fix: surface task_id in interrupted tool error text for LLM resume#35222
fix: surface task_id in interrupted tool error text for LLM resume#35222flaxodev wants to merge 1 commit into
Conversation
…resume them
When a user aborts a running sub-agent, the Task tool's sessionId is persisted in the tool part's metadata but never surfaced to the LLM. The agent only sees "Tool execution aborted" with no way to know the sub-agent's session ID, so it cannot resume the aborted task via the task_id parameter.
Include the task_id in the error text rendered to the LLM for any
interrupted tool call that has sessionId in its state metadata.
The agent will see:
Tool execution aborted
`task_id: ses_0d76b70c6ffekT4JcAvvXEuaeI`
And can pass that task_id back to the Task tool to resume the
sub-agent with its full conversation history intact.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
I've been thinking for a long time to make the task_id return even if the agent stalls out, errors, etc. Just too many higher priority issues to work on. A fix is needed. The recovery pattern for agents is typically trying to resume the session and observing it fail without understanding why, and then just retasking a fresh subagent. Which works, but its sometimes inefficient and creates more token burn. The additional feature that's needed though is for when subagents fail to return, due to interruption or an error (such as a connection timeout), relaying the error message or the last section of text and message type (e.g. an agent was interrupted or stalled out with last messages being thinking blocks). That way the tasking agent can have enough information to better infer and understand why the subagent failed to return, and initiate more appropriate recovery processes. This would help make more autonomous workflows; less need for humans to help agents understand why a subagent session failed to return. I'd suggest expanding the scope of the fix as needed to fully address matters. |
The sub-agent session ID was persisted in DB metadata on abort but
never rendered to the LLM. Include task_id in the error text so the
agent can resume aborted sub-agents via the Task tool's task_id
parameter.
Issue for this PR
Related to #35177
Closes #
Closes #35177
Type of change
What does this PR do?
The sub-agent session ID was persisted in DB metadata on abort but
never rendered to the LLM. Include task_id in the error text so the
agent can resume aborted sub-agents via the Task tool's task_id
parameter.
How did you verify your code works?
I tested my changes locally
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist