toolnamespace

package
v1.261203.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MPL-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package toolnamespace bridges Responses API `namespace` tools to protocols that only know flat function tools (OpenAI Chat, Anthropic).

A Responses client such as Codex groups MCP tools under a namespace:

{"type":"namespace","name":"mcp__linear__","tools":[{"type":"function","name":"get_issue",...}]}

and sends a call back as {"type":"function_call","namespace":"mcp__linear__","name":"get_issue"}. Flat upstreams have no such grouping, so the request side expands each namespace member into a function named FlatName(namespace, name), and the response side uses an Index built from the same request to split that name back into namespace and name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlatName

func FlatName(namespace, name string) string

FlatName is the function name a namespace member gets on a flat upstream. Codex namespaces MCP servers as `mcp__<server>__`, so the usual result is the familiar `mcp__<server>__<tool>`; a namespace without a trailing underscore gets a `__` separator.

func Functions

Functions returns the function tools of a Responses tool list in request order, with every namespace member expanded under its flat name. Whatever cannot be offered upstream is logged rather than dropped silently: a namespace member lost to a name clash or because it is not a function is a warning, a top-level tool type with no flat equivalent (web_search, custom and the like, which a flat upstream never had) is debug output, since clients such as Codex send those on every request.

Types

type Entry

type Entry struct {
	Namespace string
	Name      string
}

Entry is the namespace and member name a flattened function stands for.

type Index

type Index map[string]Entry

Index maps a flattened function name to the namespace member it came from. A nil Index restores nothing.

func IndexOf

func IndexOf(tools []responses.ToolUnionParam) Index

IndexOf returns the Index for a Responses request's tools: one entry per function inside a namespace. It is nil when the request has none. It makes the same decisions as Functions, so the names it knows are exactly the ones the upstream was offered.

func (Index) Restore

func (i Index) Restore(flat string) (namespace, name string)

Restore splits a flattened function name back into namespace and name. A name that was not produced from a namespace member comes back unchanged with an empty namespace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL