Skip to content

Throw ToolExecutionStopped from stopped SystemLanguageModel responses - #397

Merged
mattt merged 1 commit into
mainfrom
mattt/system-stopped-content
Nov 6, 2026
Merged

mattt merged 1 commit into
mainfrom
mattt/system-stopped-content

Conversation

@mattt

@mattt mattt commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

This PR makes a SystemLanguageModel response that a tool execution delegate stops behave like one from the HTTP models. Until now, such a response ended with 0 for Int and false for Bool, which looks like the model's answer, and threw GeneratedContentError.typeMismatch for a structure with required properties. The model now uses the shared StoppedContent values in respond and in streaming, and throws LanguageModelSession.ToolExecutionStopped with the transcript entries for types that can't be empty. A stream keeps its last snapshot only if that snapshot decodes as the complete type, and the error from a stream carries the usage of its requests, so the session counts them.

@mattt
mattt merged commit e1de7e1 into main Nov 6, 2026
12 checks passed
@mattt
mattt deleted the mattt/system-stopped-content branch November 6, 2026 08:07
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.

1 participant