mirror of
https://github.com/openai/codex.git
synced 2026-11-16 06:54:36 +00:00
Move Guardian REPL evidence rendering into the shared context registry (#43602)
## What changed Move completed REPL response rendering into `codex-guardian-context` and register a synchronous-only `NodeReplEvidence` section. Core supplies a borrowed view of its evidence snapshot and retains responsibility for capture, storage eviction, and the delivery cursor. Preserve the existing text and multimodal layouts, rendering bounds, omission markers, image ordering, and deduplication. Exclude evidence payloads from the rendered section's debug output. ## Testing Adapt the existing evidence tests to exercise the shared renderer. Extend registry coverage to verify synchronous-only inclusion, rendered content, and omission of evidence payloads from debug output. GitOrigin-RevId: eb181870558a7f2f77270dee7c17d36700f3e148
This commit is contained in:
1 parent
b4373e53ab
commit
d75ed505d7
11 files changed
+352
-175
No files matched your search
@@ -152,6 +152,23 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
|
||||
}),
|
||||
};
|
||||
let permissions = parent_context.map(parent_turn_permissions);
|
||||
let node_repl_snapshot = if node_repl_transcripts_enabled {
|
||||
session
|
||||
.services
|
||||
.thread_extension_data
|
||||
.get::<NodeReplReviewEvidence>()
|
||||
.and_then(|evidence| evidence.snapshot_since(reviewed_node_repl_evidence_sequence))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let node_repl_context = node_repl_snapshot
|
||||
.as_ref()
|
||||
.map(|snapshot| snapshot.context(evidence_mode));
|
||||
let node_repl_evidence_sequence = node_repl_snapshot
|
||||
.as_ref()
|
||||
.map_or(reviewed_node_repl_evidence_sequence, |snapshot| {
|
||||
snapshot.sequence
|
||||
});
|
||||
let sections = collect_guardian_context(
|
||||
&GuardianReviewHistory(history),
|
||||
node_repl_result_token_limit,
|
||||
@@ -159,6 +176,7 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
|
||||
&trusted_user_inputs,
|
||||
Some(&planned_action),
|
||||
permissions.as_ref(),
|
||||
node_repl_context.as_ref(),
|
||||
)?;
|
||||
let transcript_entries = sections
|
||||
.iter()
|
||||
@@ -240,6 +258,7 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
|
||||
let mut action_items = Vec::new();
|
||||
let mut permission_items = Vec::new();
|
||||
let mut image_items = Vec::new();
|
||||
let mut node_repl_items = Vec::new();
|
||||
for section in sections {
|
||||
match section {
|
||||
ContextSection::RootConversation { items }
|
||||
@@ -254,6 +273,7 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
|
||||
| ContextSection::TrustedSkills(_) => {
|
||||
unreachable!("trusted review and tool sections are async-only")
|
||||
}
|
||||
ContextSection::NodeReplEvidence(evidence) => node_repl_items = evidence.items,
|
||||
ContextSection::TranscriptImages(images) => {
|
||||
image_items.extend(images.images.into_iter().filter_map(|image| match image {
|
||||
codex_protocol::models::ContentItem::InputImage { image_url, detail } => {
|
||||
@@ -286,17 +306,7 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
|
||||
push_text(text);
|
||||
}
|
||||
items.extend(image_items);
|
||||
let mut node_repl_evidence_sequence = reviewed_node_repl_evidence_sequence;
|
||||
if node_repl_transcripts_enabled
|
||||
&& let Some(fragment) = session
|
||||
.services
|
||||
.thread_extension_data
|
||||
.get::<NodeReplReviewEvidence>()
|
||||
.and_then(|evidence| evidence.snapshot_since(reviewed_node_repl_evidence_sequence))
|
||||
{
|
||||
node_repl_evidence_sequence = fragment.sequence;
|
||||
items.extend(fragment.into_inputs(evidence_mode));
|
||||
}
|
||||
items.extend(node_repl_items);
|
||||
items.extend(action_items.into_iter().map(|text| UserInput::Text {
|
||||
text,
|
||||
text_elements: Vec::new(),
|
||||
@@ -478,6 +488,7 @@ pub(super) fn collect_guardian_context(
|
||||
trusted_user_answers: &[String],
|
||||
planned_action: Option<&PlannedAction>,
|
||||
permissions: Option<&PermissionContext>,
|
||||
node_repl: Option<&codex_guardian_context::NodeReplContext<'_>>,
|
||||
) -> Result<Vec<ContextSection>, SectionError> {
|
||||
let transcript = ConversationTranscriptConfig {
|
||||
options: ConversationTranscriptOptions::default(),
|
||||
@@ -499,6 +510,7 @@ pub(super) fn collect_guardian_context(
|
||||
trusted_tool: None,
|
||||
trusted_skill_paths: &[],
|
||||
images: None,
|
||||
node_repl,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -957,6 +957,7 @@ fn collect_guardian_transcript_entries(
|
||||
&[],
|
||||
/*planned_action*/ None,
|
||||
/*permissions*/ None,
|
||||
/*node_repl*/ None,
|
||||
)
|
||||
.expect("collect Guardian context")
|
||||
.into_iter()
|
||||
|
||||
Reference in new issue
Block a user