-
Notifications
You must be signed in to change notification settings - Fork 0
feat(classification): add ToolExposure so a tool can declare it is not advertised #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,62 @@ pub enum ToolScope { | |
| CliRpcOnly, | ||
| } | ||
|
|
||
| /// Where a tool is exposed to the model. | ||
| /// | ||
| /// Every tool a host registers is dispatchable. This says which of them the | ||
| /// model is *told about* up front, and it is a property of the tool rather than | ||
| /// of a config posture, because the answer rarely varies by deployment: a tool | ||
| /// the model needs on most turns is direct, and one it needs on a handful of | ||
| /// turns a week is not, whoever is running the host. | ||
| /// | ||
| /// The distinction exists because tool schemas are a fixed per-turn cost paid | ||
| /// on every request, and on a large tool surface they dominate it — measured on | ||
| /// OpenHuman's orchestrator, 45 KB of schema against 34 KB of system prompt. | ||
| /// A schema the model reads on one turn in five hundred is not worth its place | ||
| /// on the other four hundred and ninety-nine. | ||
| /// | ||
| /// Modelled on Codex's `ToolExposure` (`codex-rs/tools/src/tool_executor.rs`), | ||
| /// which pairs `Deferred` with a BM25-indexed `tool_search`. This enum is | ||
| /// deliberately the smaller half of that design: Codex additionally | ||
| /// distinguishes its Code Mode surface, which has no equivalent here yet. | ||
| #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum ToolExposure { | ||
|
Comment on lines
+41
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No test references AGENTS.md reference: AGENTS.md:L170-L172 Useful? React with 👍 / 👎. |
||
| /// Advertise the tool's schema on every request. | ||
| /// | ||
| /// The default, and deliberately so: a tool that has thought about its own | ||
| /// exposure will say so, and one that has not should keep behaving exactly | ||
| /// as it did before this existed. | ||
| #[default] | ||
| Direct, | ||
| /// Register the tool and keep its schema off the wire, reachable through | ||
| /// the host's tool-search facility. | ||
| /// | ||
| /// A host that offers no such facility must treat this as [`Self::Direct`] | ||
| /// rather than hiding the tool — a capability the model cannot see *and* | ||
| /// cannot look up is simply gone, which is a bigger regression than the | ||
| /// tokens it saves. | ||
| Deferred, | ||
|
Comment on lines
+51
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This introduces host-facing behavior and an important constraint that hosts without search must reinterpret AGENTS.md reference: AGENTS.md:L206-L208 Useful? React with 👍 / 👎. |
||
| /// Keep the tool dispatchable but never show it to the model. | ||
| /// | ||
| /// For tools a host calls on the model's behalf, or that exist only to be | ||
| /// invoked by another tool. | ||
| Hidden, | ||
| } | ||
|
|
||
| impl ToolExposure { | ||
| /// Whether this tool's schema belongs in the initial tool list. | ||
| pub fn is_direct(self) -> bool { | ||
| matches!(self, Self::Direct) | ||
| } | ||
|
|
||
| /// Whether tool search may surface this tool. | ||
| pub fn is_searchable(self) -> bool { | ||
| matches!(self, Self::Deferred) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| /// Category of a tool — used to scope which tools a given sub-agent may see. | ||
| /// | ||
| /// The distinction is about *where the work happens*: a [`Self::System`] tool | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ | |
| //! a tool hands back. | ||
| //! - [`spec`] — [`ToolSpec`], the declaration a model is shown. | ||
| //! - [`permission`] — [`PermissionLevel`], the privilege ladder. | ||
| //! - [`classification`] — [`ToolScope`] and [`ToolCategory`]. | ||
| //! - [`classification`] — [`ToolScope`], [`ToolCategory`] and [`ToolExposure`]. | ||
| //! - [`call`] — [`ToolCallOptions`] and [`ToolTimeout`], the per-invocation | ||
| //! inputs that are not arguments. | ||
| //! - [`context`] — [`ToolRunContext`], the narrow seam onto a live run. | ||
|
|
@@ -107,7 +107,7 @@ pub mod tool; | |
| pub mod workspace; | ||
|
|
||
| pub use call::{ToolCallOptions, ToolTimeout}; | ||
| pub use classification::{ToolCategory, ToolScope}; | ||
| pub use classification::{ToolCategory, ToolExposure, ToolScope}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This makes AGENTS.md reference: AGENTS.md:L204-L205 Useful? React with 👍 / 👎. |
||
| pub use context::ToolRunContext; | ||
| pub use naming::{ | ||
| ContextDetailOptions, context_detail_from_args, context_detail_from_args_with, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the new public type ToolExposure
ToolExposureis now publicly exported from the module but does not yet appear to have a rustdoc comment on its definition (the diff only changes the re-export line). The repository rules require every public item to get a rustdoc comment withmissing_docstreated as an error. Add///documentation explaining whatToolExposurerepresents, how it is used (including its relation toToolCategoryandToolScope), and any wire-format or default behaviour.[RULE] missing-docs ·