mirror of
https://github.com/openai/codex.git
synced 2026-11-14 14:49:31 +00:00
Refresh global instructions at model-request boundaries (#44675)
## Why Running root threads retained their startup global instructions, so edits to global `AGENTS.md` files did not take effect during an active session. ## What changed - Reload global instructions when capturing model-request context, including after tools within the same turn. Apply changes without repeating unchanged instructions or rediscovering repository instructions when the environment and trust level are unchanged. - Preserve the last successful global instructions on read failures, suppress recurring warnings until recovery, and clear instructions when their source is removed or blank. - Serialize refreshes and allow cancellation without blocking subsequent requests. - Give new subagents the parent's applied instruction snapshot and update Guardian reviewer reuse to account for refreshed instructions. ## Testing Add regression coverage for live edits and removal, read failures and recovery, warning suppression, cancellation, subagent inheritance, and Guardian reviewer reuse. Update resume, fork, and compaction tests to verify refreshed instructions. GitOrigin-RevId: f7e9b399740fa4f45e482c070f6e901ee7cf85cd
This commit is contained in:
1 parent
28f43b0417
commit
935ac7710d
23 files changed
+1143
-249
No files matched your search
@@ -3,7 +3,6 @@ use std::sync::Arc;
|
||||
use async_channel::Receiver;
|
||||
use async_channel::Sender;
|
||||
use codex_async_utils::OrCancelExt;
|
||||
use codex_extension_api::LoadedUserInstructions;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
use codex_protocol::protocol::Event;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
@@ -74,10 +73,7 @@ pub(crate) async fn run_codex_thread_interactive(
|
||||
|
||||
let conversation_history = initial_history.unwrap_or(InitialHistory::New);
|
||||
let forked_from_thread_id = conversation_history.forked_from_id();
|
||||
let user_instructions = LoadedUserInstructions {
|
||||
instructions: parent_session.user_instructions().await,
|
||||
warnings: Vec::new(),
|
||||
};
|
||||
let instructions = parent_session.inherited_instructions().await;
|
||||
let session_source = SessionSource::SubAgent(subagent_source.clone());
|
||||
let is_guardian_reviewer = crate::guardian::is_basic_session_source(&session_source);
|
||||
let extensions = if isolation == codex_extension_api::SessionIsolation::Isolated {
|
||||
@@ -93,7 +89,7 @@ pub(crate) async fn run_codex_thread_interactive(
|
||||
let (session, io) = Session::spawn(SessionSpawnArgs {
|
||||
config,
|
||||
allow_provider_model_fallback: false,
|
||||
user_instructions,
|
||||
instructions,
|
||||
installation_id: parent_session.installation_id.clone(),
|
||||
auth_manager,
|
||||
models_manager,
|
||||
|
||||
Reference in new issue
Block a user