Add Guardian internal session support (#39994)

## What changed

- Add an extension API for spawning host-owned internal sessions and a
  `ThreadReadyInput` lifecycle callback that runs after thread registration.
- Add Guardian reviewer session scaffolding that records the parent thread and
  effective model, plus the under-development `guardian_ext` feature flag.
- Start internal sessions with fresh history while preserving parent lineage,
  shared session controls, and internal-thread visibility rules.
- Scope internal-session prompt cache keys to their source and parent thread,
  and expose `guardian` as an internal session source.

## Testing

- Cover internal-session spawning, parent metadata, history isolation, prompt
  cache keys, and extension spawner argument forwarding.

GitOrigin-RevId: 682dae80397d62bb36247796b447042e760ca364
This commit is contained in:
Won Park authored and copyberry committed 2026-08-21 19:11:05 +00:00
1 parent 79b7606803
commit 56012fafb8
22 files changed
+402 -10

No files matched your search

+11 -3
View File
@@ -483,9 +483,17 @@ impl ModelClient {
}
fn prompt_cache_key(&self, responses_metadata: &CodexResponsesMetadata) -> String {
self.prompt_cache_key_override
.clone()
.unwrap_or_else(|| responses_metadata.session_id.clone())
if let Some(prompt_cache_key) = &self.prompt_cache_key_override {
return prompt_cache_key.clone();
}
if let SessionSource::Internal(source) = &self.state.session_source
&& let Some(parent_thread_id) = responses_metadata.parent_thread_id
{
return format!("{source}:{parent_thread_id}");
}
responses_metadata.session_id.clone()
}
/// Creates a fresh turn-scoped streaming session.