Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(mcp): support thread attachments #8700

Closedjuliusmarmingewants to merge 13 commits intot3code/codex-turn-mapping fromagents/mcp-queue-inputs/attachmentsopened View on GitHub

juliusmarmingecommented

Problem

MCP thread creation and send paths discarded attachments even though V2 already supports thread-scoped attachment claims.

Change

  • Add a signed pending-upload preparation tool and bounded ready-to-send attachment references.
  • Accept attachment references on thread creation and send without embedding file bytes in MCP results.
  • Reuse the existing attachment store, claim, provider capability, and V2 dispatch paths.
  • Recover accepted start/send receipts before mutable upload checks and retain claims on accepted or uncertain outcomes.

Behavior

Uploads use the existing POST route and bearer URL. New operations validate ownership, MIME support, and provider capability before creating a thread. Accepted retries return the original message and run identity after the pending upload disappears, while unused replay copies are cleaned up. OpenCode keeps path fallback behavior and Antigravity accepts image attachments only.

Validation

  • 63 focused attachment, MCP, ThreadLaunch, ThreadManagement, receipt-replay, contract, and presentation tests.
  • Scoped @t3tools/contracts, @t3tools/shared, and t3 typechecks.
  • Formatting and type-aware lint for all changed files.

Base

Standalone PR on t3code/codex-turn-mapping at 415ed0f73b97f1655b6282492f81d0b2bba3a9cc.

