Desktop rehydrate injected stale AGENTS instructions from another workspace

Open 💬 1 comment Opened Feb 13, 2026 by deinspanjer

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

  1. Session starts with expected workspace:
  • ~/.codex/sessions/2026/02/12/rollout-2026-02-12T16-08-13-019c53ae-d992-7543-aeb1-cd8348e680aa.jsonl:1
  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
  1. Immediately after, turn_context.user_instructions flips to payload containing the playground line:
  • ~/.codex/sessions/2026/02/12/rollout-2026-02-12T16-08-13-019c53ae-d992-7543-aeb1-cd8348e680aa.jsonl:824
  1. cwd in turn context remains /Users/dre/src/ts/platform-operator-console.
  2. Same minute, extension log reports rehydrate anomaly:
  • ~/Library/Application Support/Code/logs/20260211T083628/window1/exthost/openai.chatgpt/Codex.log:2741
  • Failed 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_instructions are computed at spawn and stored:
  • current-installed-codex-version/codex-rs/core/src/codex.rs:283
  • current-installed-codex-version/codex-rs/core/src/codex.rs:358
  • Later settings updates can change cwd without recomputing user_instructions:
  • current-installed-codex-version/codex-rs/core/src/codex.rs:642
  • current-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

Suggested fixes

  1. Recompute user_instructions whenever cwd changes in resumed/rehydrated sessions.
  2. Add invariant check: AGENTS prompt header path must be within active workspace chain.
  3. On “Failed to apply patches” during resume, force full instruction rebuild from current cwd.
  4. Emit debug metadata for instruction-source files (resolved paths + hashes) in logs.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