Skip to content

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

Merged
Yash-Singh1 merged 3 commits into
pingdotgg:mainfrom
StiensWout:t3code/pi-tool-media
Oct 10, 2026
Merged

Yash-Singh1 merged 3 commits into
pingdotgg:mainfrom
StiensWout:t3code/pi-tool-media

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Oct 10, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

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 a11f464 and 0b7af01.


📒 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
Loading

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 name Status Explanation
Description check Passed The 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 check Passed The title is concise, conventional, and directly describes the main change: preserving Pi tool images and structured results.
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.

✨ 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.

@Yash-Singh1
Yash-Singh1 merged commit 38c187b into pingdotgg:main Oct 10, 2026
30 checks passed
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Oct 11, 2026
## What's Changed
* fix(pi): preserve tool images and structured results by @StiensWout in pingdotgg/t3code#17851
* fix(server): Claude 5 task lists reach the tasks drawer by @Mnigos in pingdotgg/t3code#14964
* fix(web): find bar and thread details panel stop covering each other by @MatthewFeroz in pingdotgg/t3code#17858
* fix(web): use server metadata for file chip icons by @Yash-Singh1 in pingdotgg/t3code#17923
* fix(desktop): copy images from HTML previews by @Bil0000 in pingdotgg/t3code#17555
* docs(pi): update installation and remote login guidance by @StiensWout in pingdotgg/t3code#17836
* fix(pi): preserve native abort outcomes by @StiensWout in pingdotgg/t3code#17853
* fix(pi): keep thinking defaults specific to each model by @StiensWout in pingdotgg/t3code#17835
* fix(pi): preserve shell command exit codes by @StiensWout in pingdotgg/t3code#17834
* fix(pi): expire and cancel extension approvals by @StiensWout in pingdotgg/t3code#17840
* feat(pi): include native sessions in usage reports by @StiensWout in pingdotgg/t3code#17848
* fix(server): route Copilot ACP subagent output into subagent threads by @maria-rcks in pingdotgg/t3code#17714
* fix(web): composer banner titles truncate beside their icon instead of wrapping by @maria-rcks in pingdotgg/t3code#17699
* fix(server): Muse turns no longer fail on Windows by @ntindle in pingdotgg/t3code#17163
* fix(pi): allow known read-only T3 tools without approval by @StiensWout in pingdotgg/t3code#17852
* fix: worktree threads keep their worktree when the agent starts, and messages sent during setup queue by @maria-rcks in pingdotgg/t3code#17654
* fix(server): keep Claude workflows alive while they report progress by @maria-rcks in pingdotgg/t3code#17715
* fix(web): media preview centers its content and pins the close button by @maria-rcks in pingdotgg/t3code#17951
* fix(server): threads without a project no longer need Git installed by @t3dotgg in pingdotgg/t3code#17959
* fix(web): toggling tools and thinking at the bottom keeps you at the bottom by @t3dotgg in pingdotgg/t3code#17954
* fix(web): Compact chip follows Claude's real prompt cache TTL by @t3dotgg in pingdotgg/t3code#17945
* fix(usage): bound OpenCode history reads to prevent backend OOM by @Yash-Singh1 in pingdotgg/t3code#17961
* refactor: format diff line counts through one shared helper by @maria-rcks in pingdotgg/t3code#17948
* fix: new projects start their first thread in the project folder, not a worktree by @t3dotgg in pingdotgg/t3code#17371

## New Contributors
* @ntindle made their first contribution in pingdotgg/t3code#17163

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261010.2948...v0.0.46-nightly.20261011.2955

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261011.2955
github-actions Bot added a commit to davidvanderklay/t3code-flake that referenced this pull request Oct 11, 2026
## What's Changed
* fix(pi): preserve tool images and structured results by @StiensWout in pingdotgg/t3code#17851
* fix(server): Claude 5 task lists reach the tasks drawer by @Mnigos in pingdotgg/t3code#14964
* fix(web): find bar and thread details panel stop covering each other by @MatthewFeroz in pingdotgg/t3code#17858
* fix(web): use server metadata for file chip icons by @Yash-Singh1 in pingdotgg/t3code#17923
* fix(desktop): copy images from HTML previews by @Bil0000 in pingdotgg/t3code#17555
* docs(pi): update installation and remote login guidance by @StiensWout in pingdotgg/t3code#17836
* fix(pi): preserve native abort outcomes by @StiensWout in pingdotgg/t3code#17853
* fix(pi): keep thinking defaults specific to each model by @StiensWout in pingdotgg/t3code#17835
* fix(pi): preserve shell command exit codes by @StiensWout in pingdotgg/t3code#17834
* fix(pi): expire and cancel extension approvals by @StiensWout in pingdotgg/t3code#17840
* feat(pi): include native sessions in usage reports by @StiensWout in pingdotgg/t3code#17848
* fix(server): route Copilot ACP subagent output into subagent threads by @maria-rcks in pingdotgg/t3code#17714
* fix(web): composer banner titles truncate beside their icon instead of wrapping by @maria-rcks in pingdotgg/t3code#17699
* fix(server): Muse turns no longer fail on Windows by @ntindle in pingdotgg/t3code#17163
* fix(pi): allow known read-only T3 tools without approval by @StiensWout in pingdotgg/t3code#17852
* fix: worktree threads keep their worktree when the agent starts, and messages sent during setup queue by @maria-rcks in pingdotgg/t3code#17654
* fix(server): keep Claude workflows alive while they report progress by @maria-rcks in pingdotgg/t3code#17715
* fix(web): media preview centers its content and pins the close button by @maria-rcks in pingdotgg/t3code#17951
* fix(server): threads without a project no longer need Git installed by @t3dotgg in pingdotgg/t3code#17959
* fix(web): toggling tools and thinking at the bottom keeps you at the bottom by @t3dotgg in pingdotgg/t3code#17954
* fix(web): Compact chip follows Claude's real prompt cache TTL by @t3dotgg in pingdotgg/t3code#17945
* fix(usage): bound OpenCode history reads to prevent backend OOM by @Yash-Singh1 in pingdotgg/t3code#17961
* refactor: format diff line counts through one shared helper by @maria-rcks in pingdotgg/t3code#17948
* fix: new projects start their first thread in the project folder, not a worktree by @t3dotgg in pingdotgg/t3code#17371

## New Contributors
* @ntindle made their first contribution in pingdotgg/t3code#17163

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261010.2948...v0.0.46-nightly.20261011.2955

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261011.2955
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants