mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
## What changed Move Guardian session-source detection, the reviewer name constant, and parent-thread prompt cache key generation into `codex-guardian-reviewer`. Re-export them from core, preserving existing behavior. ## Testing Move the existing prompt cache key test into the reviewer crate, retaining coverage for parent-thread scoping, key length, and missing or inapplicable inputs. GitOrigin-RevId: c14b3c030ba93676a0799aba56b23a676dbbc56d
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
//! Recognizes Guardian session sources and scopes legacy reviewer cache keys to the parent thread.
|
|
|
|
use codex_protocol::ThreadId;
|
|
use codex_protocol::protocol::InternalSessionSource;
|
|
use codex_protocol::protocol::SessionSource;
|
|
use codex_protocol::protocol::SubAgentSource;
|
|
|
|
pub const GUARDIAN_REVIEWER_NAME: &str = "guardian";
|
|
|
|
pub fn is_basic_session_source(session_source: &SessionSource) -> bool {
|
|
match session_source {
|
|
SessionSource::SubAgent(SubAgentSource::Other(label)) => label == GUARDIAN_REVIEWER_NAME,
|
|
SessionSource::Internal(InternalSessionSource::Guardian) => true,
|
|
_ => false,
|
|
}
|
|
}
|
|
|
|
pub fn prompt_cache_key_override_for_review_session(
|
|
session_source: &SessionSource,
|
|
parent_thread_id: Option<ThreadId>,
|
|
) -> Option<String> {
|
|
let SessionSource::SubAgent(SubAgentSource::Other(name)) = session_source else {
|
|
return None;
|
|
};
|
|
if name != GUARDIAN_REVIEWER_NAME {
|
|
return None;
|
|
}
|
|
let parent_thread_id = parent_thread_id?;
|
|
Some(format!("guardian:{parent_thread_id}"))
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "session_tests.rs"]
|
|
mod tests;
|