Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/desktop
Steps to reproduce
- Use T3 Code with a Codex instance on Codex app-server 0.171.0. It happens with
model_provider = "openai"and with a custom Responses provider alike. - Start a Codex thread with the T3 MCP attached and send any short prompt, e.g. "Say only OK."
- After the turn finishes, run
/compact. - Send another prompt.
- Open the thread's rollout (
~/.codex/sessions/.../rollout-*.jsonl) and look at the developer messages that start with<t3_code_.
Expected behavior
After compaction the five T3 additionalContext entries (t3_code_orchestration_01–03, t3_code_runtime, t3_code_tools) are in the model's context exactly once.
restoreAdditionalContext should only re-inject entries that compaction actually removed. If they are still in the replacement history, nothing needs to be injected.
Actual behavior
Codex 0.171.0 keeps the entries in replacement_history, and T3 then injects all of them again. The next request has every T3 block twice.
From a fresh thread on Codex 0.171.0 (custom provider). A thread on the default openai provider shows the same sequence at lines 13–17, 27, 33 and 34–38:
| Rollout line | What happens |
|---|---|
| 13–17 | First turn: Codex writes the five entries as developer messages, content_item_kinds: additional_content.t3_code_*, provenance harness |
| 29 | compacted: replacement_history still contains all five entries with their additional_content.t3_code_* kinds |
| 35 | task_complete of the compaction turn |
| 36–40 | The same five blocks appended again via thread/inject_items. They have content_item_kinds: ["unknown"] and no provenance, so they are T3's restore, not Codex's own rendering |
Across my rollouts the change lines up with the Codex upgrade:
| Installed Codex | Compactions in T3 threads | T3 entries kept in replacement_history |
Result after T3's restore |
|---|---|---|---|
| 0.166–0.169 (until 2026-11-19) | 11 | none in any of them | 1 copy (restore needed, works as intended) |
| 0.171.0 (from 2026-11-22) | 9 | kept in 8; the 9th had no T3 entries at all | 2 copies |
Cause on our side. CodexAdapterV2.ts on main (checked 2026-11-26) still assumes the old Codex behavior:
// Codex drops client developer messages during compaction but only resends additionalContext
// when it changes. Restore after turn/completed: items injected mid-turn make the turn sample again.
const restoreAdditionalContext = Effect.fn("CodexAdapterV2.restoreAdditionalContext")(...)A contextCompaction item marks the thread in threadsAwaitingContextRestore. On turn/completed the adapter injects every stored entry without checking whether it is still in history.
That assumption matches openai/codex#38269 ("Automatic compaction drops unchanged additionalContext"). That issue is still open, but Codex 0.171.0 evidently rebuilds the replacement history with the retained additionalContext.
Cost. The five blocks are ~6.3k characters (~1.6k tokens). That is the extra input on every request until the next compaction. I also saw up to four copies in a long thread; part of that is probably the resume duplication from #25191.
Suggested fix. Before restoring, check which <key> blocks are missing from the post-compaction history and inject only those. Alternatively, skip the restore for Codex versions that keep additionalContext across compaction. The existing test "preserves T3 context on the wire and restores it after compaction" could get a second case where the replacement history already contains the entries.
Related. These are not duplicates:
- [Bug]: Native Codex resume appends duplicate T3 application instructions to model input #25191 – duplicate T3 instructions after a native Codex resume. Same symptom, different trigger.
- PR fix(server): Codex turns that auto-compact end instead of looping on restored context #25911 – moved the restore to
turn/completedto stop compaction loops. Tested against codex-cli 0.163.0. - [Bug]: ACP instruction block (incl. collaborative browser) is lost after context compaction and never re-injected #21036 / PR fix(server): re-inject T3 instructions into ACP sessions after compaction #21053 – the same restore added for ACP adapters.
Impact
Minor bug or occasional failure
Version or commit
T3 Code desktop 0.1.12. Codex app-server 0.171.0. The adapter code is unchanged on main as of 2026-11-26.
Environment
macOS 27.2 (Darwin), T3 Code desktop 0.1.12, Codex app-server 0.171.0, gpt-6.2-sol; reproduced with model_provider "openai" and with a custom Responses provider
Logs or stack traces
Screenshots, recordings, or supporting files
No response
Workaround
No response
Activity