-
fix(agent): guard against unexpected Anthropic response shape in invoke (#2419)
发布于
2026-05-23 20:44:25 +00:00 - fix(agent): guard against unexpected Anthropic response shape in invoke
Use getattr for response.content and response.stop_reason in
AnthropicAgentClient.invoke() to prevent AttributeError when the
Anthropic SDK returns an object without a .content attribute (e.g.
an unexpected response shape). Matches the defensive pattern already
used in llm_client.py.https://claude.ai/code/session_016C1yo4oJ1CS2f8tymsaJQ9
- fix(agent): log warning when Anthropic response has unexpected shape
When getattr fallback fires (response lacks .content list), emit a
logger.warning so the bad response shape is observable in logs and not
silently swallowed. Addresses Greptile review feedback.https://claude.ai/code/session_016C1yo4oJ1CS2f8tymsaJQ9
- fix(agent): raise RuntimeError on unexpected Anthropic response shape
Replace silent empty-response fallback with an explicit RuntimeError,
consistent with OpenAIAgentClient. Add a test to cover this path.https://claude.ai/code/session_016C1yo4oJ1CS2f8tymsaJQ9
Co-authored-by: Claude noreply@anthropic.com
下载附件