Repository navigation
Fix Agent Flow evidence schema fallback #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c0e3751
03c89bb
fd10556
690d1a4
e15a73e
d1d16f1
ff26db2
8acc8c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,6 +139,8 @@ export async function aiJsonWithFallback(messages: Message[], valid: (value: Rec | |
| jsonParsed: Boolean(parsed), | ||
| }); | ||
| failures.push(`${provider.label}-invalid-response`); | ||
| // Retry one schema-invalid response within the same provider and route deadline. | ||
| if (attempt === 0 && timeoutMs > 9000) continue; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When both providers use the default 20-second budget, the primary provider receives about 6.7 seconds, so Useful? React with 👍 / 👎. |
||
| break; | ||
| } catch (error) { | ||
| failures.push(`${provider.label}-${error instanceof Error && error.name === "TimeoutError" ? "timeout" : "network-error"}`); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
| import { readFile } from "node:fs/promises"; | ||
|
|
||
| test("Agent Flow prompt requests evidence point fields its validator requires", async () => { | ||
| const route = await readFile(new URL("../app/api/research/agent-flow/route.ts", import.meta.url), "utf8"); | ||
| const policy = await readFile(new URL("../lib/agent-flow-policy.ts", import.meta.url), "utf8"); | ||
| assert.ok(policy.includes("text: string; citedUrls: string[]")); | ||
| assert.ok(policy.includes("row.citedUrls")); | ||
| assert.ok(route.includes("Each supportingEvidence and counterEvidence item must be {text,citedUrls:[exact supplied URLs]}")); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a provider returns an otherwise valid asset but keeps the old evidence shape—such as strings or objects without
text—normalizeFlowAssessmentsilently drops those entries and still returns a non-null assessment. Consequently this validity callback accepts the response, the newly added retry never runs, and users receive a completed assessment with its supporting and counter evidence missing. The validator must reject malformed non-empty evidence arrays, rather than relying only on this prompt instruction, for the fallback change to address the reported schema failure.Useful? React with 👍 / 👎.