Skip to content

Implementation Plan: Codex Sous-Chef Recipe Context Loss via Auto-Compaction#3947

Merged
Trecek merged 3 commits into
developfrom
codex-sous-chef-recipe-context-loss-via-auto-compaction/3938
Jun 9, 2026
Merged

Implementation Plan: Codex Sous-Chef Recipe Context Loss via Auto-Compaction#3947
Trecek merged 3 commits into
developfrom
codex-sous-chef-recipe-context-loss-via-auto-compaction/3938

Conversation

@Trecek

@Trecek Trecek commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Prevent Codex sous-chef sessions from losing recipe content during long pipeline runs by:

  1. Disabling auto-compaction — Set model_auto_compact_token_limit = 999999999 in the Codex config.toml via ensure_codex_mcp_registered(), using the existing _ensure_top_level_key() pattern already used for tool_output_token_limit.

  2. Structural recipe-read guard — Add a new blocking PreToolUse guard hook (recipe_read_guard.py) that denies run_cmd/Bash calls containing recipe/skill/agent file path patterns and run_python calls importing autoskillit.recipe.*. This provides defense-in-depth that cannot be compacted away, unlike the prompt-based prohibitions in _backend_supplement().

Implementation Plan

Plan file: /home/talon/projects/autoskillit-runs/impl-20260608-151346-014727/.autoskillit/temp/make-plan/codex_sous_chef_recipe_context_loss_via_auto_compaction_plan_2026-06-08_153500.md

Closes #3938

🤖 Generated with Claude Code via AutoSkillit

Token Usage Summary

Step Model count uncached output cache_read peak_ctx turns cache_write time
run_bem* sonnet 1 62 31.8k 434.0k 97.6k 24 89.5k 9m 23s
dispatch:f69547b0-e15c-448a-a61c-366c3d67786d* sonnet 1 66 4.0k 269.4k 42.6k 17 43.5k 10m 32s
plan* opus[1m] 7 5.0k 63.9k 5.9M 94.3k 210 376.6k 44m 19s
verify* sonnet 6 5.3k 50.7k 2.6M 66.1k 151 216.9k 27m 9s
implement* MiniMax-M3 6 381.4k 29.1k 6.2M 74.7k 279 0 22m 19s
audit_impl* sonnet 6 4.9k 33.4k 1.2M 48.0k 97 143.6k 16m 50s
prepare_pr* MiniMax-M3 5 219.3k 11.8k 798.6k 47.9k 64 0 5m 36s
compose_pr* MiniMax-M3 5 181.4k 7.3k 858.4k 39.0k 64 0 4m 13s
review_pr* sonnet 10 1.3k 180.5k 7.9M 90.9k 427 440.6k 43m 52s
dispatch:2496288b-5215-4250-9d9d-a50396f464c3* sonnet 1 354 12.7k 3.2M 85.4k 125 85.6k 47m 48s
resolve_review* sonnet 3 655 34.5k 5.0M 98.2k 187 151.8k 16m 29s
dispatch:90358dda-aa18-4129-8dc1-d152f9f5f96c* sonnet 1 314 10.3k 2.8M 80.8k 82 110.7k 35m 1s
dispatch:14357aff-0458-4688-aeeb-7546f8b07de4* sonnet 1 346 12.7k 3.2M 85.0k 87 85.2k 32m 2s
fix* sonnet 1 232 22.3k 1.9M 86.5k 76 64.8k 10m 28s
dispatch:d8fd01d8-d94b-4d47-a6f0-120c4a965a79* sonnet 1 346 12.3k 3.4M 89.5k 123 65.1k 1h 3m
retry_worktree* sonnet 1 84 2.8k 356.0k 40.6k 25 23.0k 1m 45s
dispatch:71dae9f1-25d8-40bc-bdc2-31bcc568ef60* sonnet 1 178 6.1k 1.5M 76.7k 44 52.4k 22m 15s
dispatch:1bd28782-d46f-49ab-bf61-0b127e2bc596* sonnet 1 370 12.2k 3.5M 86.8k 97 62.4k 1h 14m
Total 801.5k 538.3k 51.0M 98.2k 2.0M 8h 7m

* Step used a non-Anthropic provider; caching behavior may differ.

Token Efficiency

Step LoC Changed cache_read/LoC cache_write/LoC output/LoC
run_bem 0
dispatch:f69547b0-e15c-448a-a61c-366c3d67786d 0
plan 0
verify 0
implement 353 17691.0 0.0 82.4
audit_impl 0
prepare_pr 0
compose_pr 0
review_pr 0
dispatch:2496288b-5215-4250-9d9d-a50396f464c3 7568 426.8 11.3 1.7
resolve_review 53 94520.3 2864.8 651.7
dispatch:90358dda-aa18-4129-8dc1-d152f9f5f96c 0
dispatch:14357aff-0458-4688-aeeb-7546f8b07de4 0
fix 14 134006.6 4625.6 1592.7
dispatch:d8fd01d8-d94b-4d47-a6f0-120c4a965a79 0
retry_worktree 0
dispatch:71dae9f1-25d8-40bc-bdc2-31bcc568ef60 0
dispatch:1bd28782-d46f-49ab-bf61-0b127e2bc596 1230 2842.6 50.8 9.9
Total 9218 5535.2 218.2 58.4

Model Usage Breakdown

Model steps uncached output cache_read cache_write time
sonnet 14 14.5k 426.2k 37.2M 1.6M 6h 51m
opus[1m] 1 5.0k 63.9k 5.9M 376.6k 44m 19s
MiniMax-M3 3 782.1k 48.1k 7.9M 0 32m 9s

Trecek and others added 3 commits June 8, 2026 16:26
Add CODEX_AUTO_COMPACT_LIMIT (999_999_999) so Codex cannot compact
recipe content out of the agent's context during long pipeline runs.
Wire it through _is_autoskillit_registered and ensure_codex_mcp_registered
(both normal and corrupt paths), plus the re-export chain and the test
fixtures that build "valid config" dicts.

Add a new PreToolUse guard `recipe_read_guard.py` that denies
run_cmd/Bash commands containing recipe/skill/agent path patterns and
run_python callables matching `autoskillit.recipe.*` in headless
sessions. This is defense-in-depth that cannot be compacted away, unlike
the prompt-based prohibitions in `_backend_supplement()`.

Register the guard in HOOK_REGISTRY with matcher
`Bash|mcp__.*autoskillit.*__(run_cmd|run_python)` and add it to
NEW_SUBDIR_BASENAMES. Run `task sync-hooks-hash` to refresh
registry.sha256.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…_guard

Mirrors the pattern established in fleet_dispatch_guard.py — emit
sys.stderr.write() on the fail-open path so silent OSError failures
are observable in session logs without changing the fail-open contract.
@Trecek Trecek force-pushed the codex-sous-chef-recipe-context-loss-via-auto-compaction/3938 branch from e55477a to 4211154 Compare June 8, 2026 23:26
@Trecek Trecek added this pull request to the merge queue Jun 9, 2026
Merged via the queue into develop with commit 87b7f6b Jun 9, 2026
3 checks passed
@Trecek Trecek deleted the codex-sous-chef-recipe-context-loss-via-auto-compaction/3938 branch June 9, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant