Repository navigation
trading-desk: add Company Profile analyst as 5th Phase 1 grounding agent (FIX-606) - #286
Conversation
…ent (FIX-606) A renderer-style analyst that fetches structured business identity (name, sector, industry, description, scale) from Finnhub /stock/profile2 + Yahoo quoteSummary and renders it as a memo, so downstream phases reason from data instead of training priors. The prompt constrains the LLM to trace every claim to a `<data>` field and to quote one figure verbatim; when no provider can resolve the ticker the memo explicitly says so rather than inventing the company. Runs in parallel with the existing four Phase 1 analysts; downstream phases pick it up via the existing `formatAnalystMemos` flow (no capability or formatter changes). `setupPhase1Memos` is refactored to derive its memoStatus seed from `PHASE_1_MEMO_KEYS` so future analyst additions don't have to touch this file.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| technical: technicalAnalyst, | ||
| companyProfile: companyProfileAnalyst, | ||
| }, | ||
| { maxConcurrency: 4 }, |
There was a problem hiding this comment.
maxConcurrency was not updated when the 5th analyst was added. With 5 branches and maxConcurrency: 4, the framework queues one analyst until another finishes — so they never all run simultaneously, directly contradicting the label "5 analysts dispatched in parallel."
| { maxConcurrency: 4 }, | |
| { maxConcurrency: 5 }, |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bda09df. Configure here.
| sentiment: sentimentAnalyst, | ||
| news: newsAnalyst, | ||
| technical: technicalAnalyst, | ||
| companyProfile: companyProfileAnalyst, |
There was a problem hiding this comment.
maxConcurrency not updated for fifth parallel analyst
Medium Severity
maxConcurrency is still 4 but there are now 5 parallel analyst branches. The framework's mapWithConcurrency creates only min(limit, values.length) workers, so the fifth analyst (company profile) will be queued behind the first four instead of running concurrently. This contradicts the label on line 24 ("5 analysts dispatched in parallel") and adds unnecessary latency to every run, since the company profile fetch is the fastest of the five.
Reviewed by Cursor Bugbot for commit bda09df. Configure here.
Replace `block.config.execute!` direct calls with `testBlock` from `@flow-state-dev/testing` — the public test surface. The framework wraps thrown `FixtureMissingError` in a `FlowError` whose message preserves the original cause, so the missing-fixture assertion now checks message content instead of the wrapped error class.
|
Bot review triage:
Generated by Claude Code |
`assetProfile` does not include `longName`/`shortName` — those live in `quoteType`. As written the Yahoo fallback's name would always be null and the function would always throw, silently making the fallback dead code. Add `quoteType` to the modules list, read the name (and the exchange, which `quoteType` does carry) from there. The spec's mapping table was incorrect on this point.
Two changes that together solve "no business description" in live mode:
1. Provider merge. The chain was Finnhub-OR-Yahoo (whichever answered
first). Finnhub almost always answers but doesn't carry sector or
businessDescription — those fields stayed null even when Yahoo
could have supplied them. Now both providers run via
Promise.allSettled and we field-by-field merge: Finnhub wins where
it has a value, Yahoo fills the gaps. Source tag reflects the
primary identity contributor.
2. Web enrichment backstops. Two new schema fields populated in live
mode after the provider merge:
- websiteMetaDescription: the company's own homepage
<meta name="description"> (or og:description, longer wins).
Deterministic regex extraction, no LLM.
- searchSnippets: top web-search results for the company name,
via @flow-state-dev/tools/search's auto-detected provider
(Tavily, Exa, Perplexity, Serper, Brave, Perplexity-Sonar).
Both fail soft to null — missing search keys or an unreachable
homepage never blocks the analyst.
The prompt is updated to teach the analyst about the new fields, the
inline source-attribution rule ("per the company's homepage", "per
Reuters", etc.), and that the verbatim-quote requirement can be
satisfied from any of the three description sources.
`resolveProvider` is now exported from `@flow-state-dev/tools/search`
so callers running a search inside another handler's execute don't
have to instantiate the search tool block (which would violate
AGENTS.md rule 4).
Fixtures gain the two new fields as null — the curated
businessDescription was already populated.


Summary
Adds a fifth Phase 1 analyst — Company Profile Analyst — to
examples/trading-desk. It grounds the desk in what the underlying business actually is (name, sector, industry, business description, scale) using real provider data, so downstream phases reason from a data-derived profile rather than the model's training priors./stock/profile2(preferred) + YahooquoteSummary(assetProfile + summaryDetail) and renders them. The prompt constrains the LLM to trace every body claim to a<data>field, with a "quote one figure verbatim" requirement as a structural defense against fabrication. The shared<grounding>clause from FIX-605 reinforces the boundary.phase1AllErroredGuard.examples/trading-desk/. Composes cleanly into the existing fan-out — downstream phases pick the memo up via the existingformatAnalystMemosflow.setupPhase1Memosnow derives itsmemoStatusseed fromPHASE_1_MEMO_KEYSso future analyst additions don't touch this file.Implementation follows the attached spec (FIX-606: Company Profile Analyst — Implementation Spec) step-for-step.
Files
phase-1/tools/get_company_profile.ts,phase-1/tools/get_company_profileschema + empty payload,companyProfilePrompt,companyProfileGenerator+companyProfileAnalystsub-sequencer.services/finnhub.ts::fetchFinnhubCompanyProfile,services/yahoo.ts::fetchYahooCompanyProfile.2026-05-06.phase-1/index.ts.parallel(label updated to "5 analysts"),PHASE_GROUPS.p1,PHASE_1_MEMO_KEYS,PHASE_1_ANALYST_AGENTS(transcript),PUBLISH_ORDER(theses pane).examples/trading-desk/README.md,apps/docs/guides/trading-desk-walkthrough.md,docs/internal/design/trading-desk.md,changelog.md.Test plan
pnpm --filter @flow-state-dev/example-trading-desk typecheck— cleanpnpm --filter @flow-state-dev/example-trading-desk test— 91 passed (22 files)pnpm typecheck(workspace) — cleantest/get-company-profile.spec.tscovers fixture mode, missing-fixture error, Finnhub success, both-providers-unavailable, and schema-strictness of the empty payload.test/setup.spec.tsupdated to 5 pending memos.test/session-resources-layout.spec.tsupdated to expect 8 memo keys (was 7) and mock the new generator.fsdev runon NVDA fixture mode — not run in this environment; reviewer can verify locally per the spec's Step 12 verification list.Fixes FIX-606.
Generated by Claude Code
Note
Medium Risk
Adds a new Phase 1 agent plus a new live/fixture data-fetch tool (Finnhub/Yahoo) and updates memo seeding/order, which could affect pipeline orchestration and run behavior despite being scoped to the example.
Overview
Adds a fifth Phase 1 analyst (
companyProfileAnalyst) to the Trading Desk example that fetches and renders structured company identity/scale data into a newmemos/p1/company-profilememo, and wires it into Phase 1 parallel fan-out, agent registries, and UI publish ordering.Introduces a new
get_company_profiletool with fixture support and a live fallback chain (Finnhub preferred, Yahoo fallback, then explicitunavailablepayload) plus prompt constraints to keep the memo grounded in returned fields.Updates fixtures, tests, and docs to reflect the extra analyst/memo, and refactors
setupPhase1Memosto derive initialmemoStatuskeys fromPHASE_1_MEMO_KEYSinstead of hardcoding Phase 1 entries.Reviewed by Cursor Bugbot for commit bda09df. Configure here.
Greptile Summary
Adds a fifth Phase 1 analyst (
companyProfileAnalyst) to the Trading Desk example that fetches structured company identity/scale data from Finnhub and Yahoo, enriches it with homepage meta-description and web search snippets as fallbacks, and renders it into a newmemos/p1/company-profilememo.get_company_profiletool runs Finnhub and Yahoo concurrently, merges fields with Finnhub preferred for identity/scale and Yahoo for sector/description, then falls back to web enrichment when both structured providers leave the description null; all three fallback steps fail-soft viaPromise.allSettled.setupPhase1Memosis refactored to derive itsmemoStatusseed fromPHASE_1_MEMO_KEYSrather than a hardcoded list, so future analyst additions no longer require touching that file.companyProfileAnalystis wired into the Phase 1 parallel fan-out, agent registry, and UI publish order; fixtures for NVDA/AAPL/JPM and a full test suite covering fixture, live, both-providers-fail, web-enrichment, and schema-validity paths are included.Confidence Score: 5/5
Safe to merge — the new analyst composes cleanly into the existing fan-out pattern and all failure modes degrade gracefully.
The change is well-scoped to the trading-desk example. The provider fetch chain is wrapped in Promise.allSettled at every layer, so network failures or missing API keys never block the pipeline. The Yahoo name-field bug identified in a prior review is correctly resolved here. The setup refactor is a clean DRY improvement. Tests cover all key branches and use the correct testBlock API. No logic errors found in the merge, enrichment, or prompt wiring.
No files require special attention beyond the two minor comment corrections in services/web.ts.
Important Files Changed
Sequence Diagram
sequenceDiagram participant P1 as phase1Pipeline participant CP as companyProfileAnalyst participant Tool as get_company_profile participant FH as Finnhub /stock/profile2 participant YH as Yahoo quoteSummary participant Web as fetchWebsiteMetaDescription participant Search as searchCompanyWeb participant Gen as companyProfileGenerator (LLM) participant Memo as memos/p1/company-profile P1->>CP: ".parallel({ companyProfile: companyProfileAnalyst })" CP->>Tool: execute(ticker, date) alt fixture mode Tool-->>CP: loadFixture("company-profile.json") else live mode Tool->>FH: fetchFinnhubCompanyProfile Tool->>YH: fetchYahooCompanyProfile Note over FH,YH: Promise.allSettled — both run concurrently FH-->>Tool: profile (or rejected) YH-->>Tool: profile (or rejected) alt both fail Tool-->>CP: emptyPayload (source: unavailable) else at least one succeeds Tool->>Tool: field-level merge (Finnhub preferred) Tool->>Web: fetchWebsiteMetaDescription(website) Tool->>Search: searchCompanyWeb(name) Note over Web,Search: Promise.allSettled — both fail-soft to null Web-->>Tool: "metaDescription | null" Search-->>Tool: "snippets[] | null" Tool-->>CP: enriched profile end end CP->>Gen: companyProfileGenerator(companyProfile) Gen-->>CP: thesis (title, body, rating, metrics) CP->>Memo: commitMemo(companyProfile)Comments Outside Diff (1)
changelog.md, line 75-81 (link)AGENTS.md says "Lead each bullet with the fact, not bolded preamble. Bolded category labels at the start of every bullet are not [allowed]." All five new bullets open with a bold label (
**Renderer, not synthesizer.**,**Provider chain reuses what's already wired:**, etc.). The older entries in the same file (e.g., 2026-04-11) lead directly with the fact as a plain sentence.Context Used: AGENTS.md (source)
Reviews (4): Last reviewed commit: "trading-desk: merge providers + web-enri..." | Re-trigger Greptile