Skip to content

fix(pi): support on-demand T3 tools on completion gateways - #23685

Open
StiensWout wants to merge 5 commits into
pingdotgg:mainfrom
StiensWout:t3code/pi-gateway-tools-7a694119
Open

StiensWout wants to merge 5 commits into
pingdotgg:mainfrom
StiensWout:t3code/pi-gateway-tools-7a694119

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Pi sends the entire T3 tool catalog to OpenAI-compatible completion gateways, even when a gateway supports discovering tools on demand.

Add a Pi instance setting to opt out. Keep orchestration tools, the active loadout and tools called in retained history available after model and tree restores. Preserve the eager default for compatibility and fall back to it when native tool_search is unavailable. Pi's tool allowlists and exclusions still apply.

Refs #19190. Based on #22544, preserving Victor Vogel's contribution and correcting its restore and no-search cases. Smaller requests require Pi 0.99 or newer with built-in tool_search; start a new thread to avoid retaining an earlier eager loadout.

Verification:

  • check:changed passes 124 tests and five affected package typechecks. Two independent reviews found no blockers.
  • Seven credential-free cases through real Pi 1.4, a scripted MCP server and completion gateway cover defaults, opt-out, tool discovery, history, model/tree restores and native selectors. The five-tool fixture is a protocol check, not a production token benchmark.
  • The isolated web client verifies the switch defaults on, saves off and remains off after reload. No native mobile or desktop-shell run is claimed. Mobile sessions use the shared server setting, but mobile has no instance-config editor.

Before

No gateway tool-loading setting. Isolated fixture paths are redacted.

Pi runtime settings before the opt-out control

After

The existing provider settings form exposes the opt-out. Isolated fixture paths are redacted.

Pi gateway tool-loading switch turned off

Prepared for Wout by gpt-6.1-sol in Codex through T3 Code. Independent review also used Claude Opus 5.5.

only21mil and others added 2 commits October 22, 2026 16:26
Reuse the implementation from PR pingdotgg#22544 by Victor Vogel, rebased onto
current main. Preserve the default eager declaration policy for gateways
that cannot execute undeclared T3 tools.

Original commits:
a8ff6b1
c5751e6
7c2b8fb
Original PR head: 63a414b
Keep direct orchestration tools in called mode, preserve eager declarations without native tool_search, and document the Pi 0.99 exposure requirement. Verify native selection rules and both instance settings through the subprocess boundary.
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 22, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 22, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 41ad8cf

Macroscope's review found this PR approvable — Adds an opt-in setting for smaller completion-gateway tool requests while preserving existing eager-loading defaults. Native-discovery fallbacks and existing tool permission controls remain in place.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Pi provider adds a setting for eager tool-schema loading on OpenAI-compatible completion gateways. When disabled, and when Pi’s built-in tool_search is available, the MCP extension selects orchestration tools and T3 tools called in retained session history.

Changes: Pi gateway tool loading

Layer / File(s) Summary
Setting and launch configuration
packages/provider-pi/src/settings.ts, packages/provider-pi/src/server/mcpInjection.ts, packages/provider-pi/src/server/mcpInjection.test.ts, packages/provider-pi/src/server/adapter.ts, packages/provider-pi/src/server/adapter.test.ts, packages/provider-pi/src/server/status.test.ts, packages/provider-pi/src/server/textGeneration.test.ts
The eagerCompletionGatewayTools setting defaults to true and is passed into launch configuration. When the setting is false for an active T3 MCP session, the child environment sets T3_PI_GATEWAY_TOOLS to "called". Tests cover setting propagation and environment handling.
Gateway tool reconciliation
packages/provider-pi/src/server/mcpExtensionSource.ts, packages/provider-pi/src/server/mcpBridge.testkit.ts, packages/provider-pi/src/server/mcpExtensionSource.test.ts, docs/user/providers-pi.md
In called-tools mode, the extension selects orchestration tools and previously called T3 tools for OpenAI-completions models when built-in tool search is available. Otherwise, it retains all catalog tools. Tests cover hooks, tool selection, and cases where tool search is disabled. The provider guide describes the setting and its requirements.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PiSettings
  participant PiAdapter
  participant LaunchConfiguration
  participant McpExtension
  PiSettings->>PiAdapter: eagerCompletionGatewayTools setting
  PiAdapter->>LaunchConfiguration: pass setting to buildPiRpcLaunch
  LaunchConfiguration->>McpExtension: provide called mode when eager loading is disabled
  McpExtension->>McpExtension: select gateway tools from model and session history
Loading

