mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve Guardian context sections and share planned-action rendering (#43534)
## What changed - Replace `ComposedContext` with ordered `ContextSection` values that retain section identities through transcript selection and rendering. - Add a shared `PlannedAction` section and renderer for core synchronous approval prompts and the Guardian V2 asynchronous scorer, preserving full, delta, terminal-input, and network-request framing. - Keep action JSON and retry reasons out of `PlannedAction` debug output. ## Testing Update registry and transcript tests to assert section identities and source roles. Extend registry coverage to verify planned-action collection for both consumers and omission of action JSON and reasons from debug output. GitOrigin-RevId: 675b841a2cad06afce03f414615b4d7aa0553b13
This commit is contained in:
1 parent
53ba408a2f
commit
93ac341410
12 files changed
+437
-233
No files matched your search
@@ -1,41 +0,0 @@
|
||||
//! Groups collected sections for the existing Guardian prompt layout.
|
||||
//!
|
||||
//! Authorization keeps its rendered fragment boundaries and registration order.
|
||||
//! Transcript entries remain structured so callers retain their own rendering,
|
||||
//! retention and delta policies. Composition never changes roles or budgets.
|
||||
|
||||
use crate::ContextSection;
|
||||
use crate::ConversationTranscriptEntry;
|
||||
use crate::SectionError;
|
||||
use crate::SectionInput;
|
||||
use crate::SectionRegistry;
|
||||
|
||||
/// Shared authorization prelude and transcript evidence before caller rendering.
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
pub struct ComposedContext {
|
||||
pub authorization: Vec<String>,
|
||||
pub transcript: Vec<ConversationTranscriptEntry>,
|
||||
}
|
||||
|
||||
impl SectionRegistry {
|
||||
/// Collects sections and groups them without duplicating layout knowledge in callers.
|
||||
///
|
||||
/// Like [`Self::collect`], returns no partial context if a contributor fails.
|
||||
/// Callers needing individual section identities can continue using `collect`.
|
||||
pub fn compose(&self, input: &SectionInput<'_>) -> Result<ComposedContext, SectionError> {
|
||||
let mut context = ComposedContext::default();
|
||||
for section in self.collect(input)? {
|
||||
match section {
|
||||
ContextSection::ConversationTranscript { items } => {
|
||||
context.transcript.extend(items)
|
||||
}
|
||||
ContextSection::RootConversation { items }
|
||||
| ContextSection::RetainedUserInstructions { items }
|
||||
| ContextSection::TrustedUserAnswers { items } => {
|
||||
context.authorization.extend(items)
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(context)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user