mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Add managed developer instructions to requirements (#39755)
## What changed - Add `additional_developer_instructions` to managed requirements and expose it through `configRequirements/read` as `additionalDeveloperInstructions`, independently of ordinary developer instructions. - Include the managed instructions in model context, emit explicit replacement or removal messages when requirements change, and preserve the current value across compaction, resume, and agent forks without duplication. - Reject managed instructions whose rendered context exceeds 10,000 estimated tokens. ## Testing - Cover requirements layering and API serialization, context updates and removal, size validation, repeated model requests, compaction and resume, rollout migration, and agent forks. GitOrigin-RevId: bc0b70fb7988944c2f68176dff55f5ed61eb46c8
This commit is contained in:
1 parent
85a1b0e33d
commit
ce950dcf26
31 files changed
+540
-19
No files matched your search
@@ -4,6 +4,7 @@ use crate::agent::role::apply_role_to_config;
|
||||
use crate::config::PermissionProfileSnapshot;
|
||||
use crate::context::ContextualUserFragment;
|
||||
use crate::context::CurrentTimeReminder;
|
||||
use crate::context::ManagedDeveloperInstructions;
|
||||
use crate::context::MultiAgentModeInstructions;
|
||||
use crate::context::MultiAgentRoleInstructions;
|
||||
use crate::session::multi_agents::resolve_usage_hints;
|
||||
@@ -737,16 +738,28 @@ impl AgentControl {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(parent_developer_instructions) = parent_developer_instructions.as_ref()
|
||||
&& let Some(subagent_developer_instructions) =
|
||||
subagent_developer_instructions.as_ref()
|
||||
&& let ResponseItem::Message { role, content, .. } = response_item
|
||||
if let ResponseItem::Message { role, content, .. } = response_item
|
||||
&& role == "developer"
|
||||
{
|
||||
content.retain_mut(|content_item| {
|
||||
let ContentItem::InputText { text } = content_item else {
|
||||
return true;
|
||||
};
|
||||
if ManagedDeveloperInstructions::matches_text(text) {
|
||||
// If the child will rebuild its initial context, drop the inherited
|
||||
// managed instructions; startup will add the current requirements once.
|
||||
return preserve_reference_context_item;
|
||||
}
|
||||
let (
|
||||
Some(parent_developer_instructions),
|
||||
Some(subagent_developer_instructions),
|
||||
) = (
|
||||
parent_developer_instructions.as_ref(),
|
||||
subagent_developer_instructions.as_ref(),
|
||||
)
|
||||
else {
|
||||
return true;
|
||||
};
|
||||
// TODO(anp) track better message fragment provenance in rollouts.
|
||||
if !text.contains(parent_developer_instructions) {
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user