Desktop rehydrate injected stale AGENTS instructions from another workspace
Summary
On February 13, 2026 at 10:56:21 local time (2026-02-13T15:56:21Z), conversation 019c53ae-d992-7543-aeb1-cd8348e680aa switched to a different user_instructions payload that included:
At the end of your turn, report you are testing with the ~/codex-sandboxes/playground/.codex/AGENTS.md file in place.
This happened even though the thread cwd and sandbox root remained /Users/dre/src/ts/platform-operator-console.
Impact
Instruction boundary was violated at prompt-construction level: model followed unrelated AGENTS guidance from another workspace context.
Environment
- Codex Desktop / VS Code extension (
openai.chatgpt-0.5.74-darwin-arm64) - CLI version in session meta:
0.100.0-alpha.10 - Host: macOS
- Conversation:
019c53ae-d992-7543-aeb1-cd8348e680aa
Observed Behavior
- Session starts with expected workspace:
~/.codex/sessions/2026/02/12/rollout-2026-02-12T16-08-13-019c53ae-d992-7543-aeb1-cd8348e680aa.jsonl:1
- At
2026-02-13T15:56:21.063Z, a fresh preamble is injected, including AGENTS block containing playground path:
~/.codex/sessions/2026/02/12/rollout-2026-02-12T16-08-13-019c53ae-d992-7543-aeb1-cd8348e680aa.jsonl:816
- Immediately after,
turn_context.user_instructionsflips to payload containing the playground line:
~/.codex/sessions/2026/02/12/rollout-2026-02-12T16-08-13-019c53ae-d992-7543-aeb1-cd8348e680aa.jsonl:824
cwdin turn context remains/Users/dre/src/ts/platform-operator-console.- Same minute, extension log reports rehydrate anomaly:
~/Library/Application Support/Code/logs/20260211T083628/window1/exthost/openai.chatgpt/Codex.log:2741Failed to apply patches ... conversationId=019c53ae-d992-7543-aeb1-cd8348e680aa
Expected Behavior
When restoring/resuming a thread, AGENTS/project instructions should be recomputed from the active workspace (cwd) and trusted config only; stale instructions from other workspaces must not be injected.
Why this looks like a rehydrate bug (inference)
user_instructionsare computed at spawn and stored:current-installed-codex-version/codex-rs/core/src/codex.rs:283current-installed-codex-version/codex-rs/core/src/codex.rs:358- Later settings updates can change
cwdwithout recomputinguser_instructions: current-installed-codex-version/codex-rs/core/src/codex.rs:642current-installed-codex-version/codex-rs/core/src/codex.rs:662- Turn context reuses stored
user_instructions: current-installed-codex-version/codex-rs/core/src/codex.rs:797
Relevant docs
- https://developers.openai.com/codex/guides/agents-md/#how-codex-discovers-guidance
- https://developers.openai.com/codex/config-advanced/#project-instructions-discovery
Suggested fixes
- Recompute
user_instructionswhenevercwdchanges in resumed/rehydrated sessions. - Add invariant check: AGENTS prompt header path must be within active workspace chain.
- On “Failed to apply patches” during resume, force full instruction rebuild from current
cwd. - Emit debug metadata for instruction-source files (resolved paths + hashes) in logs.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