Add opt-in conversation history retrieval to Guardian reviews (#49036)

## Why

The transcript supplied to Guardian may omit earlier user instructions, restrictions, or revoked permissions. History retrieval lets the reviewer check relevant authorization before approving actions with side effects.

## What changed

- Add the disabled-by-default `guardian_conversation_history_tools` feature. With Apps enabled, expose `user_message.search_messages` and `user_message.read_messages` through the parent's live Apps connection and conversation identity.
- Recheck the parent's current app and tool policy on each call, rejecting disabled tools and calls requiring approval.
- Add retrieval instructions that distinguish user authorization from assistant context and account for later revocations and incomplete results. Allow overrides through `auto_review.experimental_conversation_history_prompt`.
- Limit history responses to an estimated 4,000 tokens by default, configurable through `auto_review.conversation_history_max_output_tokens`, while preserving stricter parent and reviewer limits.
- Allow explicit extension registries for isolated sessions and prevent those sessions from inheriting the implicit Apps connection.

## Testing

Add scenarios covering history tool exposure, parent connection and identity reuse, custom prompts, output truncation, stricter reviewer budgets, and live permission changes on a reused reviewer. Extend configuration coverage for blank prompt overrides.

GitOrigin-RevId: 055a69b113c8548bd58e7d5618ea026ba6d1ffb1
This commit is contained in:
felixxia-oai
2026-09-28 17:29:52 +00:00
committed by copyberry
parent 46fdd5ef39
commit 41ed72c32b
21 changed files with 718 additions and 27 deletions
+11 -2
View File
@@ -2181,11 +2181,20 @@ impl ThreadManagerState {
}
let (instructions, inherited_exec_policy, extensions, mcp_manager, multi_agent_version) =
if isolation == codex_extension_api::SessionIsolation::Isolated {
let extensions = thread_extension_init
.get::<codex_extension_api::IsolatedSessionExtensions<Config>>()
.map(|extensions| Arc::clone(&extensions.0))
.unwrap_or_else(empty_extension_registry);
let mcp_manager = McpManager::new_with_extensions(
Arc::clone(&self.plugins_manager),
Arc::clone(&extensions),
CodexAppsToolsCache::default(),
);
(
inherited_instructions.unwrap_or_default(),
None,
empty_extension_registry(),
Arc::new(McpManager::new(Arc::clone(&self.plugins_manager))),
extensions,
Arc::new(mcp_manager),
Some(MultiAgentVersion::Disabled),
)
} else {