Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(code): cloud coding agent follow-up turns no longer 422 (persist tool_call_id)

purple3c0b65b16727
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index dc215c30..247c677d 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -448,6 +448,12 @@ export function useCodex() {
// model sees the full tool-call chain from previous turns
// (continue capability, parity with original Codex CLI).
if (m.tool_calls) msg.tool_calls = m.tool_calls as any
+ // Carry the tool-result linkage across turns too. ed99f82 sets
+ // tool_call_id on role:'tool' messages INSIDE the loop, but the
+ // persist+rebuild round-trip below dropped it — so the SECOND user
+ // turn replayed tool results with no tool_call_id and DeepInfra
+ // (lu-cloud) 422'd "tool_call_id: Field required", wedging the chat.
+ if (m.tool_call_id) msg.tool_call_id = m.tool_call_id
return msg
}),
]
@@ -1458,6 +1464,10 @@ export function useCodex() {
timestamp: Date.now(),
hidden: true,
tool_calls: tm.tool_calls as any,
+ // Persist the tool-result linkage so the next turn's history
+ // builder can replay it — without this, follow-up turns 422 on
+ // lu-cloud (see types/chat.ts Message.tool_call_id, Bug 4).
+ tool_call_id: tm.tool_call_id,
})
}
}
diff --git a/src/types/chat.ts b/src/types/chat.ts
index 5d9fef80..27c34ee6 100644
--- a/src/types/chat.ts
+++ b/src/types/chat.ts
@@ -52,7 +52,12 @@ export interface Message {
// the model sees what it did before (parity with original Codex CLI).
// Hidden messages are included in the API payload but not rendered.
hidden?: boolean
- tool_calls?: { function: { name: string; arguments: Record<string, unknown> } }[]
+ tool_calls?: { id?: string; function: { name: string; arguments: Record<string, unknown> } }[]
+ /** OpenAI tool-result linkage on role:'tool' messages. Persisted so id-based
+ * providers (lu-cloud/DeepInfra, OpenAI) can match a tool result to its call
+ * ACROSS turns. Without it, once a tool call is in the history DeepInfra 422s
+ * "tool_call_id: Field required" on every follow-up turn (Bug 4, 2026-07-11). */
+ tool_call_id?: string
// Real token usage reported by the model (Ollama prompt_eval_count/eval_count,
// OpenAI/LM-Studio usage.*). promptTokens = the FULL consumed context for that
// turn (system prompt + tools + RAG + history + input), so it powers a