-
Notifications
You must be signed in to change notification settings - Fork 117
Description
Description:
When user makes streaming request with tool use for claude code, the first chunk has "input":{}, and the following chunk has partial_json. User needs to concatenate input field so they will get an invalid json:
"input": {}{"location": "San Francisco, CA", "unit": "renheit"}
This will fail JSON validation check:
| return nil, fmt.Errorf("failed to unmarshal content_block_start: %w", err) |
event: content_block_start
data: {"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01T1x1fJ34qAmk2tNTrN7Up6","name":"get_weather","input":{}}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"{"location":"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":" "San"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":" Francisc"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"o,"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":" CA""}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":", "}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""unit": "fah"}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"renheit"}"}}
event: content_block_stop
data: {"type":"content_block_stop","index":1}
https://docs.claude.com/en/docs/build-with-claude/streaming#streaming-request-with-tool-use
Repro steps:
Include sample requests, environment, etc. All data and inputs
required to reproduce the bug.
Note: If there are privacy concerns, sanitize the data prior to
sharing.
Environment:
Include the environment like gateway version, envoy version and so on.
Logs:
envoy returns 500 for the following reason:
ext_proc_error_gRPC_error_2{error_processing_request_message:_cannot_process_request_headers:_failed_to_transform_request:_failed_to_unmarshal_tool_call_arguments:invalid_character'{'_after_top-level_value{via_upstream}}