Files
codex/codex-rs/ext/extension-api/src/session_isolation.rs
T
felixxia-oai 41ed72c32b 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
2026-09-28 17:29:52 +00:00

25 lines
1.2 KiB
Rust

//! Host-supplied isolation for internal runtimes, independent of their attribution.
//! Isolation only removes inherited capabilities; it never grants review authority.
//! Isolated sessions may receive a separate registry of explicit extensions.
use std::sync::Arc;
use crate::ExtensionRegistry;
/// Runtime policy supplied through `ExtensionDataInit` before session startup.
/// The host captures this value once so later extension-state changes cannot alter it.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SessionIsolation {
/// Use the host's ordinary instruction providers, extensions and execution rules.
#[default]
Inherit,
/// Start without inherited instruction providers or extensions, retain only managed
/// execution rules, and omit implicit Apps and executor-discovered MCP servers. Explicitly supplied
/// instructions and permissions remain the responsibility of the internal caller.
Isolated,
}
/// Explicit extensions for an isolated session, supplied through `ExtensionDataInit`.
/// The host uses only this registry and never combines it with inherited extensions.
pub struct IsolatedSessionExtensions<C: Sync>(pub Arc<ExtensionRegistry<C>>);