Repository navigation
feat(agent-service): show past tool results in the agent's history - #9244
Conversation
Automated Reviewer SuggestionsBased on the
|
Backport auto-label reportThis
|
bobbai00
left a comment
There was a problem hiding this comment.
🔴 1 must-fix · 3 advisory · 0 polish: the history now follows the prompt's layout, but until #9120 lands a multi-line error reaches the model as its first line only.
Correctness (3)
context-utils.ts:153: multi-line[ERROR]results keep only their first line whileisErroris unset (must-fix, see inline)context-utils.spec.ts:167: a call with no result is one the SDK rejected, shown as succeeded (advisory, see inline)context-utils.ts:127: results are matched to calls by position, not bytoolCallId(advisory, see inline)
Conventions (1)
context-utils.spec.ts:137: title typefixversus AGENTS.md's type table, which also drives the backports (advisory, see inline)
Verification trace
Ran context-utils.spec.ts at bb28d64 (bun 1.3.14): 14 pass. Reproduced the must-fix by feeding assembleContext the strings executeOperatorAndFormat returns, with isError computed as onStepFinish does: the validation failure renders Output: [ERROR] Operator op8: and the execution failure Output: [ERROR] Execution failed due to the following error:. In ai 7.0.58, step.toolResults keeps only tool-result parts; a call with schema-invalid input gets a tool-error part instead, so it has no result here.
bobbai00
left a comment
There was a problem hiding this comment.
🟡 4 resolved · 0 open · 1 new (1 new = 1 newly introduced · 0 late catches): every round-1 finding is fixed or answered. What remains is updating the PR description.
Conventions (1)
context-utils.ts:154: the description still says an unflagged[ERROR]result shows on anOutput:line (advisory, see inline)
Verification trace
Ran context-utils.spec.ts at 360e30f (bun 1.3.14): 15 pass, and tsc --noEmit is clean. Reverting the [ERROR] check fails the unflagged-error test, and reverting to index pairing fails the id-matching test. Against current main (the merge is clean), tool errors are still [ERROR] ... strings, isError is recorded the same way, and in ai 7.0.152 step.toolResults still holds only tool-result parts.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9244 +/- ##
=========================================
Coverage 91.79% 91.79%
Complexity 5023 5023
=========================================
Files 1283 1283
Lines 56872 56887 +15
Branches 7440 7440
=========================================
+ Hits 52204 52219 +15
Misses 2800 2800
Partials 1868 1868
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The turn history listed each past tool call by name only, although the system prompt describes Summary, Output and Error lines under it. A failed call gave the model no reason, so it repeated the same call. Each past call now carries the summary from its input, then either the first line of its output or, for a failed call, the full error. Operator data stays in the dataflow section. Closes apache#9119 Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up. Tool errors are "[ERROR] ..." strings and isError is not set for them yet, so a multi-line execution error kept only its first line. The marker now counts as an error alongside isError, as serializeOperator already does. Results are matched to calls by toolCallId, so a call the SDK rejected cannot take the next call's result. Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <[email protected]>
360e30f to
b204f36
Compare
…pache#9259) ### What changes were proposed in this PR? Tool failures returned as `[ERROR]` strings and SDK-generated `tool-error` parts must be persisted as failures so subsequent agent turns receive the correct status. This change builds stored results from step content, matches results to calls by `toolCallId`, and reuses normalized failure status to prevent delegate execution after rejected modifications. A shared `isErrorResult` predicate keeps string classification beside `createErrorResult`. Thrown errors are stored as readable messages so they survive JSON snapshots and appear in subsequent context. Calls without a recorded result are marked failed. History formatting uses the normalized `isError` flag. Regression coverage includes error-prefixed output, SDK-rejected calls, reordered results, throwing tools (Error, string and null values), length-limited calls that never execute, and suppression of execution after rejected modifications. ### Any related issues, documentation, discussions? Closes apache#9120 Related: apache#9244, whose tool-history presentation relies on accurate persisted failure status. ### How was this PR tested? From `agent-service`: - `bun test`: 347 passed, 0 failed - `bun run typecheck`: passed - `bun run format:check`: passed - `git diff --check`: passed The new behavior assertions reproduced the failures before the production fix. Validation used Bun 1.3.3 and the repository’s frozen lockfile. The full test run required local socket access for the server tests. GitHub CI results remain separate from these local checks. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex
…pache#9259) ### What changes were proposed in this PR? Tool failures returned as `[ERROR]` strings and SDK-generated `tool-error` parts must be persisted as failures so subsequent agent turns receive the correct status. This change builds stored results from step content, matches results to calls by `toolCallId`, and reuses normalized failure status to prevent delegate execution after rejected modifications. A shared `isErrorResult` predicate keeps string classification beside `createErrorResult`. Thrown errors are stored as readable messages so they survive JSON snapshots and appear in subsequent context. Calls without a recorded result are marked failed. History formatting uses the normalized `isError` flag. Regression coverage includes error-prefixed output, SDK-rejected calls, reordered results, throwing tools (Error, string and null values), length-limited calls that never execute, and suppression of execution after rejected modifications. ### Any related issues, documentation, discussions? Closes apache#9120 Related: apache#9244, whose tool-history presentation relies on accurate persisted failure status. ### How was this PR tested? From `agent-service`: - `bun test`: 347 passed, 0 failed - `bun run typecheck`: passed - `bun run format:check`: passed - `git diff --check`: passed The new behavior assertions reproduced the failures before the production fix. Validation used Bun 1.3.3 and the repository’s frozen lockfile. The full test run required local socket access for the server tests. GitHub CI results remain separate from these local checks. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex
What changes were proposed in this PR?
serializeTaskwrote each past tool call as one line,- <tool> (<status>). The system prompt (prompts.ts) says each call also hasSummary,OutputorErrorlines under it, but they were never added. When a call failed, the model never saw why, so it made the same call again.Each past call now has, in the prompt's layout:
Summary:, thesummarythe model passed in the call, when it gave oneOutput:, the first line of the tool's result. That line is the tool's one-line summary, for exampleAdded operator op1, ...orExecuted operator op1. Operator data is already in the dataflow section, so it is not repeated.Error:, the full error, indented, when the result is marked as failedA call that has no result yet still shows only its name.
This is separate from #9120, which @oliarmak-web is fixing. That one sets
isErrorfor[ERROR]results. Until it lands, a failed call's message still reaches the model through itsOutput:line (for exampleOutput: [ERROR] Source operator "op7" not found). After it lands, the same call gets the fullError:block.Any related issues, documentation, discussions?
Closes #9119
How was this PR tested?
New tests in
context-utils.spec.ts:[ERROR]result that isn't flagged as an error still shows its message on theOutput:line.Both fail without the change. Locally:
bun test(326 pass),tsc --noEmitandprettier --checkare clean.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5). I reviewed and tested the change.
🤖 Generated with Claude Code