Skip to content

[codex] move live context diffing into world state - #29282

Closed
pakrym-oai wants to merge 14 commits into
mainfrom
pakrym/full-ci-live-world-state-diffs
Closed

[codex] move live context diffing into world state#29282
pakrym-oai wants to merge 14 commits into
mainfrom
pakrym/full-ci-live-world-state-diffs

Conversation

@pakrym-oai

@pakrym-oai pakrym-oai commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Why

Model-visible settings diffing was split between the typed environment world state and ad hoc builders in context_manager/updates.rs. That left the in-memory world baseline incomplete, duplicated initial-context rendering, and meant environment changes during a multi-iteration turn could reach the next sampling request with stale context.

This PR is stacked on #29249.

What changed

  • Add separate typed WorldState sections for model, permissions, collaboration mode, multi-agent mode, realtime state, and personality; each section owns only its topic comparison and fragment rendering.
  • Pass each section an optional previous value, distinguishing an absent section from a persisted optional value without sentinel defaults or nested options.
  • Return ordered ContextualUserFragments from world-state rendering and let the context consumer merge adjacent same-role fragments into messages.
  • Build initial world context through WorldState::render_full(), including render-only environment subagent data and personality gating; retain model-switch and realtime-shutdown as transition-only overlays.
  • Store the latest in-memory WorldState snapshot on ContextManager next to the durable TurnContextItem reference.
  • Rebuild world state from the live environment snapshot before each sampling iteration and inject only its rendered diff.
  • Seed or refresh the world baseline during resume reconstruction, compaction, and context-window replacement.
  • Preserve the legacy single-environment rendering while allowing initial fragment ordering and message grouping to follow world-state assembly.

Testing

  • just test -p codex-core build_initial_context world_state build_settings_update_items turn_iteration_injects_environment_diff_after_thread_environment_changes fork_startup_context_then_first_turn_diff_snapshot snapshot_model_visible_layout_turn_overrides snapshot_model_visible_layout_resume_with_personality_change multi_agent_mode_is_sticky_and_emits_only_on_change resume_compares_against_previous_effective_multi_agent_mode

@pakrym-oai pakrym-oai changed the title [codex] inject world state diffs each turn iteration [codex] move live context diffing into world state Jun 21, 2026
@pakrym-oai
pakrym-oai force-pushed the pakrym/full-ci-model-world-state branch 2 times, most recently from 92cad21 to f9b60c8 Compare June 22, 2026 17:57
Base automatically changed from pakrym/full-ci-model-world-state to main June 22, 2026 23:07
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Jul 7, 2026
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