Skip to content

fix(parser): treat Codex /goal continuation context as system content#886

Merged
wesm merged 1 commit into
kenn-io:mainfrom
mjacobs:fix/codex-goal-continuation-context
Jun 26, 2026
Merged

fix(parser): treat Codex /goal continuation context as system content#886
wesm merged 1 commit into
kenn-io:mainfrom
mjacobs:fix/codex-goal-continuation-context

Conversation

@mjacobs

@mjacobs mjacobs commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Codex /goal sessions inject continuation context as role=user records 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, and user_message_count was inflated (which also feeds single-turn/automated session classification).

This routes both envelope formats through the existing isCodexSystemMessage gate so they are dropped from the transcript, user counts, search, and analytics — the same way <environment_context>, <skill>, and other Codex internal envelopes are:

  • Current: <codex_internal_context source="goal">…</codex_internal_context>
  • Legacy: <goal_context>…</goal_context>

Detection is scoped to the structured wrapper (and the goal source 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 (isCodexGoalContext plus the isCodexSystemMessage wiring).

Closes #868

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
@roborev-ci

roborev-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown

roborev: Combined Review (ad975f9)

No issues found.


Panel: ci_default_security | Synthesis: codex | Members: codex_default (codex/default, done, 1m13s), codex_security (codex/security, done, 36s) | Total: 1m49s

@wesm wesm merged commit 9bee8a3 into kenn-io:main Jun 26, 2026
12 checks passed
@mjacobs mjacobs deleted the fix/codex-goal-continuation-context branch June 26, 2026 17:37
wesm pushed a commit that referenced this pull request Jun 28, 2026
Refinement on top of #886 / 9bee8a3, which already taught the Codex parser to classify `/goal` continuation envelopes as system content for newly parsed sessions.

This PR handles the archive and compatibility side of that fix. It bumps the parser data version to 56 on top of main's version-55 Kimi usage-event bump, so existing source-backed Codex sessions are non-destructively re-parsed and old stored `/goal` rows are removed from message lists and user-turn counts instead of remaining in persistent SQLite archives.

It also adds read-path fallbacks for legacy rows that may still exist before reparse, or in rows that cannot be re-emitted from source files. Backend system-prefix filtering now uses a dedicated Codex goal-context predicate plus SQLite/PostgreSQL/DuckDB SQL variants, while frontend system-message detection and HTML/focused export use the same wrapper semantics. Both the current `<codex_internal_context ... source="goal">` form, including extra attributes, and the older `<goal_context>` wrapper stay out of search, transcript filtering, and exported sessions.

The main tradeoff is the data-version bump: multi-host PostgreSQL deployments should upgrade `pg serve` and all pushers together, because older agentsview binaries reject rows written by a newer parser data version.

Co-authored-by: Trent Nelson <tpn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Codex /goal continuation context renders as user messages in transcripts

2 participants