Implemented by GPT-5.6-Sol via Codex in T3 Code.

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 7c62e49a-4968-46bc-a1ba-91b5d2c332f8

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Warning

      Your free Security trial is over. An organization admin can activate Security or dismiss this notice.


      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ⚠️ The latest CI run did not produce a thread transfer result for 6991ca7.

      This comment will update automatically after the next completed run.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High orchestration-v2/orchestrator-mcp-server.md:320

      The documented prepare-then-send flow is rejected because t3_attachment_prepare_upload returns attachmentId, while create_threads, t3_thread_start, and t3_thread_send require ChatAttachment.id; passing the returned metadata leaves id absent. Document constructing { id: attachmentId, type, name, mimeType, sizeBytes } before passing the attachment.

      it constructs `{ id: attachmentId, type, name, mimeType, sizeBytes }` from the returned metadata and passes that attachment to `create_threads`, `t3_thread_start`, or `t3_thread_send`.
      Also found in 1 other location(s)

      packages/contracts/src/attachmentMcp.ts:38

      AttachmentMcpPrepareUploadResult returns the identifier as attachmentId, but every new orchestration attachments input uses ChatAttachment, which requires that same field to be named id. Thus the prepare result cannot be supplied as an attachment reference without an undocumented manual rename: passing its returned metadata leaves the required id absent and the start/send/create schema rejects it. Return id (or make the consumer schema accept attachmentId) so the advertised prepare-then-send flow composes.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @docs/orchestration-v2/orchestrator-mcp-server.md around line 320:
      
      The documented prepare-then-send flow is rejected because `t3_attachment_prepare_upload` returns `attachmentId`, while `create_threads`, `t3_thread_start`, and `t3_thread_send` require `ChatAttachment.id`; passing the returned metadata leaves `id` absent. Document constructing `{ id: attachmentId, type, name, mimeType, sizeBytes }` before passing the attachment.
      
      Also found in 1 other location(s):
      - packages/contracts/src/attachmentMcp.ts:38 -- `AttachmentMcpPrepareUploadResult` returns the identifier as `attachmentId`, but every new orchestration `attachments` input uses `ChatAttachment`, which requires that same field to be named `id`. Thus the prepare result cannot be supplied as an attachment reference without an undocumented manual rename: passing its returned metadata leaves the required `id` absent and the start/send/create schema rejects it. Return `id` (or make the consumer schema accept `attachmentId`) so the advertised prepare-then-send flow composes.
      
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds a substantial production MCP attachment workflow spanning upload authorization, filesystem claims, orchestration retries, contracts, and provider adapters. An unresolved provider-delivery concern and newly added static-analysis suppression directives make human review necessary.

      No code changes detected at 6991ca7. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Fixed in 79af386cd3. The prepare result now includes an explicit attachment object whose id is the issued attachmentId; tool/docs say to pass that object unchanged. The real MCP/V2 integration does exactly that after uploading through the signed route.

    7. apps/server/src/mcp/OrchestratorMcpService.ts line 198OutdatedResolvedby juliusmarminge
    8. Stale Bugbot comment from a previous run.

    9. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High mcp/OrchestratorMcpService.ts:911

      A driver-only child-task request selects an unavailable inherited provider and returns provider_unavailable even when another runnable instance for that driver exists. inheritedCandidate is chosen without checking its constraints, so use it only when it is runnable before falling back to availableCandidate.

      No longer relevant as of 3839f6446d6bee93f1e34dea46c2c815bdf2e234

    10. UI consistency review

      One concrete regression found: the shared markdown renderer now resolves its environment-scoped actions from the globally active environment instead of explicit scope.

      Everything else in the changed web UI (panel/toolbar displayMode variants, ThreadDetailsPanel shared style constants, PopoverPopup positioner props) stays within the shared primitive contracts, and no apps/web/src CSS changed in this PR.

      Posted via Macroscope — UI Consistency
      apps/web/src/components/ChatMarkdown.tsx lines 1633 to 1634OutdatedResolvedby juliusmarminge
    11. Reviewed the new/changed Effect service code in this PR (AttachmentMcpService, the attachment toolkit, OrchestratorMcpService, ThreadManagementService, Orchestrator). One convention deviation found; everything else (namespace imports, inline Context.Service interface, environment-based dependency acquisition, structured Schema.TaggedErrorClass failures with derived messages and preserved cause) matches the conventions.

      Posted via Macroscope — Effect Service Conventions
    12. Verified as inherited from pinned trunk 490318afa505: the inheritedCandidate/availableCandidate selection block is byte-for-byte identical there, and #8700 only shifts its line number through attachment additions. This valid provider-selection issue is outside the attachment concern and is preserved for upstream follow-up rather than broadening this PR.

    13. Effect service conventions review: one import-convention deviation in the new MCP attachment test. Everything else (new AttachmentMcpService tag/make/layer shape, environment-based dependency acquisition, and the new ThreadManagementPostDispatchProjectionError structural error with derived message and preserved cause) matches the repository conventions.

      Posted via Macroscope — Effect Service Conventions
    14. Effect service conventions review: one finding on the new OrchestratorV2Shape.getCommandReceipt signature.

      Posted via Macroscope — Effect Service Conventions
    15. apps/server/src/mcp/AttachmentMcpService.ts line 141Resolvedby juliusmarminge
    16. Effect service conventions review: one finding on the new transformEventSink type signatures in the replay harness.

      Posted via Macroscope — Effect Service Conventions
    17. Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

      Fix All in Cursor Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot), but a cloud agent failed to start. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit da38dd1480539520585bdde1455d26eecd413782. Configure [here](https://www.cursor.com/dashboard/bugbot).
      apps/server/src/mcp/OrchestratorMcpService.ts line 185Resolvedby juliusmarminge
    18. Bugbot is paused — on-demand spend limit reached

      Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

      A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

    19. Superseded as the active MCP proposal by #10564 in the rebuilt MCP stack, following the maintainer request to review thin service wrappers separately from service hardening.

      This is not a full feature-parity replacement. t3_thread_send remains unchanged. The new t3_thread_send_attachments checks target ownership and permission ceilings. Each call is a new message; claimed files are retained when dispatch outcome is uncertain. Provider support stays in adapters, and no keyed replay protocol is added.

      Closing this mixed proposal without merging. The remote branch agents/mcp-queue-inputs/attachments and exact head 6991ca726981ad8a608484beffd0dd76c9bef020 are retained so the service changes can be extracted for separate review later.

    20. juliusmarminge closed this

Sign in to join this conversation.