Tool calls from previous turns are dropped silently, so the agent denies work it did (follow-up to #6825)
Summary
Following #6825, 0.203.0 (#6835) started sending completed tool calls from earlier turns as structuredHistory. On 0.207.0 some or all of those calls are missing, with no omission note.
The cause is in the server's thread-snapshot merge: a tool call stored as completed is never updated, so the messageId the browser adds later (once the reply text starts) is discarded. After the run the browser reloads the thread, gets tool calls with no messageId, and messagesWithToolCallHistory skips them. The model then concludes it did not do work it actually did, and the chat suggests repeating it.
Environment
- App: Flow (internal editorial app built on Agent-Native)
@agent-native/core:0.207.0@agent-native/agentkit:0.207.0- Model:
gpt-5.6-terraviaai-sdk:openai, efforthigh, Act mode - We use
createAgentChatPluginwith the built-in agent-native chat transport and the framework's chat UI. - We do not use a custom chat engine or history serializer.
- No page reload between messages.
Steps and observed behavior
Run 1, new chat (partial loss):
- Ask: "You write me a skill that gives me three headline options for a certain body of text or for a certain subject." The agent makes four
resourcescalls, all successful:readskills/write-skill/SKILL.md,listskills/,writeskills/three-headline-options/SKILL.md("Wrote resource … (1017 bytes)"), andreadof the new skill. It replies: "Created and saved the personal three-headline-options skill…" - Ask: "Tell me exactly what resources calls you made here or what tool calls you made in your last response".
- The follow-up request's
structuredHistorycontains only the fourth call (the read-back). The first three, including the write, are missing, with no omission note. - The agent replies: "I made one tool call: … I did not create, write, save, or modify any resource—so my previous statement that I had 'created and saved' it was incorrect." A "Save the skill now" suggestion is shown.
Run 2, new chat (total loss), captured as a HAR:
- Ask: "Can you update my three headline option skills to be much more concise in its description?" The agent makes four
resourcescalls (readwrite-skill, read the skill, write it, read it back) before writing any text, then replies: "Updated and verified the personal three-headline-options skill…" - Ask: "what tool calls exactly did u make to find out". The request has no
structuredHistoryfield and no omission note. - The agent replies: "None in the recorded turn—the earlier reply was incorrect. I did not call
resources…". An "Update the skill now" suggestion is shown.
What the HAR shows (run 2)
| Time (UTC) | Request | Tool calls in it |
|---|---|---|
| 14:21:12 | PUT /agent-chat/threads/:id (mid-run snapshot delta) |
Calls 1–2, status: "completed", no messageId (no assistant message existed yet) |
| 14:21:18 | PUT …/threads/:id (mid-run) |
Calls 3–4, completed, no messageId |
| 14:21:20 | PUT …/threads/:id ×3 (after the reply) |
All four, completed, messageId: "message-ffb19f57-…" (the reply) |
| 14:21:20–14:21:29 | GET …/threads/:id ×4 |
All four, completed, no messageId |
| 14:21:29 | POST /agent-chat (follow-up) |
No structuredHistory |
Cause
preferIncomingSnapshotEntry in packages/core/src/agent/thread-data-builder.ts only accepts an incoming tool call when the stored copy is still running:
if (kind === "toolCall") return existing.status === "running" && incoming.status !== "running";
When a model makes its tool calls before any reply text (common with OpenAI models), the browser saves those calls as completed with no messageId, because there is no assistant message to link them to yet (pendingToolMessageAssociations in agentkit-protocol.ts). When the reply starts, the browser re-saves them with the messageId. The server keeps the stored copy, so the link is lost. Run 1 fits this pattern: the last call was presumably still running at the last mid-run save, so its completed, linked copy replaced the stored one.
After the run, the browser reloads the thread and uses the server's tool calls. messagesWithToolCallHistory in packages/agentkit/src/client/client.ts keeps only calls whose messageId matches an assistant message (eligibleCalls). Unlinked calls are skipped without setting omittedHistory, so no omission note is added either.
Expected behavior
The next request should include every completed tool call and result from the previous turn, within the documented bounds (64 calls / 256 KiB), or an omission note when any are left out.
Impact
Follow-up questions about earlier actions, such as "did you save it?" or "what did you change?", get incorrect answers. In both runs the agent told the user a completed write had not happened, and the chat suggested doing it again. For tools with side effects, following that suggestion would repeat completed work.
Related behavior in 0.205.0
On 0.205.0 we also saw all tool history for a turn dropped with the note "Tool-call history was omitted because its position could not be reconstructed safely" (messagePartsWithToolHistory). That may be a separate path.