Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(pi): preserve tool images and structured results #17851

MergedStiensWout(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/17851/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHub

Problem

Pi MCP image blocks were flattened to text, and native structured results were lost in tool details. Valid screenshots could also exceed the RPC record limit when Pi included model and script copies.

Change

Preserve native content and typed script output, carry images into T3's existing asset path, and size the finite record budget for the shared image limits. Collapse duplicate read text and keep structured-output omission readable.

Scope and approval

Maintainer-requested Pi support follow-up. Scope is the existing Pi MCP/tool-result boundary and its shared output consumers.

Verification

Validation: 97 Pi tests and 188 combined provider, projection, image, asset and client-detail tests passed. Pi typecheck and scoped lint/format checks passed.

Prepared for Wout by gpt-6.1-sol in Codex.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This change modifies the production Pi tool-result and RPC transport boundaries to preserve images and structured data, with a corresponding increase in the large-record memory limit. It also adds a static-analysis diagnostic suppression in the test harness, so human review is required.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 31d45ae8-a918-4c1d-b207-f19f2f145486

      📥 Commits

      Reviewing files that changed from the base of the PR and between a11f464133291122e0f6381b35e1b245d0aa9c73 and 0b7af018c6a5bb25188dee4ba6073e1f7b7a2aeb.


      📒 Files selected for processing (6)
      • 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/rpc.ts

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



      📝 Walkthrough

      Walkthrough

      The MCP bridge now preserves supported image and text content and returns structured results separately. The Pi adapter normalizes tool output with bounds on structured data. The RPC layer accepts larger records for image-bearing results.

      Changes

      MCP Tool Output and Image Transport

      Layer / File(s)Summary
      MCP result conversion and tool registration
      packages/provider-pi/src/server/mcpExtensionSource.ts, packages/provider-pi/src/server/mcpBridge.testkit.ts, packages/provider-pi/src/server/mcpExtensionSource.test.ts
      The bridge preserves supported text and image blocks, separates model-facing content from script-facing results, and exposes an output schema. Tests cover result conversion, error handling, structured-content fallback, and cancellation.
      Pi tool output normalization
      packages/provider-pi/src/server/adapter.ts, packages/provider-pi/src/server/adapter.test.ts
      The adapter retains content and distinct structured output, omits duplicate or oversized structured values, and supplies normalized output to dynamic tool items. Tests cover text, image, and structured results.
      Image-bearing RPC records
      packages/provider-pi/src/server/rpc.ts, packages/provider-pi/src/server/adapter.test.ts
      The RPC record limit now uses the shared image-output budget. Chunked transport tests cover large image results and verify that an oversized record does not block a following valid record.

      Priority: ⬇️ Low

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

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant PiRuntime
        participant MCPBridge
        participant MCPServer
        participant PiRPC
        participant Adapter
        PiRuntime->>MCPBridge: Execute registered MCP tool
        MCPBridge->>MCPServer: Send tools/call request
        MCPServer-->>MCPBridge: Return content and structured result
        MCPBridge-->>PiRuntime: Return model content and script result
        PiRuntime->>PiRPC: Emit tool result record
        PiRPC->>Adapter: Deliver framed record
        Adapter-->>PiRuntime: Provide normalized dynamic tool output

      Suggested reviewers: juliusmarminge


      Merge Risk | ⚪ Minimal · up to 0b7af

      Merge Risk: ⚪ Minimal · up to 0b7af

      The change preserves images and structured tool results and sizes the RPC record limit from the shared image budgets. No concrete merge-blocking issue was identified.

      Security Architecture Review

      Security architecture risk: 🔵 Low · up to 0b7af

      The change preserves richer tool results without changing tool permissions. Existing image restrictions and authorized asset-URL issuance remain in place. Larger accepted messages and incompletely verified recovery sequences leave some uncertainty about resource containment and result lifecycle behavior.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • observed — The changed path carries tool-controlled images and structured data into model/script results and the owning thread's stored tool output. Parsing and event buffering occur in the host process. Image retrieval uses a signed capability naming the thread, item, and image index rather than a tool-supplied arbitrary file path.

      Trust Boundaries and Controls

      • observed — The bridge retains the existing injected MCP endpoint/credential boundary, tool namespaces, exposure selection, and runtime-mode approval hook. Result preservation does not add tool registration authority or change approval decisions in the inspected comparison.
      • observed — Asset-URL issuance is reached through authenticated WebSocket RPC and requires the connection's orchestration-read scope for tool images. Retrieval verifies the signature and expiry, then reloads the referenced tool image. This establishes environment-scope authorization and signed-capability access, not deployment-specific tenant isolation.

      Resilience and Maintainability Implications

      • observed — The larger whole-record ceiling remains finite and accounts for duplicated image representations, but applies before JSON parsing and adapter normalization. The pre-existing event queue is unbounded, so downstream image and structured-storage limits do not themselves bound aggregate transport memory.

      Hardening Proposals

      • proposed — Consider a byte-aware aggregate event-buffer budget or backpressure policy alongside the enlarged per-record allowance. Define how budget exhaustion terminalizes affected work so resource protection does not silently strand tool items. This is a containment proposal, not a verified denial-of-service finding.

      Pre-merge checks | Passed 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Description checkPassedThe description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the affected Pi boundary, the main behavior changes, and the reported test and check r…
      Title checkPassedThe title is concise, conventional, and directly describes the main change: preserving Pi tool images and structured results.
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.

Sign in to join this conversation.