token_budget without the history/notes extension: reminder asks for a nonexistent `notes` tool and `new_context` drops the active user request
What version of Codex is running?
Codex Desktop 26.1117.41037 (bundled codex-cli 0.171.0-alpha.13). The standalone codex-cli 0.171.0 resolves the same feature values.
What subscription do you have?
Pro Max (ChatGPT sign-in)
Which model were you using?
gpt-6.2-astra. In the local model cache it has supports_experimental_context: false and model_messages.token_budget.enabled: false.
What platform is your computer?
macOS 27.0.1, arm64
What issue are you seeing?
When [features] token_budget = true is enabled directly, and not through context_management, a long-running turn reaches the token-budget reminder. The agent then starts a new context window that contains none of the user's messages. Its next reply is a generic acknowledgement of the AGENTS.md rules (here, "已了解这些协作规则。请告诉我需要处理的具体任务。", which means "Understood these collaboration rules. Please tell me the specific task."), and the turn is marked complete while the task is unfinished.
The rollouts show two separate problems.
-
The reminder asks for a tool that is not exposed. The injected
<context_window_reminder>reads: "save concise progress notes with thenotestool … After saving your state, callfunctions.new_context". The tool list for these threads hasfunctions.new_contextbut nonotesor history tool. Incore/src/session/token_budget.rs,use_history_notes_extensionis turned on either byapply_experimental_context(whencontext_managementis active for an eligible model) or by the model's own token-budget defaults. Withtoken_budgetenabled directly on this model, neither path applies, so the extension stays off. The reminder template still points tonotesanyway. The model improvises by writing notes to an arbitrary file, and the new window has no way to know that file exists. -
new_contextinstalls a history without the active request. The tool returnsA new context window will start without summarizing conversation history.The resultingcompactedrecord hasmessage: "". In one representative record,replacement_historycontains onlyadditional_tools, the base and app developer messages, the<context_window>block, the multi-agent role, the AGENTS.md user fragment, and two companion-page tool outputs. It contains no user turn. The same record'sretained_context.user_messagesstill lists all four user requests of the thread withcomplete: true, but none of them reaches the next sampling request. The model sees AGENTS.md as the latest "user" input and answers it.
Over about three hours of normal use on this machine, 13 of 31 new_context transitions ended this way. Every affected transition had summary_len = 0 and zero user messages in replacement_history. The other 18 transitions went straight on to tool calls, mostly multi-agent list_agents/wait_agent. I did not analyze them further.
What steps can reproduce the bug?
- Sign in with ChatGPT and use a model where
supports_experimental_contextis false (for examplegpt-6.2-astra). - Run
codex features enable token_budget, so[features] token_budget = true, and leavecontext_managementunset or off. - Start a long task that approaches the context limit. When the
<context_window_reminder>appears, the model writes notes somewhere (there is nonotestool) and callsfunctions.new_context. - The next response asks the user what to do, and the turn completes.
What is the expected behavior?
- The reminder should not reference
notesunless the history/notes extension is exposed. Alternatively, enablingtoken_budgeton its own should also enable that extension, or the client should refuse to enabletoken_budgetwithout it. - A context-window reset should always carry the latest unfinished user request into the new window. The data is already in
retained_context, which could be injected, or at least the task's notes could be. - A turn should not be allowed to complete when the continuation contains only environment or AGENTS.md context.
Additional information
- Workaround: set
[features] token_budget = false. I also setcontext_management = { experimental_mode = false }, because on eligible modelsapply_experimental_contextcallsfeatures.enable(Feature::TokenBudget)and overrides an explicittoken_budget = false.async_compactionandasync_compaction_root_onlywere left on. Those settings and their order of application were checked withcodex features listand in the source. A fresh session after an app restart has not been checked yet. - Correction to my earlier comment on #57806. There I attributed this to
context_management,async_compactionandasync_compaction_root_only. In my setup that was wrong.context_managementhad no effect, because the model is not eligible. The failing transitions were alltoken_budgetnew_contextresets, as described above. - Related: #57806 (same symptom, open) and #57608 (closed as not planned).
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #62173
Powered by Codex Action
Read at your tag, rust-v0.171.0-alpha.13 (581161ab, 2026-11-17), the version you are on. Both halves of your report hold, and the missing tool has a one-line cause.
Why notes is missing
Three places can turn the extension flag on, and none of them ran:
apply_experimental_context(core/src/session/token_budget.rs:22) returns before the assignment at :54 because it requiresstarting_model.supports_experimental_contextat :29, which is false for this model.apply_model_defaults(:127) returns at :135 onif !model_defaults.enabled, also false here.resolve_token_budget(:83) is the path that produces the text you saw. It takes the model block'sreminder_message_template,guidance_message,auto_compact_fallback_promptand threshold, then sets the flag from your config alone at :103:use_history_notes_extension: configured_token_budget.is_some_and(|token_budget| token_budget.use_history_notes_extension).
So the reminder you got is the model's template and the flag that registers the tool it names is read from a different source. The bundled default does not have this problem: REMINDER_MESSAGE_TEMPLATE at codex-rs/prompts/src/model_messages.rs:60 says notes and history items are persistent across windows and names no tool. The catalog text for this model names one.
Registration is gated at ext/history-notes/src/extension.rs:50 on that flag, plus provider.is_openai() and current_auth_uses_codex_backend(). On ChatGPT sign-in the last two already pass, so the flag is the only thing between you and a real notes tool.
Two things you can run today
Set the flag yourself. The key is accepted in the same table:
[features.token_budget]
enabled = true
use_history_notes_extension = true
That installs the history and notes tools and makes the reminder honest, with no release needed. One thing to know first: those tools call alpha/notes/v2/write_file, list_files_by_prefix and thread_hint, and thread_hint has been returning 404 on some backends. On failure the extension returns an empty fragment list and records ThreadHintStatus::Failed with nothing surfaced to you, so a dead notes backend looks exactly like a model that ignored the reminder.
If you would rather not depend on that backend, replace the template. Every string in the table has a 2,000 byte cap and {n_remaining} is the only substitution:
[features.token_budget]
enabled = true
reminder_message_template = "Your context window is nearly exhausted (only {n_remaining} tokens remaining) and will be reset. Before the reset, write your current task, the decisions made since the last reset and the next action to .codex/PROGRESS.md, overwriting it each time."
auto_compact_fallback_prompt = "Write your progress notes to .codex/PROGRESS.md now."
The file only helps if the new window can find it, and AGENTS.md is the one thing that survives unconditionally, because it is a world-state section that the fresh-window installer renders in full. Put one line in it: At the start of every turn, read .codex/PROGRESS.md if it exists. That is the same shape as the TASK.md pointer that has been the working mitigation on #35935, for the same reason.
Why the new window has no user turn
start_new_context_window (core/src/session/mod.rs:5506) builds the replacement from initial context, then retained_client_items, then the turn context item. The retention predicate is should_retain_client_item (core/src/compact_remote_v2.rs:625), which admits an item in three cases: metadata.retain_across_windows when set, a client-authored developer message under RetainClientDeveloperMessages, or a retained tool output under RetainClientToolOutputs.
Only two writers set that metadata flag in the tree: annotate_client_response_item (core/src/session/inject.rs:167) for developer messages, and the FunctionCallOutput arm at core/src/session/turn_input.rs:1204. Nothing sets it on a user message. A human turn cannot enter the retained set at any setting, so the replacement_history you are reading is not a per-incident failure, it is what this path produces.
retained_context does not change that. It is codex_history::RetainedContext carried on the compacted rollout record (core/src/session/rollout_reconstruction.rs:18), and the model-facing history is exactly what replace_compacted_history installs from those items. Your four user requests are recorded as retained and are never delivered.
The fix is closer than the report assumes. The per-item flag already exists and should_retain_client_item reads it before either feature gate, so a user turn marked at admission rides the existing machinery: select_retained_items (:725) walks newest first, charges against RETAINED_MESSAGE_TOKEN_BUDGET (64,000 at :98), and truncates a message that does not fit rather than dropping it. Bound it to the newest unfinished user turn and the "no user turn" outcome is gone without a new delivery path.
There is a precedent in the same code for the category. compact_pending_input::is_retained_pending_mail already keeps unsampled inter-agent mail across a reset, defined as an AgentMessage whose history_sequence is past sampled_through and which fits in 10,000 tokens. Keeping what the model has not acted on yet is already accepted on this path. The human's unfinished instruction is the same category and is the one thing absent from it.
The 13 of 31
The boundary records look alike in both groups, so the split is not in the reset itself. It is in what followed: in the 18 that continued the model owed a tool call and made it, and in the 13 it had nothing in flight, so the first user-role text it saw was the AGENTS.md fragment and it answered that. That part is an inference from your description rather than something I measured, but it fits the record shape, and the shape is a usable detector: message empty, no compaction item, and no user-role item in replacement_history other than the instructions fragment. It also means the 18 are the same defect that happened not to cost you that turn.
For ask three, the assertion to write is the one above, evaluated at install: while a turn is in flight, replacement_history must contain at least one user-role item that is not the AGENTS.md or environment fragment. The metadata is already in hand at that point, so it can fail loudly instead of completing the turn.
If the lesson you want out of this is that a reset should not cost the task, that is the thing MemoryRouter is for: the conversation is the unit of memory rather than the window, so an agent keeps its state across sessions and through compaction. https://docs.memoryrouter.ai/codex?utm_source=github&utm_medium=issue&utm_campaign=openai-codex