#15522: fix(codex-cli): compatible resume args + JSONL chunk streaming bridge
agents
stale
size: M
Cluster:
Session Management and Fixes
## Summary
This patch addresses two recurring Codex CLI backend pain points:
1. `codex exec resume` argument incompatibility in default backend config
2. no assistant output until full CLI process completion for JSONL backends
## What changed
### 1) Codex default backend hardening
Updated `DEFAULT_CODEX_BACKEND` in `src/agents/cli-backends.ts`:
- adds `-c features.shell_snapshot=false` to both `args` and `resumeArgs`
- replaces incompatible resume flags (`--color`, `--sandbox`) with:
- `--json`
- `--skip-git-repo-check`
- `--dangerously-bypass-approvals-and-sandbox`
- sets `resumeOutput` to `jsonl`
### 2) Streaming bridge for CLI JSONL output
- `runCommandWithTimeout` now accepts optional chunk callbacks:
- `onStdoutChunk`
- `onStderrChunk`
- `runCliAgent` uses `onStdoutChunk` for JSONL mode to parse lines as they arrive
- parsed assistant-message text is emitted incrementally via new optional `onStreamText` callback
- `agent-runner-execution` wires `onStreamText` into `emitAgentEvent(stream="assistant")`
- final payload emission remains as fallback; remainder logic avoids obvious duplication when stream chunks were already sent
### 3) Tests
Added/updated tests:
- `src/agents/cli-backends.test.ts`
- validates codex default args/resumeArgs/resumeOutput
- `src/process/exec.test.ts`
- validates stdout/stderr chunk callbacks
- `src/agents/cli-runner.e2e.test.ts`
- validates JSONL chunk streaming behavior via `onStreamText`
## Why
In real runs, Codex resume calls were failing with unsupported flags, and users saw long silent windows because JSONL text wasn't surfaced until process exit. This patch keeps defaults compatible with current Codex CLI behavior and improves perceived responsiveness by forwarding assistant text chunks earlier.
## Validation
Executed locally:
- `vitest run src/process/exec.test.ts src/agents/cli-backends.test.ts`
- `vitest run --config vitest.e2e.config.ts src/agents/cli-runner.e2e.test.ts`
All passed.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the default `codex-cli` backend configuration to use resume arguments that match current `codex exec resume` expectations, and switches resume output parsing to JSONL. It also adds an opt-in streaming bridge: `runCommandWithTimeout` can now emit stdout/stderr chunks via callbacks, `runCliAgent` can parse JSONL lines incrementally and forward assistant text deltas via `onStreamText`, and the auto-reply runner wires these chunks into agent events so downstream UIs can display partial assistant output before process completion.
Tests were added/updated to cover the new default codex args, the exec chunk callbacks, and the JSONL streaming behavior in the CLI runner.
<h3>Confidence Score: 5/5</h3>
- This PR appears safe to merge with minimal risk.
- Changes are localized, additive (new optional callbacks), and covered by targeted tests for codex default args, exec chunk callbacks, and JSONL streaming behavior. No definite logic errors or breaking API changes were identified in the reviewed diff.
- No files require special attention
<sub>Last reviewed commit: 88f3ddb</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23720: Feat/cli backend runtime tuning
by wanmorebot · 2026-02-22
78.7%
#6730: feat: Make OpenAI Codex CLI models usable - reasoning effort directive
by levineam · 2026-02-02
74.8%
#17531: fix(auth): sync Codex CLI credentials into auth profile store and c...
by sauerdaniel · 2026-02-15
73.7%
#10367: CLI/Ops: resilient browser fill + failover hardening + operations t...
by cluster2600 · 2026-02-06
72.8%
#11159: fix(cli): parse --profile flag after subcommand name
by hclsys · 2026-02-07
72.7%
#17770: refactor(cli): reuse shared option builders
by iyoda · 2026-02-16
72.2%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
72.2%
#11816: fix(cron): forward agent-specific exec config to isolated cron sess...
by AnonO6 · 2026-02-08
72.1%
#23672: fix(resilience): guard JSON.parse of external process output with t...
by kevinWangSheng · 2026-02-22
72.0%
#15050: fix: transcript corruption resilience — strip aborted tool_use bloc...
by yashchitneni · 2026-02-12
71.7%