Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(openai-codex): skip step 5r on a request that declares no tools
Jack Rudenkob685c9c1a203
diff --git a/ai-docs/architecture/code-mode.md b/ai-docs/architecture/code-mode.mdindex ebab5735..6103f0f5 100644--- a/ai-docs/architecture/code-mode.md+++ b/ai-docs/architecture/code-mode.md@@ -170,8 +170,10 @@ parallel wrapper's `toolu_<id>_p<k>` never decode, so history grouping never depAfter 5b (the account is THIS request's) and after 3c (a synthetic reply gets the same Layer 4hooks), before 5c. Synchronous from record lookup to state transition, so two concurrent requests-for one record serialise. Guard: `openai-codex`, `oauth` arm, an account key, a session id,-`tool_choice` absent or `auto`. A request with a named tool, `any` or `none` never resumes a+for one record serialise. Guard: `openai-codex`, `oauth` arm, an account key, a session id, ≥ 1+declared tool (5d's `no-tools` gate: a tool-less compaction or summary request is never code mode,+so it must not consume a batch, end other scripts, or get tool_use blocks), `tool_choice` absent or+`auto`. A request with a named tool, `any` or `none` never resumes ascript: consuming a batch there would run the script's next tools outside the turn that owns it;the next ordinary request resumes it. It reads the stores only if a code-mode request alreadycreated them, with one exception: when none exist (the first request after a restart) but the lastdiff --git a/packages/cli/src/code-mode/resume.ts b/packages/cli/src/code-mode/resume.tsindex cd300466..335c6b55 100644--- a/packages/cli/src/code-mode/resume.ts+++ b/packages/cli/src/code-mode/resume.ts@@ -10,7 +10,8 @@** Guard (else nothing is touched and the request continues): `openai-codex`* (the caller's check), the binding's arm is `oauth`, an account key, a Claude- * Code session id, and `tool_choice` absent or `auto`. A named tool, `any` or+ * Code session id, ≥ 1 declared tool (5d's `no-tools` gate), and `tool_choice`+ * absent or `auto`. A named tool, `any` or* `none` never resumes a script: such requests are Claude Code's internal* one-shot calls, and consuming a batch there would run the script's next tools* outside the turn that owns it; the next ordinary request resumes it.@@ -583,6 +584,11 @@ export function resumeFromToolResults(const sessionKey = sessionKeyFor(extractSessionId(req), accountKey);if (!accountKey || !sessionKey) return { kind: "none" };if (!isAutoToolChoice(toolChoice)) return { kind: "none" };+ // 5d's `no-tools` gate: a tool-less request (compaction, an internal+ // summary) is never code mode, so it must not consume a batch, end the+ // session's other scripts, or be answered with tool_use blocks.+ const tools = Array.isArray(req.tools) ? (req.tools as ClaudeToolLike[]) : [];+ if (tools.length === 0) return { kind: "none" };const messages = Array.isArray(req.messages) ? (req.messages as ClaudeMessage[]) : [];let active = stores;if (@@ -604,7 +610,7 @@ export function resumeFromToolResults(sessionKey,toolUses: indexToolUses(messages),results: indexToolResults(messages),- tools: Array.isArray(req.tools) ? (req.tools as ClaudeToolLike[]) : [],+ tools,},active);