Skip to content

Persist tool call error state in session messages#1711

Merged
rumpl merged 1 commit intodocker:mainfrom
trungutt:gordon-persist-tool-is-error
Feb 12, 2026
Merged

Persist tool call error state in session messages#1711
rumpl merged 1 commit intodocker:mainfrom
trungutt:gordon-persist-tool-is-error

Conversation

@trungutt
Copy link
Contributor

When a tool call fails (either from execution error or user rejection), the IsError flag was only sent in the streaming SSE event but never stored on the tool response message in the session. This means that when a session is reloaded, the error state is lost and failed tool calls appear as if they succeeded.

This PR adds an IsError field to chat.Message and populate it from the tool execution result in both executeToolWithHandler and addToolErrorResponse. Also pass the persisted value through to the Anthropic provider instead of hardcoding false, so that the model receives accurate error context on session resumption.

When a tool call fails (either from execution error or user rejection),
the IsError flag was only sent in the streaming SSE event but never
stored on the tool response message in the session. This means that
when a session is reloaded, the error state is lost and failed tool
calls appear as if they succeeded.

Add an IsError field to chat.Message and populate it from the tool
execution result in both executeToolWithHandler and
addToolErrorResponse. Also pass the persisted value through to the
Anthropic provider instead of hardcoding false, so that the model
receives accurate error context on session resumption.
@trungutt trungutt requested a review from a team as a code owner February 12, 2026 18:02
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

No issues found - The implementation looks solid!

This PR correctly adds persistence for the tool call error state. The changes properly:

  • Add the IsError field to chat.Message with appropriate JSON serialization
  • Populate it from res.IsError in executeToolWithHandler
  • Set it to true in addToolErrorResponse for explicit error cases
  • Pass the persisted value to the Anthropic provider instead of hardcoding false

The error handling paths ensure res is always initialized before accessing res.IsError, and the bool field defaults to false for existing messages, maintaining backward compatibility.

Great work! 🚀

Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

Could use a test somewhere

@rumpl rumpl merged commit 5c6ac0e into docker:main Feb 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants