Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
refactor(agent): make finance web usage dynamic
Jiayuan Zhangc5db9bf232ca
diff --git a/packages/core/src/agent/system-prompt/sections.test.ts b/packages/core/src/agent/system-prompt/sections.test.tsindex cb792de5b2..55daae5c96 100644--- a/packages/core/src/agent/system-prompt/sections.test.ts+++ b/packages/core/src/agent/system-prompt/sections.test.ts@@ -176,15 +176,18 @@ describe("buildConditionalToolSections", () => {it("includes web access section when web tools present", () => {const result = buildConditionalToolSections(["web_search"], "full");- expect(result.join("\n")).toContain("## Web Access");+ const text = result.join("\n");+ expect(text).toContain("## Web Access");+ expect(text).toContain("Web usage is conditional, not mandatory");});- it("adds data-web fusion guidance when both data and web tools are present", () => {+ it("adds dynamic evidence decision guidance when both data and web tools are present", () => {const result = buildConditionalToolSections(["data", "web_search"], "full");const text = result.join("\n");expect(text).toContain("## Data Access");- expect(text).toContain("combine them");- expect(text).toContain("macro, policy, and breaking-news context");+ expect(text).toContain("dynamic evidence decision");+ expect(text).toContain("Tool Decision");+ expect(text).toContain("plan (`data_only` | `hybrid` | `web_first`)");});it("returns empty when no conditional tools match", () => {diff --git a/packages/core/src/agent/system-prompt/sections.ts b/packages/core/src/agent/system-prompt/sections.tsindex 0a8647092f..2fe2cf8baa 100644--- a/packages/core/src/agent/system-prompt/sections.ts+++ b/packages/core/src/agent/system-prompt/sections.ts@@ -271,15 +271,23 @@ export function buildConditionalToolSections(// Data toolsif (toolSet.has("data")) {- lines.push(+ const dataLines = ["## Data Access","You have access to structured financial and market data via the `data` tool.",'Use domain="finance" with specific actions to retrieve stock prices, financial statements, SEC filings, metrics, and more.',"Always specify dates in YYYY-MM-DD format. Use period='annual' or 'quarterly' or 'ttm' for financial statements.",hasWebTools- ? "When both data and web tools are available, combine them: use `data` for structured fundamentals, and web sources for macro, policy, and breaking-news context."+ ? "When both data and web tools are available, make a dynamic evidence decision: start from structured data, and use web tools only when external validation is needed (for example: event-driven, time-sensitive, or conflicting/incomplete evidence).": "Use tool outputs as evidence, and clearly state assumptions when data is incomplete.",+ ...(hasWebTools+ ? [+ "Before final conclusions, include a short `Tool Decision` summary with: plan (`data_only` | `hybrid` | `web_first`), reason, and missing evidence impact.",+ ]+ : []),"",+ ];+ lines.push(+ ...dataLines,);}@@ -289,6 +297,7 @@ export function buildConditionalToolSections("## Web Access","You have web access. Use it when the user asks about current events, needs up-to-date information, or requests content from URLs.","Prefer web_search for discovery and web_fetch for specific URLs.",+ "Web usage is conditional, not mandatory: call web tools when they materially improve evidence quality.","",);}