fix(parser): treat Codex /goal continuation context as system content#886
Open
mjacobs wants to merge 1 commit into
Open
fix(parser): treat Codex /goal continuation context as system content#886mjacobs wants to merge 1 commit into
mjacobs wants to merge 1 commit into
Conversation
Codex /goal sessions inject continuation context as role=user records wrapped in <codex_internal_context source="goal"> (current) or <goal_context> (legacy). These were parsed as ordinary user turns, flooding long goal-oriented sessions with synthetic messages between real exchanges and inflating user_message_count. Route both wrappers through isCodexSystemMessage so they are dropped from the transcript, user counts, search, and analytics like other Codex internal envelopes. Detection is scoped to the structured wrapper (and the goal source for the modern form) so a real user message that quotes the goal text is preserved. Closes kenn-io#868
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.
Codex
/goalsessions inject continuation context asrole=userrecords so the model keeps working toward the active thread goal. agentsview parsed these as ordinary user turns, so long goal-oriented Codex sessions filled with synthetic "Continue working toward the active thread goal…" messages between real exchanges, anduser_message_countwas inflated (which also feeds single-turn/automated session classification).This routes both envelope formats through the existing
isCodexSystemMessagegate so they are dropped from the transcript, user counts, search, and analytics — the same way<environment_context>,<skill>, and other Codex internal envelopes are:<codex_internal_context source="goal">…</codex_internal_context><goal_context>…</goal_context>Detection is scoped to the structured wrapper (and the
goalsource for the modern form), so a real user message that merely quotes the goal sentence is preserved. The change is parser-level and pre-storage, so it applies identically to the full and incremental parse paths and both storage backends.Where to look:
internal/parser/codex.go(isCodexGoalContextplus theisCodexSystemMessagewiring).Closes #868