Anthropic Interaction Example
Anthropic Interaction Example
Section titled “Anthropic Interaction Example”Back to Anthropic Messages.
This page mirrors the detailed Chinese interaction example in a compact English form. It is a protocol illustration, not a replayable upstream fixture.
Scenario
Section titled “Scenario”The user asks whether Beijing is suitable for running today. The client exposes a local get_weather tool, while the upstream may use an Anthropic server-side web_search tool.
- 1
client requestClient sends `messages`, local `get_weather`, server `web_search`, and `stream: true`.
- 2
provider pass-throughProxAI forwards the Anthropic Messages request to the configured upstream.
- 3
first SSE turnUpstream emits server-tool use/result blocks and a local `tool_use(get_weather)` block.
- 4
local tool runtimeClient runs `get_weather` using the accumulated `input_json_delta` fragments.
- 5
second requestClient sends the previous assistant `tool_use` plus a user-side `tool_result`.
- 6
final SSE answerUpstream emits text deltas and ends with `message_delta(stop_reason=end_turn)` plus `message_stop`.
ID relationships
Section titled “ID relationships”| ID | Source | How it is used later |
|---|---|---|
srvu_01 | server_tool_use | Executed by the upstream service; the client does not send a matching tool result. |
srvr_01 | web_search_tool_result | Identifies the server-tool result block itself. |
toolu_01 | tool_use(get_weather) | Client executes the local tool and sends tool_result.tool_use_id = toolu_01 in the next request. |
Stream assembly rule
Section titled “Stream assembly rule”Anthropic streaming joins content deltas by content_block index:
content_blocks[index] = started blockpartial_tool_inputs[index] += input_json_delta.partial_jsonWhen content_block_stop(index=2) arrives, the client can parse the accumulated partial JSON and use the same block’s ToolUseBlock.id as the local tool call id.