Possibly related issues

  • pingdotgg/t3code#19190 — The issue describes eager activation of completion-gateway MCP tools, and this change adds an opt-out for that behavior.

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 41ad8

The new setting is off by default, so existing Pi users see no change. Users who turn it off get smaller requests on gateways that support tool_search, and the author's reported tests and runtime checks passed. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(pi): support on-demand T3 tools on completion gateways" matches the main change. The PR adds a Pi setting that lets completion gateways load T3 tools on demand through tool_search inste…
Description check Passed The description follows the template well. It states the problem (Pi sends the full T3 tool catalog to completion gateways), the change (an opt-out setting that keeps orchestration tools, the active l…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(pi): support on-demand T3 tools on completion gateways" matches the main change. The PR adds a Pi setting that lets completion gateways load T3 tools on demand through tool_search instead of receiving every tool schema. The title is a conventional commit, short, and specific to the Pi provider. It does not name the opt-out setting, but it still describes the primary behavior.

Full details: Description check

Explanation

The description follows the template well. It states the problem (Pi sends the full T3 tool catalog to completion gateways), the change (an opt-out setting that keeps orchestration tools, the active loadout, and called tools available), and scope (it refers to issue #19190 and a prior PR #22544). Verification is detailed, with test counts, manual Pi 1.4 cases, web client checks, and stated limits. Screenshots are embedded for before and after. The Problem and Change headings are brief but adequate. The Scope section does not state a bug-fix rationale explicitly, since the author frames the work as a fix and links an issue. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f0e905e and 41ad8cf.

Files selected for processing: 10

  • packages/provider-pi/src/server/adapter.test.ts
  • packages/provider-pi/src/server/adapter.ts
  • packages/provider-pi/src/server/mcpBridge.testkit.ts
  • packages/provider-pi/src/server/mcpExtensionSource.test.ts
  • packages/provider-pi/src/server/mcpExtensionSource.ts
  • packages/provider-pi/src/server/mcpInjection.test.ts
  • packages/provider-pi/src/server/mcpInjection.ts
  • packages/provider-pi/src/server/status.test.ts
  • packages/provider-pi/src/server/textGeneration.test.ts
  • packages/provider-pi/src/settings.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@maria-rcks

maria-rcks commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

Verified unchanged head f0e905efcfa18b0aae678afca779b2bae9e6fb64 on Linux with repo Playwright and Google Chrome. Created the project and threads through the web app against a real git repository. Used real Pi 1.4.0 and gpt-6.1-sol completion requests through the VM's proxy. A transparent forwarding observer recorded tool names without mocking responses.

  • Reproduced eager loading on github/main (575579d68a): no opt-out control, all 66 T3 schemas declared, orchestration call completed.
  • On this PR, the switch defaults on, saves off, and remains off after reload.
  • Fresh PR threads declared 83 T3 schemas by default and only the three orchestration schemas with the switch off. Native tool_search discovered t3_project_list; its real call returned the app-created project. Normal read also read README.md.
  • After restarting the dev server, the same thread retained the discovered schema and called it directly without another search.
  • A fresh thread with native tool_search excluded fell back to all 83 T3 schemas and completed a direct project-list call.
  • A separate native Codex gpt-6.1-sol turn read README.md and called orchestration successfully.
  • Blacksmith passed check:changed against the PR base: format, lint, knip, five package typechecks and 124 tests. The initial focused run also passed 117 tests. No source changes or pushes were needed.

Main and this older PR have different catalogs; the 83-to-3 comparison is within the PR, not a cross-version token benchmark.

Runtime request transcript

Main, same Pi runtime and gateway configuration:

main Pi settings without the gateway opt-out

PR, opt-out saved and reloaded:

PR Pi gateway opt-out saved off after reload

real Pi tool discovery and README read completed

gateway switch interaction in the real dev app

Not verified

Native iOS/Android and desktop shell, model switching and tree branching/restores, older Pi versions, and other external gateways were not exercised. Resume after a server restart was exercised. No latency or token-cost claim is made.

juliusmarminge and others added 3 commits November 12, 2026 21:53
…ls-7a694119

# Conflicts:
#	packages/provider-pi/src/server/adapter.test.ts
#	packages/provider-pi/src/server/mcpExtensionSource.ts
AI-assisted; verified with the tests and tools listed above.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
AI-assisted; verified with the tests and tools listed above.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@macroscopeapp
macroscopeapp Bot dismissed their stale review November 12, 2026 21:56

Dismissing prior approval to re-evaluate 41ad8cf

This branch has not been deployed

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

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants