bobbai00 opened a new pull request, #9494:
URL: https://github.com/apache/texera/pull/9494
### What changes were proposed in this PR?
Before every model call, the agent dropped the AI SDK's messages and wrote
one user message in their place: a summary of the conversation, then the
current dataflow. This PR keeps the conversation as the SDK's own messages.
| | `main` | This PR |
| --- | --- | --- |
| What the model reads | One user message the service writes again before
every call | The conversation's messages: the user's, the assistant's with its
tool calls, and the tool results |
| A past tool call | Its name, its summary and the first line of its result
| Its arguments and its whole result |
| The current dataflow | Inside that message | One message at the end of
each call's input, written again each time and never kept |
| The loop | `generateText` with `onStepFinish`, an alias AI SDK 7
deprecates | The SDK's `ToolLoopAgent` with `onStepEnd` |
| The system prompt | Describes the summary's format (1.4 KB) | Describes
the dataflow block only |
Each step keeps the messages it added, and the model reads them along the
path to HEAD, so a branch HEAD has left stays out of sight as before. A stopped
or failed turn ends with the note the chat already shows ("Generation stopped
by user.", "Error: ..."), so the next turn knows. The chat looks the same; only
its step details change, since they list what the model received:
| Step details on `main` | Step details with this PR |
| --- | --- |
| <img width="400" alt="One rebuilt message"
src="https://raw.githubusercontent.com/bobbai00/texera/de672b863ee9a4510a8aae33d8f80f11e9f63ec4/step-detail-main.png"
/> | <img width="400" alt="The conversation as native messages"
src="https://raw.githubusercontent.com/bobbai00/texera/de672b863ee9a4510a8aae33d8f80f11e9f63ec4/step-detail-this-pr.png"
/> |
### Any related issues, documentation, discussions?
Closes #9455
Part of #9453
### How was this PR tested?
- `cd agent-service && bun test` (341 pass), `bun run typecheck` and `bun
run format:check`. The new tests check, with the SDK's mock model, the exact
input of each call: a tool call and its whole result reach the next step, the
dataflow block is last and appears once, a second turn reads the first as it
happened, an abandoned branch stays out, a stopped or failed turn is part of
the next turn's history, and `clearHistory` leaves nothing behind.
- End to end with Claude Haiku 5.5 through LiteLLM, on a single-node stack
of today's images with this branch's agent-service and the Angular app. Three
prompts on the Iris example dataset (load and count it, the species with the
largest average petal length, then add the average sepal length) on `main` and
on this branch:
| | Answers correct | Model calls per turn | Input tokens |
| --- | --- | --- | --- |
| `main` | 3 of 3 | 2, 2, 2 | 79,194 |
| This PR | 3 of 3 | 2, 2, 2 | 78,384 |
- A turn stopped after its first step, followed by "Go on: finish what I
asked before", continued from the stopped turn's tool result and added only the
missing operator.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]