Skip to content

feat(agent-service): show past tool results in the agent's history - #9244

Merged
bobbai00 merged 2 commits into
apache:mainfrom
shaynhornik:fix/agent-history-tool-results
Nov 16, 2026
Merged

bobbai00 merged 2 commits into
apache:mainfrom
shaynhornik:fix/agent-history-tool-results

Conversation

@shaynhornik

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

serializeTask wrote each past tool call as one line, - <tool> (<status>). The system prompt (prompts.ts) says each call also has Summary, Output or Error lines 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:, the summary the model passed in the call, when it gave one
  • Output:, the first line of the tool's result. That line is the tool's one-line summary, for example Added operator op1, ... or Executed 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 failed

A call that has no result yet still shows only its name.

This is separate from #9120, which @oliarmak-web is fixing. That one sets isError for [ERROR] results. Until it lands, a failed call's message still reaches the model through its Output: line (for example Output: [ERROR] Source operator "op7" not found). After it lands, the same call gets the full Error: block.

Any related issues, documentation, discussions?

Closes #9119

How was this PR tested?

New tests in context-utils.spec.ts:

  • Summary, first-line Output and an indented multi-line Error are written under their calls, a call with no result gets nothing extra, and an operator's table data stays out of the history.
  • An [ERROR] result that isn't flagged as an error still shows its message on the Output: line.

Both fail without the change. Locally: bun test (326 pass), tsc --noEmit and prettier --check are 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

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @bobbai00
    You can notify them by mentioning @bobbai00 in a comment.

@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Nov 2, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 November 2, 2026 00:29
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
✅ release/v1.3 Change detected on this branch — label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.
✅ release/v1.2 Change detected on this branch — label added; this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.

Auto-label run.

@bobbai00
bobbai00 self-requested a review November 2, 2026 18:18

@bobbai00 bobbai00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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 while isError is 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 by toolCallId (advisory, see inline)

Conventions (1)

  • context-utils.spec.ts:137: title type fix versus 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.

@shaynhornik shaynhornik changed the title fix(agent-service): show past tool results in the agent's history feat(agent-service): show past tool results in the agent's history Nov 3, 2026
@mengw15 mengw15 removed the release/v1.3 back porting to release/v1.3 label Nov 9, 2026

@bobbai00 bobbai00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 an Output: 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-commenter

codecov-commenter commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (716ab3c) to head (b204f36).

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           
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 716ab3c
agent-service 99.56% <100.00%> (+<0.01%) ⬆️
amber 85.75% <ø> (ø) Carriedforward from 716ab3c
computing-unit-managing-service 64.05% <ø> (ø) Carriedforward from 716ab3c
config-service 87.73% <ø> (ø) Carriedforward from 716ab3c
file-service 82.31% <ø> (ø) Carriedforward from 716ab3c
frontend 96.43% <ø> (ø) Carriedforward from 716ab3c
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 716ab3c
pyamber 98.50% <ø> (ø) Carriedforward from 716ab3c
workflow-compiling-service 78.30% <ø> (ø) Carriedforward from 716ab3c

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

shaynhornik and others added 2 commits November 15, 2026 16:10
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]>
@bobbai00
bobbai00 force-pushed the fix/agent-history-tool-results branch from 360e30f to b204f36 Compare November 16, 2026 00:10
@github-actions github-actions Bot added the fix label Nov 16, 2026
@bobbai00
bobbai00 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into apache:main with commit 205fe77 Nov 16, 2026
22 checks passed
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 18, 2026
…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
Ma77Ball pushed a commit to Ma77Ball/texera that referenced this pull request Nov 21, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent does not see tool errors in its history, so it repeats the same failing call

5 participants