Skip to content

Bug: InternalError.400 in 0.56 #702

@aresstokrat

Description

@aresstokrat

Describe the bug

Image

first time i got this one and i don't know how to pass it bye
The API rejects requests because Aider sends a message with role tool without a preceding assistant message containing tool_calls. This breaks the required message pair sequence that DashScope strictly enforces.

The issue seems to occur when a tool call gets interrupted mid-session — the orphaned tool_calls entry stays in the message history, and on the next request the API sees an unpaired tool message and rejects it.

Temporary fix: /clear resets the history and unblocks the session. Using edit_format: diff prevents it from happening at all.

It would be helpful if Aider sanitized the outgoing message history before each API request — removing or repairing any unpaired tool / tool_calls messages so the sequence is always valid regardless of what happened during the session.

Steps to reproduce

{
"role": "assistant",
"content": [
{
"type": "reasoning",
"text": "The builder subagent has provided a comprehensive implementation plan. I need to review it and approve it before proceeding. The plan looks good and covers all the requirements from the user's request.\n\nLet me approve the plan and let the builder proceed with implementation."
},
{
"type": "text",
"text": "Plan approved. Proceed with implementation.\n\n"
},
{
"type": "tool-call",
"toolCallId": "call_8c4db2f1c2464ced90922fe2",
"toolName": "todo---update_item_completion",
"input": {
"name": "Read and analyze current modules (main.py, executor.py, route_optimizer.py, providers, config.py, approval.py)",
"completed": true
}
}
],
"id": "6e584110-f1b1-4c3e-ab48-613656143bd5",
"usageReport": {
"model": "openai-compatible-2/qwen3.5-plus",
"sentTokens": 0,
"receivedTokens": 0,
"cacheReadTokens": 0,
"messageCost": 0,
"agentTotalCost": 0
},
"promptContext": {
"id": "00b35ae3-9e6c-47ab-823d-fb6217f1659d"
}
},
{
"role": "tool",
"content": [
{
"type": "tool-result",
"toolCallId": "call_8c4db2f1c2464ced90922fe2",
"toolName": "todo---update_item_completion",
"output": {
"type": "json",
"value": [
{
"name": "Read and analyze current modules (main.py, executor.py, route_optimizer.py, providers, config.py, approval.py)",
"completed": true
},
{
"name": "Define canonical amount fields and models (RouteQuote, ExecutionRequest, ExecutionAttempt)",
"completed": false
},
{
"name": "Update BridgeRoute and RouteInfo with canonical amount semantics",
"completed": false
},
{
"name": "Update provider adapters to map to canonical RouteQuote",
"completed": false
},
{
"name": "Add mandatory preflight validation checks (chain_id, balance, gas, allowance, quote TTL, etc.)",
"completed": false
},
{
"name": "Integrate ERC20 approval flow into executor (detect, build, send, wait)",
"completed": false
},
{
"name": "Update JSON reporting to expose approval steps",
"completed": false
},
{
"name": "Add/enable tests for provider contracts, native path, ERC20 approval, preflight aborts",
"completed": false
},
{
"name": "Verify changes and commit Stage 2 separately",
"completed": false
}
]
}
}
],
"id": "65ac839a-335e-4fa0-9704-1d81b5a120a8",
"usageReport": {
"model": "openai-compatible-2/qwen3.5-plus",
"sentTokens": 0,
"receivedTokens": 0,
"cacheReadTokens": 0,
"messageCost": 0,
"agentTotalCost": 0
},
"promptContext": {
"id": "00b35ae3-9e6c-47ab-823d-fb6217f1659d"
}
},
{
"role": "assistant",
"content": [
{
"type": "reasoning",
"text": "Good, the todo list is updated. Now I'll wait for the builder subagent to continue with the implementation. The builder has the full context and plan, so it should proceed with implementing the changes.\n"
},
{
"type": "text",
"text": "The builder subagent will now implement Stage 2. I'll track progress via the todo list."
}
],
"id": "182bc1f3-38ff-454b-85bf-76f6385bc603",
"usageReport": {
"model": "openai-compatible-2/qwen3.5-plus",
"sentTokens": 0,
"receivedTokens": 0,
"cacheReadTokens": 0,
"messageCost": 0,
"agentTotalCost": 0
},
"promptContext": {
"id": "00b35ae3-9e6c-47ab-823d-fb6217f1659d"
}
},
{
"id": "0c29d865-2842-4251-bb61-376b5290befe",
"role": "user",
"content": "continue",
"promptContext": {
"id": "0c29d865-2842-4251-bb61-376b5290befe"
}
},
{
"id": "603550d0-543c-4ed0-ba09-b194b6510895",
"role": "user",
"content": "continue",
"promptContext": {
"id": "603550d0-543c-4ed0-ba09-b194b6510895"
}
},
{
"id": "52db03be-451b-4319-b6d6-356dcc99152b",
"role": "user",
"content": "continue",
"promptContext": {
"id": "52db03be-451b-4319-b6d6-356dcc99152b"
}
},
{
"id": "ea64479f-900f-45fa-99ee-92b32a50cd44",
"role": "user",
"content": "continue",
"promptContext": {
"id": "ea64479f-900f-45fa-99ee-92b32a50cd44"
}
},
{
"id": "da213da2-9092-437e-b626-46cf432d603a",
"role": "user",
"content": "continue",
"promptContext": {
"id": "da213da2-9092-437e-b626-46cf432d603a"
}
},
{
"id": "2cd00609-10ff-448f-91a7-509144a14e5a",
"role": "user",
"content": "continue",
"promptContext": {
"id": "2cd00609-10ff-448f-91a7-509144a14e5a"
}
}
],
"contextFiles": [
{
"path": ".aider-desk\rules\platform.md",
"readOnly": true
}
]
}

Expected behavior

No response

Operating System

Windows11

Version

v0.56.0

Screenshots

No response

Additional context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions