mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
Unify Guardian context section collection (#42076)
## What changed - Add typed context sections for root-conversation evidence, trusted user answers, and conversation transcripts to `codex-guardian-context`. - Use the shared section registry when building core Guardian prompts and asynchronous Guardian V2 scoring context. - Preserve source-role labeling while delivering authorization evidence as user-role context, and fail closed when context collection fails. ## Testing - Cover shared section ordering and role preservation for synchronous and asynchronous targets. - Verify trusted user answers appear exactly once as user-role input in Guardian V2 approval flows. GitOrigin-RevId: 1d5d793ffbf166077411a66e85e039596907fb7e
This commit is contained in:
1 parent
d141438342
commit
2350823caa
15 files changed
+357
-108
No files matched your search
@@ -22,8 +22,8 @@ use super::GuardianThreadContext;
|
||||
use crate::async_scorer::DEFAULT_MODEL_CONTEXT_ITEM_TOKENS;
|
||||
use crate::async_scorer::GuardianV2Config;
|
||||
use crate::async_scorer::MAX_TOOL_ENTRY_TOKENS;
|
||||
use crate::async_scorer::RenderedContext;
|
||||
use crate::async_scorer::RenderedImages;
|
||||
use crate::async_scorer::RenderedTranscript;
|
||||
use crate::async_scorer::TranscriptConfig;
|
||||
use crate::async_scorer::TranscriptSource;
|
||||
use crate::async_scorer::truncate_entry;
|
||||
@@ -94,7 +94,11 @@ pub(super) fn build(
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let transcript = transcript_config.build_snapshot(input.conversation_history.as_ref());
|
||||
let transcript = transcript_config
|
||||
.build_snapshot(input.conversation_history.as_ref())
|
||||
.map_err(|error| {
|
||||
ApprovalReviewError::Failed(format!("context collection failed: {error}"))
|
||||
})?;
|
||||
let images = render_images(
|
||||
input.conversation_history.as_ref(),
|
||||
transcript_config,
|
||||
@@ -178,7 +182,7 @@ impl PromptBuilder {
|
||||
&mut self,
|
||||
root_authorization: Option<GuardianRootSnapshot>,
|
||||
trusted_user_answers: Vec<String>,
|
||||
transcript: RenderedTranscript,
|
||||
transcript: RenderedContext,
|
||||
thread_id: ThreadId,
|
||||
) {
|
||||
self.text(
|
||||
|
||||
Reference in new issue
Block a user