fix(codex): suppress inherited forked subagent usage - #521
Merged
junhoyeo merged 1 commit intoMay 10, 2026
Conversation
Codex forked child JSONL files can preserve parent records before the child turn_context. Detect forked child metadata, suppress inherited JSON records until the first child turn_context, retain the inherited token baseline for the repeated post-turn_context snapshot, and keep child metadata intact for provider, agent, and workspace attribution. Bump the source-message cache schema because Codex incremental state now stores the forked-child suppression baseline. Validation: - cargo test -p tokscale-core sessions::codex::tests::test_forked_child: PASS, 2 passed - cargo test -p tokscale-core codex: PASS, 61 passed - cargo test -p tokscale-core: PASS, 661 passed, 1 ignored; codebuff 10 passed; hermes 3 passed; doc-tests 0 passed - cargo test --workspace --all-features: PASS - cargo clippy -p tokscale-core --all-features -- -D warnings: PASS - cargo fmt --all --check: PASS - git diff --check: PASS - git diff --cached --check: PASS - ASCII-only scan over touched Rust files: PASS, no matches Rollback: - Revert this commit to restore the previous Codex forked-session parsing behavior and source message cache schema.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
junhoyeo
approved these changes
May 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
turn_context.turn_contextsnapshot is not counted as child-local usage.Why
Codex native subagent logs can include copied parent session history before the child session records its own
turn_context. Those inheritedtoken_countrows are parent work, not child-local work. Counting them inside every forked child can multiply the parent usage and produce large artificial spikes.Fixes #520.
Test plan
cargo test -p tokscale-core sessions::codex::tests::test_forked_child(2 passed)cargo test -p tokscale-core codex(61 passed)cargo test -p tokscale-core(661 passed, 1 ignored)cargo test --workspace --all-features(passed)cargo clippy -p tokscale-core --all-features -- -D warnings(passed)cargo fmt --all --check(passed)git diff --check(passed)Summary by cubic
Suppress inherited parent records in Codex forked child logs until the child’s first
turn_contextso token usage reflects only child-local work. This prevents double-counting by tracking the inherited baseline and keeps provider/agent/workspace metadata intact (fixes #520).Bug Fixes
token_countrows before the child’s firstturn_context.turn_contextsnapshot to the inherited baseline to avoid recounting.total_tokensin usage payloads and preserve child provider/agent/workspace attribution.Migration
Written for commit e0f728e. Summary will update on new commits.