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

+18
View File
@@ -481,6 +481,24 @@ fn build_subagent_headers_sets_other_subagent_label() {
assert_eq!(value, Some("memory_consolidation"));
}
#[test]
fn internal_session_prompt_cache_key_is_scoped_to_parent_thread() {
let parent_thread_id = ThreadId::new();
let client = test_model_client(SessionSource::Internal(InternalSessionSource::Guardian));
let metadata = test_responses_metadata_for_client(
&client,
Some("turn-123"),
"window-1".to_string(),
Some(parent_thread_id),
TestCodexResponsesRequestKind::Turn,
);
assert_eq!(
client.prompt_cache_key(&metadata),
format!("guardian:{parent_thread_id}")
);
}
#[test]
fn build_subagent_headers_sets_internal_memory_consolidation_label() {
let client = test_model_client(SessionSource::Internal(