MCPcopy
hub / github.com/docker/docker-agent / streamAdapter

Struct streamAdapter

pkg/model/provider/anthropic/adapter.go:19–31  ·  view source on GitHub ↗

streamAdapter adapts the Anthropic stream to our interface

Source from the content-addressed store, hash-verified

17
18// streamAdapter adapts the Anthropic stream to our interface
19type streamAdapter struct {
20 retryableStream[anthropic.MessageStreamEventUnion]
21
22 trackUsage bool
23 toolCall bool
24 stopReason anthropic.StopReason
25 // toolIDByBlock maps a content block index to its tool_use block ID.
26 // Anthropic emits each tool_use in its own content block; subsequent
27 // input_json_delta events carry the block index (not the tool ID), so
28 // we must remember the ID per block to route partial JSON correctly
29 // when multiple tool calls stream in parallel.
30 toolIDByBlock map[int64]string
31}
32
33func (c *Client) newStreamAdapter(stream *ssestream.Stream[anthropic.MessageStreamEventUnion], trackUsage bool) *streamAdapter {
34 return &streamAdapter{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected