mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve Guardian's reusable history prefix across approval requests (#46279)
## Why Changing previous review decisions or trusted tool and skill evidence should not invalidate the reusable conversation history prefix. ## What changed Move previous reviews, trusted tool metadata, and trusted skills after the transcript and permission context in Guardian context composition. Keep them before the current action, with history remaining user-role evidence. ## Testing Add a regression test that varies reviews, tools, skills, and actions while asserting an identical history prefix, both with and without retained context. Update the Guardian v2 integration test to verify the separate transcript and action messages. GitOrigin-RevId: 8f5b570b17b6715beac526afff7d52139d13a3ad
This commit is contained in:
1 parent
3ed49879c8
commit
d7f8e48d7d
3 files changed
+181
-15
No files matched your search
@@ -1187,21 +1187,46 @@ async fn guardian_v2_routes_scoped_tool_approvals(
|
||||
vec![
|
||||
json!(["additional_tools", "developer", null]),
|
||||
json!(["message", "developer", ["guardian.classifier_instructions"]]),
|
||||
json!(["message", "user", null]),
|
||||
json!(["message", "developer", null]),
|
||||
json!(["message", "developer", ["guardian.trusted_tool"]]),
|
||||
json!(["message", "developer", ["guardian.trusted_skills"]]),
|
||||
json!(["message", "user", null]),
|
||||
],
|
||||
);
|
||||
let content = input[5]["content"].as_array().expect("untrusted evidence");
|
||||
let texts = content
|
||||
let history = input[2]["content"].as_array().expect("untrusted history");
|
||||
let history_texts = history
|
||||
.iter()
|
||||
.filter_map(|item| item["text"].as_str())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(texts.first().copied(), Some(">>> TRANSCRIPT START\n"));
|
||||
assert!(texts.iter().any(|text| text.contains(USER_CONTEXT)));
|
||||
assert!(texts.iter().any(|text| text.contains("guardian-0")));
|
||||
assert_eq!(texts.last().copied(), Some(">>> APPROVAL REQUEST END\n"));
|
||||
assert_eq!(
|
||||
history_texts.first().copied(),
|
||||
Some(">>> TRANSCRIPT START\n")
|
||||
);
|
||||
assert!(history_texts.iter().any(|text| text.contains(USER_CONTEXT)));
|
||||
assert!(history_texts.iter().any(|text| text.contains("guardian-0")));
|
||||
assert_eq!(
|
||||
history_texts.last().copied(),
|
||||
Some(">>> TRANSCRIPT END\n\n")
|
||||
);
|
||||
assert!(history.iter().all(|item| item["type"] == "input_text"));
|
||||
|
||||
let content = input[6]["content"].as_array().expect("action and images");
|
||||
let action_texts = content
|
||||
.iter()
|
||||
.filter_map(|item| item["text"].as_str())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
&action_texts[..2],
|
||||
&[
|
||||
"The Codex agent has requested the following action:\n",
|
||||
">>> APPROVAL REQUEST START\n",
|
||||
],
|
||||
);
|
||||
assert_eq!(
|
||||
action_texts.last().copied(),
|
||||
Some(">>> APPROVAL REQUEST END\n")
|
||||
);
|
||||
assert!(
|
||||
content[..content.len() - 1]
|
||||
.iter()
|
||||
|
||||
Reference in new issue
Block a user