After an approved tool call runs, the agent can repeat it, and approving the repeat fails with approved_tool_call_not_pending
After an approved tool call runs, the agent can repeat it, and approving the repeat fails with approved_tool_call_not_pending
Summary
We use Agent Native. Since #7480 was fixed, clicking Approve runs the approved call directly ("Running approved … action"), which works. What happens after that has three related problems:
- The agent can repeat the call it just ran. After the approved write succeeds, the model is given "Approved. Go ahead and run the requested action." as a user message after the call's successful result. In two of our three runs, the model read the saved file back and then issued the identical write again, which needed a second approval.
- Approving that second card fails. The browser sends the second approval with a different
turnIdfrom the one the approval was created under. The server returns409approved_tool_call_not_pending, and the chat shows "The agent run failed." under the card. Nothing further happens. - The earlier "Waiting for your approval to run resources." message ends up after the result. In the chat, and in the history sent to the model on the next turn, it appears after the agent's reply to the approved call.
Nothing is lost in these runs, because the first approval saves the content. But users see a second approval they didn't expect, then an error.
Environment
- Versions:
@agent-native/core,@agent-native/toolkitand@agent-native/agentkit0.209.2 - App: reproduced in a freshly scaffolded app (
create --standalone --template chat), run withagent-native dev, using the template's full-page chat route. - Model:
gpt-6-lunaviaai-sdk:openai, efforthigh, Act mode - We use
createAgentChatPluginwith the built-in chat transport and the framework's chat UI. No custom history serializer. - Not run on the latest stable release (
0.214.0). In0.214.0, the code that creates the "Approved. Go ahead and run the requested action." message,resolveAgentToolApprovalTurnId, and theapproved_tool_call_not_pendingcheck are unchanged from0.209.2. Other parts ofclient/chat/runtime.jsandagent/tool-approval-store.jsdid change.
Steps and observed behavior
We logged the request bodies the browser sent to POST /_agent-native/agent-chat, and the request bodies sent to the model provider (without headers).
- Ask the agent to create a shared skill, for example: "Can you make me a shared skill to write a pop song?" The agent calls
resourceswithaction: "write"andscope: "shared", and an approval card appears. - Click Approve. The browser sends "Approved. Go ahead and run the requested action." with the approval key and ask ID, and the original message's
turnId(…1a546d58). - The run shows "Running approved resources action" and
Wrote resource: skills/<name>/SKILL.md (4437 bytes). The skill is saved. - The model then reads the skill back and issues a second
writewith the same path and character-for-character the same content.approval_requiredfires again, and a second approval card appears. - Click Approve on the second card. The browser sends the approval with the second card's ask ID, but with
turnId…e84a0b55. The second approval was created in the run continuing turn…1a546d58. - The server responds
409{"error":"The agent run failed.","code":"approved_tool_call_not_pending","retryable":false}. The chat shows "The agent run failed." under the card, and clicking Approve again does nothing.
In a second run (a different skill), steps 1–4 happened the same way, and the 409 appeared under the second card before it was clicked. We didn't capture that request's body. In a third run, the model read the file back and replied "Done", without repeating the write.
What the model receives after approval (step 3)
The first model request after the approved call ran ends with:
assistant: tool call resources {"action":"write","path":"skills/<name>/SKILL.md","scope":"shared",…}
tool: Wrote resource: skills/<name>/SKILL.md (<n> bytes)
user: Approved. Go ahead and run the requested action.
The instruction to run the action comes after the action has already run and succeeded. In the runs that repeated the write, the model's next calls were a read of the saved file, then the same write again.
Message order on the next turn
On the next user message, the history sent to the model contains, in this order:
assistant: Done — I created the shared skill … at skills/<name>/SKILL.md. …
assistant: Waiting for your approval to run resources.
user: <next message>
The chat shows the same order: the "Waiting for your approval" text from before the approval appears below the agent's reply to the approved call. The "Worked for" labels are attached to the swapped blocks too.
Expected behavior
- After an approved call runs, the model is told the approved call has run, and isn't asked to run it again.
- Approving any pending approval in a thread works, including a second approval in the same turn.
- The pre-approval "Waiting for your approval" message stays before the result, in the chat and in the model's history.
Impact
- Users see a second approval for a change they already approved, and approving it shows "The agent run failed."
- For actions that aren't idempotent, a repeated approved call could apply the same change twice if the second approval were accepted.
Relevant code observations
These are static source observations from 0.209.2:
- In
@agent-native/coredist/agent/production-agent.js, a request withapprovedToolCallAskIdsgets409approved_tool_call_not_pendingwhenresolveAgentToolApprovalTurnId(fromdist/agent/tool-approval-store.js) returns nothing for the request's thread,turnId, approval keys and approval ID. - The "Approved. Go ahead and run the requested action." message is created in
@agent-native/coredist/client/chat/runtime.js.
Related: #7480 (approved calls not replayed). This issue covers what happens after a successful replay.
Problem 1 could go away if the identical repeat never reached a new card. I tried that rule in Python, not in Agent Native: after an approved call has run, a repeat with the same tool and arguments in the same turn returns the stored result.
| call | result | real runs |
|---|---|---|
approved write(a.md, hello) |
saved | 1 |
| model repeats it exactly | stored result, no new card | 0 |
| same tool, changed text | needs a new approval | 0 |
Your three runs show why this would help: the model read the file back and repeated the write only because the "Approved. Go ahead" message arrived after the result. Fixing that order is still the real fix. This rule is a backstop, and it would also keep the turnId mismatch from showing up here.
One thing to check: some tools are meant to run twice with the same arguments, so this could be opt-out per tool, or limited to one turn.
I maintain Call4Agents, the Python library I used for this, and this comment was written with AI assistance. It isn't needed here, since the rule fits in your approval handler.