Skip to content

Feature Request: namespaced function calls and custom tool calls in Responses API fixtures #505

Closed

Description

@gulsher321

Checked against aimock v1.44.0 (latest, f5e17a6) used as the model behind Codex CLI rust-v0.161.0.

aimock can script ordinary Responses API function calls, but not calls to MCP tools, sub-agent tools or apply_patch. Codex needs two output items for those that aimock doesn't emit yet.

What's missing

1. namespace on function_call items

The Responses API can group tools under a namespace tool ({"type": "namespace", "name": "...", "tools": [...]}). A call to a tool in a group carries namespace next to name. See the function calling guide's Defining namespaces, and NamespaceToolParam and FunctionToolCall.namespace in the OpenAPI spec.

In aimock:

2. custom_tool_call items

A custom tool ({"type": "custom", ...}, optionally with a Lark or regex grammar) is answered with a custom_tool_call item carrying a free-text input. It streams as response.custom_tool_call_input.delta and response.custom_tool_call_input.done. See the guide's Custom tools, and CustomToolCall, ResponseCustomToolCallInputDeltaEvent and ResponseCustomToolCallInputDoneEvent in the spec. aimock has no fixture shape or builder for this item.

Why Codex needs them

All links are to rust-v0.161.0.

MCP tools. Codex wraps each MCP server's tools in one namespace tool (handlers/mcp.rs L498-L531). It routes a returned call by its exact (namespace, name) (router.rs L248-L299, registry.rs L490-L494). A plain function_call named after an MCP tool doesn't reach it.

Sub-agent tools live in the collaboration namespace by default (config/mod.rs L261). features.multi_agent_v2.tool_namespace can rename it but not remove it: an empty value is rejected (L3157-L3180).

No setting turns namespaces off.

apply_patch is a freeform custom tool with a Lark grammar (handlers/apply_patch_spec.rs L9-L30). ApplyPatchToolType has only Freeform (protocol/src/openai_models.rs L321-L325), and every model in the bundled catalog uses it.

So a test that drives Codex with aimock can't yet exercise an MCP tool call, a sub-agent or a file edit.

Possible shape

A suggestion only; whatever fits aimock's fixture model is fine.

  • An optional namespace on ToolCall, emitted on the Responses function_call item over HTTP (streaming and non-streaming) and WebSocket.
  • A custom tool call fixture, e.g. { "type": "custom", "name": "apply_patch", "input": "..." }, emitted as a custom_tool_call item and streamed with response.custom_tool_call_input.delta and .done.

Related, on the request side: toolName matching only sees top-level function tools. responsesToolsToCompletionsTools drops namespace and custom tools (src/responses.ts L230-L240, src/router.ts L501-L504), so a fixture can't match on a tool offered inside a namespace or as a custom tool.

Related, on recording: collapseOpenAISSE keeps call_id, name and arguments from a Responses function_call (src/stream-collapse.ts L523-L538), so a recorded namespaced call loses its namespace.

Activity

  1. self-assigned this
    on Oct 9, 2026
  2. jpr5 commented on Oct 10, 2026

    @jpr5
    Contributor

    Shipped in 1.45.0 (npm @copilotkit/aimock, PyPI aimock-pytest 0.7.0).

    Responses API fixtures can now carry namespaced function calls (function_call.namespace) and custom tool calls (customToolCalls, emitted as custom_tool_call items with response.custom_tool_call_input.delta/.done events). Recording captures both. Matching on match.toolNamespace is supported.

    This is opt-in, so existing setups behave exactly as in 1.44.0. Turn it on with responsesTools: "extended" (option), --responses-tools extended (CLI) or llm.responsesTools: "extended" (config). From pytest, use AIMockServer(responses_tools="extended").

    Implemented in #511 and #513, made opt-in in #518. Verified against Codex CLI 0.161.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions