mirror of
https://github.com/openai/codex.git
synced 2026-11-05 16:29:31 +00:00
Retain user instructions in Guardian context (#42844)
## Why Guardian reviews need the original user instructions even when compaction or transcript selection removes them from the active conversation window. ## What changed - Capture complete user messages in host-owned retained context and include them as ordered authorization evidence alongside verified answers. - Omit oversized instructions atomically and emit an explicit incomplete-evidence notice instead of exposing a potentially misleading partial permission. - Mark user messages inherited by forked agents so they remain model-visible without becoming child-local authorization. ## Testing - Cover retained instructions across compaction, resume, rollback, and agent forks, including oversized evidence and legacy context behavior. GitOrigin-RevId: 97122509d818c90d2f87c6a1b29c99c05ad0316e
This commit is contained in:
1 parent
147137c1f4
commit
9c4253ffc1
20 files changed
+663
-140
No files matched your search
@@ -1385,9 +1385,17 @@ async fn spawn_agent_without_fork_from_paginated_parent_stays_fresh_and_paginate
|
||||
.expect("parent shutdown should submit");
|
||||
}
|
||||
|
||||
#[test_case::test_case(true; "thread context enabled")]
|
||||
#[test_case::test_case(false; "thread context disabled")]
|
||||
#[tokio::test]
|
||||
async fn spawn_agent_fork_drops_inherited_token_usage_state() {
|
||||
let harness = AgentControlHarness::new().await;
|
||||
async fn spawn_agent_fork_drops_inherited_token_usage_state(thread_context_enabled: bool) {
|
||||
let mut harness = AgentControlHarness::new().await;
|
||||
let _ = harness.config.features.disable(Feature::MultiAgentV2);
|
||||
harness
|
||||
.config
|
||||
.features
|
||||
.set_enabled(Feature::GuardianThreadContext, thread_context_enabled)
|
||||
.expect("test context mode");
|
||||
let (parent_thread_id, parent_thread) = harness.start_paginated_thread().await;
|
||||
let parent_usage = TokenUsage {
|
||||
total_tokens: 120,
|
||||
@@ -1445,6 +1453,15 @@ async fn spawn_agent_fork_drops_inherited_token_usage_state() {
|
||||
total_tokens: 80,
|
||||
..TokenUsage::default()
|
||||
};
|
||||
assert!(
|
||||
!child_thread
|
||||
.session
|
||||
.clone_history()
|
||||
.await
|
||||
.retained_context()
|
||||
.user_messages_complete(),
|
||||
"V1 forks lack complete retained authorization in both context modes"
|
||||
);
|
||||
let turn_context = child_thread.session.new_default_turn().await;
|
||||
child_thread
|
||||
.session
|
||||
@@ -2121,7 +2138,6 @@ async fn spawn_agent_fork_strips_parent_usage_hints_from_compacted_history(
|
||||
);
|
||||
let mut inherited_context = codex_history::RetainedContext::default();
|
||||
if thread_context_enabled {
|
||||
inherited_context.restore(/*checkpoint*/ None);
|
||||
inherited_context.reserve_order();
|
||||
} else {
|
||||
inherited_context.mark_user_messages_incomplete();
|
||||
|
||||
Reference in new issue
Block a user