refactor: share execution prep for tool-call phase

Keep the current tool-call bridge contract stable while extracting shared
execution setup and tightening Anthropic forwarding regressions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
GitHub Actions
2026-04-22 07:37:00 +08:00
parent 4748432501
commit 5a7553b35b
5 changed files with 319 additions and 209 deletions

View File

@@ -52,10 +52,9 @@ class AnthropicMessagesRequest(BaseModel):
stop_sequences: list[str] | None = None
# metadata.user_id is the official hint for per-user routing / abuse tracking.
metadata: dict[str, Any] | None = None
# Tools / tool_choice are accepted but we can't forward them to Lingma yet —
# they're preserved here so the request doesn't 422, and the flattener
# surfaces any tool_use blocks as `[tool_use] {...}` text so the assistant
# still sees the context.
# Tools / tool_choice are accepted for compatibility and, when forwarding is
# enabled, are passed upstream as tool_config; tool_use / tool_result blocks
# are still flattened into text so the assistant can see prior tool context.
tools: list[dict[str, Any]] | None = None
tool_choice: dict[str, Any] | None = None