Repository navigation
Conversation
|
The evaluation from #9495 on this branch, against
The same cases pass and fail on both: the docs question, a change the user makes between two prompts, and the user's own execution are what later sub-issues of #9453 address. Most of each call is still the system prompt, which #9456 and #9481 shrink. |
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9494 +/- ##
============================================
- Coverage 91.68% 91.68% -0.01%
Complexity 5125 5125
============================================
Files 1305 1305
Lines 58211 58205 -6
Branches 7594 7594
============================================
- Hits 53371 53365 -6
Misses 2933 2933
Partials 1907 1907
*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:
|
9ff9816 to
bea6728
Compare
sshiv012
left a comment
There was a problem hiding this comment.
Preserving native messages makes sense, but I’m not yet convinced the practical benefit is demonstrated here. The evaluation reports the same 9/18 passing runs, with roughly 4% fewer input tokens and 2% smaller payloads.
Keeping full tool arguments and results also means retaining previous operator code and execution outputs alongside the current dataflow.
Could you add
a. A realistic case where the information lost by the current summary causes a failure that this PR resolves.
b. A longer conversation with repeated edits and executions, comparing correctness, token usage, and payload growth.
This would help establish whether the additional history improves the agent enough to justify its cost. If this is primarily groundwork for later changes, please identify which upcoming requirement depends on it.
| */ | ||
|
|
||
| import { generateText, type ModelMessage, type LanguageModel, stepCountIs } from "ai"; | ||
| import { ToolLoopAgent, isStepCount, type ModelMessage, type LanguageModel } from "ai"; |
There was a problem hiding this comment.
For durability reasons, can we consider evaluating WorkflowAgent before adopting ToolLoopAgent (in-memory) here? WorkflowAgent provides durable execution through the Workflow runtime, which also supports OpenTelemetry integration with our observability layer. Could you explain the intended durability architecture and why ToolLoopAgent is the appropriate choice?
There was a problem hiding this comment.
Good point on durability. WorkflowAgent runs the same tool loop on the Workflow runtime, so it needs that runtime and a store, and the agent's conversation and workflow copy would also have to be saved for a restart to pick them up. That needs its own design, so I'd like to leave it out of this PR and stay on ToolLoopAgent for now.
Before every model call, the agent dropped the SDK's messages and wrote one user message: a summary of the conversation followed by the current dataflow. A past tool call appeared as its name, its summary and the first line of its result. Each step now keeps the model messages it added: the user's message, or the assistant message with its tool calls and the tool results. The model reads these along the path to HEAD, so a branch HEAD has left stays out of sight. The current dataflow is one message at the end of every step's input, written again each time and never kept. The loop runs as the SDK's ToolLoopAgent, and the system prompt describes only the dataflow block. A tool call the SDK did not run, because its response was cut off, is kept with a failed result: the SDK refuses a conversation in which a call has no result, so every later turn would fail.
After addOperator or modifyOperator the service executed the operator itself, outside the tool call, and the result reached the model only through the dataflow block. That block is not kept, so on a later turn the agent found numbers in its own answers that no tool result showed, and told the user they were unverified. The two tools now execute the operator they changed and return the execution's result after their own line. A failed or stopped execution follows the change and does not turn it into a failure. The result is still filed under the step that made the change.
Every model call ended with a dataflow block that the service rebuilt for that call, so the last message changed on every call. A prompt cache point on the last message, which LiteLLM's automatic caching places, was never read back, and only the tool definitions and system prompt were reused. The block is gone: the model reads the SDK's own messages, so every call begins with the previous call's input. It reads the workflow with two new tools. getWorkflow lists each operator with its properties, schemas, compilation error and whether its result is there, outdated or failed, then the links. getOperatorResult returns an operator's latest result without executing anything, or says that it is outdated. Each result now records what it was computed from, so a change to the operator or to one it reads from makes the result outdated. disabledTools cannot switch the two tools off. The result formatter that only fed the block is removed.
getWorkflow and getOperatorResult become get_workflow and get_operator_result. New tools are named in snake_case; the four existing ones keep their names.
8944c07 to
bc92e98
Compare
What changes were proposed in this PR?
Before every model call, the agent replaced the AI SDK's messages with one summary message built around the workflow. This PR sends the SDK's own messages instead: the system prompt, then the user's messages, the assistant's messages and tool calls, and the tool results. The service adds only a short note when a turn was stopped or failed ("Generation stopped by user." or "Error: "), and an error result for a tool call the SDK did not carry out. The model reads the workflow through two new tools,
get_workflowandget_operator_result. Two things follow:mainthe summary shows only the workflow in full and cuts any other tool's successful result to its first line, so a tool about anything else needs its own section in the summary code, as feat(agent-service): add docs search and read tools #9424 adds one for its docs tools. Tools for datasets and the platform's other resources, and tools from MCP servers (Serve the agent's workflow tools from a Texera MCP server #9457), need no change to the context code here. The workflow itself is read through a tool, like any other resource.enable_anthropic_prompt_caching, which feat(deploy): upgrade LiteLLM and turn on prompt caching #9589 turns on, with no cache points set by hand) marks the system prompt and the last message, and the next request reuses what it repeats exactly. Onmainthe last message is the summary, rewritten before every call, so only the tool definitions and system prompt are reused. Here every call begins with the previous call's input.mainget_workflow: each operator's properties, schemas and compilation error, and whether its result is there, outdated or failed; then the linksget_operator_resultreturns it again, or says it is outdatedgenerateTextwithonStepFinish(deprecated in AI SDK 7)ToolLoopAgentwithonStepEndget_workflowreturnsdisabledToolscannot switch the two read tools off, since nothing else shows the model the workflow. In the agent panel, the step details show the conversation as the model receives it, and the Tools tab lists the two new tools.Any related issues, documentation, discussions?
Closes #9455
Part of #9453
How was this PR tested?
cd agent-service && bun test(365 pass),bun run typecheck,bun run format:check. With the SDK's mock model, the tests pin the exact input of each model call (native messages only, each call beginning with the previous call's input), whatget_workflowandget_operator_resultreturn, and when a result counts as outdated.20 tasks from KramaBench, a benchmark of data-science questions over data files, drawn at random from the 59 of its 104 tasks whose input files are all CSVs and whose answers are scored without an LLM judge,
mainagainst this PR on a single-node stack. Claude Haiku 5.5 through LiteLLM 1.110.2 (feat(deploy): upgrade LiteLLM and turn on prompt caching #9589 pins 1.108.17, whose automatic caching marks the same two points) withenable_anthropic_prompt_caching: trueand no cache points configured, one attempt per task and side, at most 40 steps. The tasks, prompt and scoring are those of the fork bobbai00/Kramabench, with each task's files uploaded as a dataset and named in the prompt by their dataset paths.mainAlthough this PR sends more tokens, it costs less: every call began with the previous call's input (119 of 119), so the cache could reuse it, while no call on
maindid (0 of 89), because its summary changes on every call. The costs use Claude Haiku 5.5's list prices.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5 and Claude Fable 5.2)