Skip to content

Streamable tool calls with Anthropic Models#176

Open
ActuallyTaylor wants to merge 11 commits into
huggingface:mainfrom
impel-intelligence:fix/stream-stop-from-tool-call
Open

Streamable tool calls with Anthropic Models#176
ActuallyTaylor wants to merge 11 commits into
huggingface:mainfrom
impel-intelligence:fix/stream-stop-from-tool-call

Conversation

@ActuallyTaylor

@ActuallyTaylor ActuallyTaylor commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a streaming transcript object that allows the streaming endpoints to stream tool calls back to the user as the model works.

Features

  • Session.transcript automatically updates as content is streamed.
  • The Anthropic stream function has been updated with an infinite loop until there are no tool calls.
    • This was mirrored from the OpenAI endpoint.
  • (Breaking) Updated Anthropic Thinking structures to match new APIs
    • Changed Thinking.init to take a specified type, budget tokens, and display type instead of a static type.
    • Added two static connivence methods .adaptive(display:) and .enabled(budgetTokens:,display:) to easily create thinking structures configured to match the Anthropic APIs.
  • Updated AnthropicLanguageModel tests to reflect the streamable transcripts.

Other Approaches

I first attempted to stream the transcript through a second API named streamTranscript. I decided not to go down this route since it would require duplicated streaming code in the model, as well as the need to make every transcript structure conform to Generable and PartiallyGenerated.

Support

Currently only supported on the Anthropic Provider.

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Previously, tool use would cancel the response. This meant that the model would never get to use the result of its tools. This fix adds an infinite loop similair to the OpenAI implementation

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
This also brings tool support in the streaming endpoint for anthropic models

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
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