Skip to main content

CodexNamespaceHandler

Struct CodexNamespaceHandler 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn restore_output_items( &self, output: &mut [OutputItem], map: Option<&NamespaceMap>, )

Source

pub fn restore_response_value( &self, value: &mut Value, map: Option<&NamespaceMap>, ) -> bool

Source

pub fn restore_response_wire( &self, wire: &mut WireEvent, map: Option<&NamespaceMap>, ) -> bool

Trait Implementations§

Source§

impl Debug for CodexNamespaceHandler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ToolHandler for CodexNamespaceHandler

Source§

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.

Source§

fn tool_type(&self) -> ToolType

Source§

fn validate(&self, param: &Value) -> Result<(), ToolError>

Validate the tool param JSON. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more