core: make AGENTS.md react to environment changes#29810
Conversation
| pub(crate) struct AgentsMdState { | ||
| instructions: Option<UserInstructions>, | ||
| // TODO(sayan): remove this fallback once rollouts persist and restore AGENTS.md state. | ||
| historical_state_unknown: bool, |
There was a problem hiding this comment.
an artifact of not having worldstate persistence yet. working on that as well
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1dd2af58d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // TODO(sayan): rollouts don't persist AGENTS.md state yet, so conservatively supersede history on resume. | ||
| world_state.add_section(AgentsMdState::unknown()); |
There was a problem hiding this comment.
see other comment, this will be cleaned up when we persist worldstate correctly
| send_environment_info(&mut websocket).await; | ||
| } | ||
|
|
||
| async fn serve_environment_with_agents_md( |
There was a problem hiding this comment.
hm, at some point we'll have to start using a real server, you can't keep reimplementing it's features in mocks.
| // TODO(sayan): Implement WorldState persistence (including AGENTS.md) across | ||
| // resume, fork, rollback, and compaction. Then delete this direct rendering, | ||
| // remove the gate in build_world_state_for_step(), and let WorldState render | ||
| // AGENTS.md for all sessions. Keep calling AgentsMdManager::refresh() only for | ||
| // deferred executors so flag-off sessions keep their creation-time instructions. | ||
| if !turn_context |
There was a problem hiding this comment.
kept this split for now to avoid changing the behavior with the flag off until worldstate persistence lands. the long-term intention is to not have special injections and let agents.md always be rendered via worldstate.
|
@codex review this |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
pakrym-oai
left a comment
There was a problem hiding this comment.
The only concern is whether we re-inject agents.md on resume.
Worth an integration test if we missed it?
83e33b2 to
fdff14a
Compare
Why
With deferred executors, a turn can begin before a remote environment attaches. AGENTS.md discovery previously ran only during session setup, so instructions from a later environment never reached the model or the session instruction sources.
WorldState persistence has now landed, so this uses the durable model-visible baseline directly instead of carrying a temporary resume/fork compatibility path.
What
AgentsMdManagerinSessionServicesto own host instructions, loaded state, and refresh caching.DeferredExecutoris enabled, refresh AGENTS.md when attached environment selections change and freeze the result in the correspondingStepContext.SessionConfigurationandTurnContext.Builds on #29833, #29835, and #29837.
Tests
codex-coreAGENTS.md, WorldState, and context-update test suites.