fix(copilot): handle empty tool_call arguments in baseline path (#12289)

## Summary

Handle empty/None `tool_call.arguments` in the baseline copilot path
that cause OpenRouter 400 errors when converting to Anthropic format.

## Changes

**`backend/copilot/baseline/service.py`**:
- Default empty `tc["arguments"]` to `"{}"` to prevent OpenRouter from
failing on empty tool arguments during format conversion.

## Test plan

- [x] Existing baseline tests pass
- [ ] Verify on staging: trigger a tool call in baseline mode and
confirm normal flow works
This commit is contained in:
Zamil Majdy
2026-03-05 16:53:05 +07:00
committed by GitHub
parent ce1675cfc7
commit 25022f2d1e

View File

@@ -287,7 +287,7 @@ async def stream_chat_completion_baseline(
yield StreamFinishStep()
step_open = False
# Append the assistant message with tool_calls to context
# Append the assistant message with tool_calls to context.
assistant_msg: dict[str, Any] = {"role": "assistant"}
if round_text:
assistant_msg["content"] = round_text
@@ -297,7 +297,7 @@ async def stream_chat_completion_baseline(
"type": "function",
"function": {
"name": tc["name"],
"arguments": tc["arguments"],
"arguments": tc["arguments"] or "{}",
},
}
for tc in tool_calls_by_index.values()