refactor(agent): make finance web usage dynamic
This commit is contained in:
parent
f2adddcde7
commit
c5db9bf232
2 changed files with 18 additions and 6 deletions
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -271,15 +271,23 @@ export function buildConditionalToolSections(
|
|||
|
||||
// Data tools
|
||||
if (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.",
|
||||
"",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue