Skip to content

Commit 56757e3

Browse files
committed
Strip caller field from Anthropic tool_use blocks
1 parent 3b27747 commit 56757e3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

stagehand/agent/anthropic_cua.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,13 @@ def _process_provider_response(
295295
if hasattr(response, "content") and isinstance(response.content, list):
296296
# Serialize Pydantic models from response.content for history
297297
try:
298-
raw_assistant_content_blocks = [
299-
block.model_dump() for block in response.content
300-
]
298+
for block in response.content:
299+
block_dict = block.model_dump()
300+
if isinstance(block_dict, dict):
301+
# Anthropic beta responses include a `caller` field on tool_use blocks
302+
# but the API rejects that key on subsequent requests.
303+
block_dict.pop("caller", None)
304+
raw_assistant_content_blocks.append(block_dict)
301305
except Exception as e:
302306
self.logger.error(
303307
f"Could not model_dump response.content blocks: {e}",

0 commit comments

Comments
 (0)