mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Add startup tool allowlists for threads (#45711)
## What changed - Add `AllowedTools` to the extension API, captured once at thread startup to restrict which tools can be advertised or executed. An empty list disables all tools; an absent value preserves ordinary tool setup. Callers must supply the list again when resuming a thread. - Filter tool registration and hosted tool specifications before Code Mode and discovery. Match names with their namespaces and require generated tools such as `exec` and `wait` to be explicitly allowed. - Move Guardian reviewer tool selection into the allowlist while retaining feature and sandbox restrictions, with a fallback for older reviewer sessions. ## Testing Add coverage for selected, empty, and absent allowlists across tool sources and Code Mode. Add managed-thread tests verifying advertised tools, rejection of excluded calls, and that replacing extension state after startup cannot change the captured allowlist. GitOrigin-RevId: 33c1722c4241f368963d8385fa0415112e16a72d
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//! A startup ceiling on the tools a thread may advertise or execute.
|
||||
|
||||
use crate::ToolName;
|
||||
|
||||
/// Supply through `ExtensionDataInit` before starting a thread. The host captures
|
||||
/// this value once; changing extension state later cannot widen the tool set.
|
||||
/// Callers must supply it again when resuming a thread.
|
||||
///
|
||||
/// An absent value keeps ordinary tool setup. An empty list permits no tools.
|
||||
/// Names include their namespace; a plain name uses the default namespace.
|
||||
/// This only removes tools: configuration and permission checks still apply.
|
||||
/// Generated tools such as Code Mode's `exec` and `wait` must also be listed.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct AllowedTools(pub Vec<ToolName>);
|
||||
|
||||
impl AllowedTools {
|
||||
pub fn contains(&self, tool: &ToolName) -> bool {
|
||||
self.0.iter().any(|allowed| {
|
||||
allowed.name == tool.name
|
||||
&& (allowed.namespace == tool.namespace
|
||||
|| (allowed.is_default_namespace() && tool.is_default_namespace()))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
mod allowed_tools;
|
||||
mod capabilities;
|
||||
mod contributors;
|
||||
mod registry;
|
||||
@@ -6,6 +7,7 @@ mod state;
|
||||
mod turn_admission;
|
||||
mod user_instructions;
|
||||
|
||||
pub use allowed_tools::AllowedTools;
|
||||
pub use session_isolation::SessionIsolation;
|
||||
|
||||
pub use capabilities::ConversationHistorySnapshot;
|
||||
|
||||
Reference in New Issue
Block a user