Skip to content

[Bug]: Cursor client-tool continuation can return tool-call-like assistant text to Pi #2305

Description

@knttkd

Client or integration

Other — Pi coding agent (pi CLI) using OpenCodex as an OpenAI Chat Completions custom provider.

Area

Provider adapter

Summary

When Pi uses opencodex/cursor/grok-4.6, a Cursor-display MCP alias can be returned to Pi as the literal tool-call name instead of the request-declared Pi tool name.

For a Pi request that declares only grep, Cursor/Grok can return:

mcp_opencodex-responses_grep

Pi has no tool with that name. The turn stops after displaying the tool call and never executes grep or receives a tool result.

The expected client-facing name is the original request-declared name:

grep

This is not a request to permit undeclared tools. The long Cursor display alias should be normalized to the declared Responses/Pi tool name before OpenCodex emits the client-facing tool call.

Reproduction

  1. Run OpenCodex on loopback and configure Pi with the generated opencodex provider using api: "openai-completions".

  2. Start Pi with the Cursor-routed Grok model and allow only grep:

    pi --model opencodex/cursor/grok-4.6:high --tools grep --no-session
  3. Ask the model to search the current directory with grep. A normal call can succeed and is displayed by Pi as:

    grep OpenCodex
    ✓ 1 lines
    
  4. In the same Pi session, ask it to use the Cursor-side long display alias for the only available grep tool (or wait for Cursor to choose that display form).

  5. Pi receives the following instead of its declared tool name:

    [TOOL_CALL]mcp_opencodex-responses_grep[ARGS]{"pattern":"OpenCodex"}
    
  6. No normal grep execution/result follows. The turn is effectively blocked because Pi cannot dispatch a tool named mcp_opencodex-responses_grep.

The test was intentionally limited to one declared tool, so no unrelated tool catalog or MCP server was involved in the failure.

Version

OpenCodex: 2.28.0
Pi: 0.84.2

Operating system

macOS 26.5 (arm64)

Provider and model

provider: cursor
model: grok-4.6
OpenCodex selector: cursor/grok-4.6
reasoning effort: high
adapter: cursor

Logs or error output

Pi transcript from the failing turn:

Thinking...

長い表示別名の grep を1回だけ呼び出して、現在の作業ディレクトリを検索します。
[TOOL_CALL]mcp_opencodex-responses_grep[ARGS]{"pattern": "OpenCodex"}

The adjacent control turn in the same Pi session completed with the ordinary declared tool name:

grep OpenCodex
✓ 1 lines

OpenCodex recorded the requests as successful Cursor-adapter requests (provider: cursor, model: grok-4.6, adapter: cursor, HTTP status 200). The failure occurs on the tool-name translation returned to Pi, not at the upstream HTTP request boundary.

Redacted configuration

Pi provider shape:

{
  "providers": {
    "opencodex": {
      "baseUrl": "http://127.0.0.1:10100/v1",
      "api": "openai-completions",
      "apiKey": "opencodex-loopback"
    }
  }
}

Relevant existing behavior

The Cursor adapter already has display-name normalization for the mcp_opencodex-responses_ prefix. The observed Pi result indicates that at least one Cursor return path emits the display alias without applying that normalization to generic client tools such as grep.

The existing normalization currently appears intended to fold the display name back to the advertised wire name:

mcp_opencodex-responses_grep -> grep

Please apply the same invariant to every Cursor client-tool return path before emitting a Responses/Chat Completions tool call to the downstream client, and add a regression test with a non-shell generic tool such as grep.

Related issues

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglanded-via-maintainerOriginal PR closed after landing via a maintainer merge trainneeds-infoWaiting on reporter for a concrete spec or reproductionproviderProvider adapters, OpenAI-compat presets, upstream API quirkstoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions