mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
## Why Guardian review can use spoken context when history supplies completed transcripts for user recordings and tool results. Source labels distinguish transcribed speech from typed user messages and identify the originating turn or tool call. ## What changed - Collect completed transcripts alongside their source history items so they participate in review delta selection. Respect tool output filtering. - Preserve source labels when truncating transcript text. Quote and escape speech in line format so it cannot introduce a new role header. - Support an optional `transcript_audio` elastic budget for synchronous and asynchronous reviews. Without it, user and tool audio use the message and tool budgets respectively. ## Testing Add coverage for loading the audio budget in both reviewers, enforcing it in line and JSON transcripts, and preserving the delta cursor as history grows. GitOrigin-RevId: fa7e130b1212692e71a996528d8397826837a644
49 lines
1.8 KiB
Rust
49 lines
1.8 KiB
Rust
//! Converts completed audio transcripts into ordinary, source-attributed conversation evidence.
|
|
//! Transcripts participate in the same delta selection and budgets as other messages and tool results.
|
|
|
|
use crate::ConversationTranscriptEntry;
|
|
use crate::ConversationTranscriptEntryKind;
|
|
use crate::ConversationTranscriptOptions;
|
|
use crate::TranscriptContent;
|
|
|
|
/// Text captured from a recording and paired with its original source by the host.
|
|
#[derive(Clone, Copy)]
|
|
pub enum AudioTranscript<'a> {
|
|
/// Speech from audio submitted on a user turn.
|
|
UserInput { turn_id: &'a str, text: &'a str },
|
|
/// Speech from audio returned by a tool call.
|
|
ToolOutput { call_id: &'a str, text: &'a str },
|
|
}
|
|
|
|
pub(crate) fn collect_audio_transcript(
|
|
transcript: AudioTranscript<'_>,
|
|
options: &ConversationTranscriptOptions,
|
|
) -> Option<ConversationTranscriptEntry> {
|
|
let (kind, text) = match transcript {
|
|
AudioTranscript::UserInput { turn_id, text } => (
|
|
ConversationTranscriptEntryKind::UserAudioTranscript(format!(
|
|
"audio transcript (recording submitted on user turn {turn_id:?})"
|
|
)),
|
|
text,
|
|
),
|
|
AudioTranscript::ToolOutput { call_id, text } if options.include_tool_outputs => (
|
|
ConversationTranscriptEntryKind::ToolAudioTranscript(format!(
|
|
"tool audio transcript (call {call_id:?})"
|
|
)),
|
|
text,
|
|
),
|
|
AudioTranscript::ToolOutput { .. } => return None,
|
|
};
|
|
if text.trim().is_empty() {
|
|
return None;
|
|
}
|
|
|
|
Some(ConversationTranscriptEntry {
|
|
kind,
|
|
original_bytes: text.len(),
|
|
content: TranscriptContent::Text(text.to_owned()),
|
|
// A transcription is distinct evidence from the original user message.
|
|
retained_source: None,
|
|
})
|
|
}
|