Skip to content

feat(0.22.1): mcpToolsForRuntimeMcp() — project MCP tools to OpenAI shape#53

Closed
tangletools wants to merge 1 commit into
mainfrom
feat/mcp-openai-tools-helper
Closed

feat(0.22.1): mcpToolsForRuntimeMcp() — project MCP tools to OpenAI shape#53
tangletools wants to merge 1 commit into
mainfrom
feat/mcp-openai-tools-helper

Conversation

@tangletools
Copy link
Copy Markdown
Contributor

Summary

  • New helper mcpToolsForRuntimeMcp() projects the 5 agent-runtime MCP delegation tools (delegate_code, delegate_research, delegate_feedback, delegation_status, delegation_history) into the OpenAI Chat Completions tools[] shape consumed by createOpenAICompatibleBackend.
  • mcpToolsForRuntimeMcpSubset(names) filters that projection to a curated subset.
  • Helper sources name + description + input schema from the canonical DELEGATE_*_TOOL_NAME / DELEGATE_*_DESCRIPTION / DELEGATE_*_INPUT_SCHEMA constants so the projection cannot drift from the server's own validators.
  • Re-exported from the package root and from /mcp so eval / orchestrator code can pass tools: mcpToolsForRuntimeMcp() directly.
  • Bump to 0.22.1; README gains a "Surfacing the tools through createOpenAICompatibleBackend" section.

Sandbox-SDK callers do not need this helper — the sandbox runtime mounts MCP servers natively and the in-sandbox harness discovers tools through the runtime, not through an OpenAI tools[] array.

Why

0.22.0 added tools + toolChoice to createOpenAICompatibleBackend, but the backend does not auto-discover tools from a parent sandbox's AgentProfile.mcpServers. Eval harnesses that wire tcloud / cli-bridge against an MCP-mounted runtime were not surfacing the delegation tools to the LLM. The gtm-agent canonical-delegation eval observed delegate_research: 0/3, delegate_code: 0/1, composite=0.07 because the model had no idea the tools existed.

This helper closes the projection gap. The companion PR in gtm-agent wires it through canonical-delegation so the eval can fire delegations end-to-end.

Test plan

  • pnpm typecheck
  • pnpm test — 267 tests pass, 11 new in tests/mcp/openai-tools.test.ts
  • pnpm build — tsup clean (helper bundled into dist/mcp/index.js + package root)
  • pnpm exec biome check src tests — clean
  • Live smoke from gtm-agent eval once both PRs merge + 0.22.1 publishes

…hape

The 0.22.0 OpenAI-compat backend accepts `tools[]` + `toolChoice` but does
not auto-discover MCP tools from a parent sandbox's profile. Callers that
route through tcloud / cli-bridge / OpenRouter / OpenAI direct must hand
the model an explicit OpenAI Chat Completions `tools[]` array.

`mcpToolsForRuntimeMcp()` returns the canonical projection of the 5
delegation tools (delegate_code, delegate_research, delegate_feedback,
delegation_status, delegation_history) wired off the existing
DELEGATE_*_TOOL_NAME / DELEGATE_*_DESCRIPTION / DELEGATE_*_INPUT_SCHEMA
constants so the projection cannot drift from the server's validators.

`mcpToolsForRuntimeMcpSubset(names)` returns a curated filter for callers
that want a partial mount (e.g. read-only history without the coder queue).

Sandbox-SDK callers do not need this helper — the sandbox runtime mounts
MCP servers natively and the in-sandbox harness discovers tools via the
runtime, not the OpenAI tools array.
@drewstone
Copy link
Copy Markdown
Contributor

Obsolete — solving wrong problem. The eval gap is that it bypasses the sandbox harness entirely; the right fix is routing eval through ensureWorkspaceSandbox + streamSandboxPrompt (or running real multi-shot with inline tool execution). Closing.

@drewstone drewstone closed this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants