You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
400 provider error on session resume with open tool calls #701
When resuming a Kimi Code session where the last turn has open (unresponded) tool calls, the LLM provider fails with a 400 [provider.api_error] stating:
an assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'.
This happens because the new user prompt/steer is appended to the history after the open tool calls, preventing trimTrailingOpenToolExchange from cleaning them since they are no longer "trailing" at the very end of the history. Additionally, the new user prompt gets deferred if pendingToolResultIds is not cleared from the aborted turn.
Solution
We resolved this by:
Clearing pendingToolResultIds at the start and end of turn boundaries (TurnFlow.runOneTurn).
Clearing pendingToolResultIds after replaying session records during resume (Agent.resume).
Reverting the step.end cleanup to correctly preserve system reminder deferral during active tool execution.
Activity