pub struct CodexNamespaceHandler;Expand description
Handler for Codex type: "namespace" tools.
Namespace tools are client-owned, like plain function tools, but need a request-scoped normalization pass to flatten members into model-visible function names and restore model calls back to the public namespace shape.
Implementations§
Source§impl CodexNamespaceHandler
impl CodexNamespaceHandler
Sourcepub fn resolve_namespace_members(
&self,
tools: &[ResponsesTool],
) -> Result<Vec<ResponsesTool>, ToolError>
pub fn resolve_namespace_members( &self, tools: &[ResponsesTool], ) -> Result<Vec<ResponsesTool>, ToolError>
Rewrites every Namespace tool’s function members to their flat,
model-visible names (see model_visible_namespace_member_name),
with collision detection against sibling function-call registry keys.
Tools stay ResponsesTool::Namespace — only the nested members’
name fields change — so ResponsesTool::to_function_tools and
super::registry::ToolRegistry::build_with_handlers can read each
member’s already-flat name directly, with no further namespace logic.
Request execution must handle the result so ambiguous declarations fail instead of being normalized into an irreversible flat shape.
§Errors
Returns ToolError::Config when a generated namespace member name
collides with another declared function-call tool or with another
namespace member.
Sourcepub fn build_namespace_map(
&self,
tools: Option<&[ResponsesTool]>,
) -> Result<Option<NamespaceMap>, ToolError>
pub fn build_namespace_map( &self, tools: Option<&[ResponsesTool]>, ) -> Result<Option<NamespaceMap>, ToolError>
Builds a NamespaceMap once from a request’s declared tools, for
reuse across every subsequent restore/rewrite call on that request —
see NamespaceMap’s docs for why this matters.
§Errors
Returns ToolError::Config when a generated namespace member name
collides with another declared function-call tool or with another
namespace member.
Sourcepub fn validate_namespace_collisions(
&self,
tools: Option<&[ResponsesTool]>,
) -> Result<(), ToolError>
pub fn validate_namespace_collisions( &self, tools: Option<&[ResponsesTool]>, ) -> Result<(), ToolError>
Rejects namespace declarations that cannot be represented unambiguously by the gateway-owned flat model-visible naming scheme.
This must run before building the upstream request or request-scoped
registry. Otherwise the gateway could silently drop a namespace member
or restore a flat model call to the wrong public { namespace, name }.
§Errors
Returns ToolError::Config when a generated namespace member name
collides with another declared function-call tool or with another
namespace member.
Sourcepub fn resolve_tool_choice(
&self,
map: Option<&NamespaceMap>,
tool_choice: Option<&ToolChoice>,
) -> ToolChoice
pub fn resolve_tool_choice( &self, map: Option<&NamespaceMap>, tool_choice: Option<&ToolChoice>, ) -> ToolChoice
Resolves the request’s tool_choice (defaulting to ToolChoice::Auto
when absent) and, if it’s a namespaced ToolChoice::Function { namespace, name }, rewrites it to the flattened, model-visible name
that ResponsesTool::to_function_tools produces for the matching
namespace member — so tool_choice agrees with the tool names
actually sent upstream.
A no-op for ToolChoice variants other than Function, and for a
Function choice that doesn’t match any declared namespace member.
pub fn restore_output_items( &self, output: &mut [OutputItem], map: Option<&NamespaceMap>, )
pub fn restore_response_value( &self, value: &mut Value, map: Option<&NamespaceMap>, ) -> bool
pub fn restore_response_wire( &self, wire: &mut WireEvent, map: Option<&NamespaceMap>, ) -> bool
Trait Implementations§
Source§impl Debug for CodexNamespaceHandler
impl Debug for CodexNamespaceHandler
Source§impl ToolHandler for CodexNamespaceHandler
impl ToolHandler for CodexNamespaceHandler
Source§fn normalize(&self, param: &Value) -> Vec<FunctionTool>
fn normalize(&self, param: &Value) -> Vec<FunctionTool>
Converts an already-renamed namespace’s function members straight to
FunctionTools. Callers must rename members to their flat, model-visible
names first via CodexNamespaceHandler::resolve_namespace_members —
this method has no sibling-tool context to do that itself.
fn tool_type(&self) -> ToolType
Auto Trait Implementations§
impl Freeze for CodexNamespaceHandler
impl RefUnwindSafe for CodexNamespaceHandler
impl Send for CodexNamespaceHandler
impl Sync for CodexNamespaceHandler
impl Unpin for CodexNamespaceHandler
impl UnsafeUnpin for CodexNamespaceHandler
impl UnwindSafe for CodexNamespaceHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more