mirror of
https://github.com/openai/codex.git
synced 2026-12-05 01:00:54 +00:00
## Why Guardian transcripts omitted encrypted agent messages, leaving reviews without evidence such as encrypted parent replies. ## What changed - Carry encrypted `agent_message` items through synchronous reviews and asynchronous scoring, preserving their order, author, recipient, and ciphertext. - Account for native messages in context budgets and omit them whole with an explicit notice when limits require it. - Support mixed text and native messages during review admission while retaining user-content annotations. ## Testing Add coverage for transcript ordering and budget eviction in both reviewer profiles, plus a mocked scenario verifying that an encrypted parent reply appears exactly once in each of two incremental Guardian reviews. GitOrigin-RevId: abc2f1ce5accd83beb06f799ef9ed9d7fa2cd90a
78 lines
3.0 KiB
Rust
78 lines
3.0 KiB
Rust
//! Structured transcript evidence shared by synchronous and asynchronous Guardian.
|
|
//!
|
|
//! Entry kinds preserve source attribution for consumer-specific retention and
|
|
//! rendering. User text and manual approvals stay complete for admission; other text is
|
|
//! capped during collection, with its original size retained for accounting.
|
|
|
|
/// Semantic role of one parent-conversation transcript entry.
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub enum ConversationTranscriptEntryKind {
|
|
/// Actual parent-thread user message.
|
|
User,
|
|
/// Explicit developer message preserving a user-approved action.
|
|
Developer,
|
|
/// Assistant commentary or an inter-agent message.
|
|
Assistant,
|
|
/// Final assistant answer eligible for stronger async retention.
|
|
ProtectedAssistant,
|
|
/// Named tool invocation, including shell and web-search calls.
|
|
ToolCall(String),
|
|
/// Tool result with a call-derived, explicit, or generic fallback label.
|
|
ToolOutput(String),
|
|
/// Result from a Node REPL-backed tool that may receive a larger sync cap.
|
|
NodeReplToolOutput(String),
|
|
/// Plaintext model reasoning that the async consumer explicitly enables.
|
|
Reasoning,
|
|
}
|
|
|
|
impl ConversationTranscriptEntryKind {
|
|
/// Returns the role label currently used in Guardian transcript prompts.
|
|
pub fn role(&self) -> &str {
|
|
match self {
|
|
Self::User => "user",
|
|
Self::Developer => "developer",
|
|
Self::Assistant | Self::ProtectedAssistant => "assistant",
|
|
Self::ToolCall(role) | Self::ToolOutput(role) | Self::NodeReplToolOutput(role) => {
|
|
role.as_str()
|
|
}
|
|
Self::Reasoning => "reasoning",
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Text or an opaque native message that only the backend can decode.
|
|
#[derive(Clone, PartialEq)]
|
|
pub enum TranscriptContent {
|
|
Text(String),
|
|
AgentMessage(Box<codex_protocol::models::ResponseItem>),
|
|
}
|
|
|
|
impl std::fmt::Debug for TranscriptContent {
|
|
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
formatter.write_str(match self {
|
|
Self::Text(_) => "Text(..)",
|
|
Self::AgentMessage(_) => "AgentMessage(..)",
|
|
})
|
|
}
|
|
}
|
|
|
|
/// Structured evidence shared by sync Guardian and async scoring.
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct ConversationTranscriptEntry {
|
|
/// Semantic role used for consumer-specific retention and truncation.
|
|
pub kind: ConversationTranscriptEntryKind,
|
|
/// Complete authorization evidence, or other text bounded by per-entry limits.
|
|
pub content: TranscriptContent,
|
|
/// Size before truncation, retained for omission and truncation accounting.
|
|
pub original_bytes: usize,
|
|
/// Original source revision and display order, established from host metadata.
|
|
pub retained_source: Option<RetainedTranscriptSource>,
|
|
}
|
|
|
|
/// Display ordering is separate from source identity and cannot establish delivery.
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub struct RetainedTranscriptSource {
|
|
pub order: String,
|
|
pub source: codex_history::RetainedSource,
|
|
}
|