Skip to content

feat: return raw MCP results from workspace MCP tools - #31385

Merged
ethanndickson merged 6 commits into
codagt-1430-media-rulefrom
codagt-1430-workspace-mcp-results
Nov 10, 2026
Merged

ethanndickson merged 6 commits into
codagt-1430-media-rulefrom
codagt-1430-workspace-mcp-results

Conversation

@ethanndickson

Copy link
Copy Markdown
Member

Part of CODAGT-1430. Stacked on #31384.

Workspace MCP tool results go through the agent's convertResult, which turns an embedded resource into a [embedded resource: ...] string and drops structured content, so a PDF from a workspace MCP server never reaches the model. Remote MCP tools already go through mcpclient's converter, which keeps both.

When a call-tool request sets include_result, the agent now returns the MCP CallToolResult as-is in Result and leaves Content empty. chattool always sets it and converts the result with mcpclient.ConvertCallResult, so workspace and remote MCP tools share one converter. Older agents ignore the flag and send the legacy Content, which we adapt to MCP content and pass to the same converter. The workspace MCP docs get a short Tool results section too.

@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

CODAGT-1430

@github-actions

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@ethanndickson
ethanndickson force-pushed the codagt-1430-workspace-mcp-results branch 2 times, most recently from 546e39b to a152555 Compare November 3, 2026 06:22
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex security review

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T06:08:18.629513Z b5a25ad Manual request
🔒 Security Review ✅ Completed 2026-11-03T06:28:18.266834Z a152555 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: a152555650

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: a152555650

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ethanndickson
ethanndickson force-pushed the codagt-1430-workspace-mcp-results branch from a152555 to 76bfe6b Compare November 4, 2026 07:02
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 76bfe6bf05

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson
ethanndickson force-pushed the codagt-1430-workspace-mcp-results branch from 76bfe6b to 03826a8 Compare November 4, 2026 07:16
@ethanndickson
ethanndickson marked this pull request as ready for review November 4, 2026 07:54
@ethanndickson
ethanndickson force-pushed the codagt-1430-workspace-mcp-results branch from 03826a8 to ffaa784 Compare November 5, 2026 08:12
@ethanndickson
ethanndickson force-pushed the codagt-1430-workspace-mcp-results branch from ffaa784 to b5a25ad Compare November 9, 2026 06:04
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: b5a25ada22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/coder-agents/extending-agents.md Resolved
Comment thread docs/coder-agents/extending-agents.md Resolved
Comment thread docs/coder-agents/extending-agents.md Resolved
Comment thread docs/coder-agents/extending-agents.md Resolved
@coderagents

coderagents Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

{
"commit_id": "b5a25ada2256aa154b1473718560607599ae8c14",
"event": "COMMENT",
"body": "## Documentation Check\n\n### Blocking\n- [ ] docs/coder-agents/extending-agents.md (open) - Reframe the outdated-agent sentence so the reader can act on it.\n\n### Design notes\n- The section duplicates two sentences verbatim from docs/coder-agents/platform-controls/mcp-servers.md "Tool results", so they can drift; a single pointer would keep them in sync.\n\n

\nFindings for agents\n\nyaml\n- id: audience-1\n persona: audience\n class: rule\n blocking: true\n file: docs/coder-agents/extending-agents.md\n line: 465\n quote: \"An outdated workspace agent drops embedded resources, such as PDFs, from tool results.\"\n evidence:\n - agent/x/agentmcp/manager.go:1071-1075 (convertResult replaces EmbeddedResource with placeholder text)\n rule: docs/.style/content-guidelines.md#describe-the-current-version-for-the-end-user\n problem: The sentence frames a version-dependent behavior without telling the reader what to do about it, describing an outdated agent's behavior instead of the observable effect the reader can act on.\n fix: Reframe to the effect and the action, for example: \"An outdated workspace agent replaces embedded resources, such as PDFs, with a placeholder text, so the model does not receive the file. Update the workspace agent to deliver them.\"\n verified: true\n\n- id: consistency-1\n persona: consistency\n class: suggestion\n blocking: false\n file: docs/coder-agents/extending-agents.md\n line: 463\n quote: \"A tool result can include an image or a PDF, and the model receives it as a file.\"\n evidence:\n - docs/coder-agents/platform-controls/mcp-servers.md:188 (verbatim identical)\n - docs/coder-agents/platform-controls/mcp-servers.md:189 (verbatim identical)\n rule: null\n problem: This sentence repeats the same sentence verbatim from the \"Tool results\" section of mcp-servers.md instead of linking to it, so the two copies can drift.\n fix: Link to the existing section instead of repeating it, for example: \"For how tool results can carry images and PDFs, and the provider and size rules, refer to [Tool results](./platform-controls/mcp-servers.md#tool-results).\"\n verified: true\n\n- id: consistency-2\n persona: consistency\n class: suggestion\n blocking: false\n file: docs/coder-agents/extending-agents.md\n line: 465\n quote: \"An outdated workspace agent drops embedded resources, such as PDFs, from tool results.\"\n evidence:\n - docs/coder-agents/extending-agents.md:463-464 (calls the same content \"an image or a PDF\" / \"a file\")\n rule: docs/.style/style-guide/word-choice.md#one-term-per-concept\n problem: \"embedded resources\" is a new name for the same tool-result content the page already calls \"an image or a PDF\" / \"a file\", so the concept has two names and the reader may wonder whether they differ.\n fix: Use one name for the concept, for example: \"An outdated workspace agent drops embedded files, such as PDFs, from tool results.\"\n verified: true\n\n- id: learner-1\n persona: learner\n class: suggestion\n blocking: false\n file: docs/coder-agents/extending-agents.md\n line: 463\n quote: \"A tool result can include an image or a PDF, and the model receives it as a file.\"\n evidence:\n - coderd/x/chatd/mcpclient/mcpclient.go:1479-1489 (ConvertCallResult appends StructuredContent as JSON text)\n rule: null\n problem: The section teaches only images and PDFs, so a reader does not learn that structured content in a workspace MCP tool result is also delivered to the model, not dropped.\n fix: Add a line noting that structured content is delivered to the model as text as well, alongside the existing image/PDF guidance.\n verified: true\n\n\n
\n\n---\nAutomated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong.\n\n\n"
}

Workspace MCP tools will reuse the remote MCP result converter, so export it and drop the test-only alias.
When a call-tool request sets include_result, the agent returns the MCP CallToolResult in MCP wire format in Result and leaves Content empty. Embedded resources and structured content then reach coderd. Requests without the flag get the legacy Content response.
…lient

Workspace MCP tools now ask the agent for the raw MCP result and convert it with mcpclient.ConvertCallResult, the converter remote MCP tools use, so PDFs, embedded resources and structured content are kept. Responses from older agents carry only legacy Content, which is adapted to MCP content values and passed to the same converter.
The revive flag-parameter rule rejects a bool parameter that switches convertResult between two outputs. CallTool now picks rawResult or convertResult, and convertResult keeps its original signature.
… tool results

Workspace MCP tool results now keep embedded resources, so an image or
a PDF from a .mcp.json server reaches the model as a file. Older agents
still drop embedded resources.
@ethanndickson
ethanndickson force-pushed the codagt-1430-workspace-mcp-results branch from b5a25ad to 2eef4d2 Compare November 9, 2026 06:48
…d section

Link to the shared Tool results section instead of repeating its rules.
@ethanndickson
ethanndickson merged commit e0e6acc into main Nov 10, 2026
50 of 53 checks passed
@ethanndickson
ethanndickson deleted the codagt-1430-workspace-mcp-results branch November 10, 2026 13:06
ethanndickson added a commit that referenced this pull request Nov 10, 2026
… tool result cap (#31386)

Part of [CODAGT-1430](https://linear.app/codercom/issue/CODAGT-1430).
Stacked on #31385.

Inline and in-process MCP servers cap each tool result at 256 KiB, and
media counts at its base64 size, so a PDF over about 190 KiB becomes an
error. In-process servers are our own code running in coderd, so we'll
count only their text toward the cap, and leave their media to the 10
MiB tool media cap in chatloop. Inline servers are untrusted, so they
still count base64 media.
coder Bot added a commit that referenced this pull request Nov 10, 2026
…ment

The doc-check agent posted the raw JSON of its review request as the summary comment on #31385. Tell the agent to write the summary to its own Markdown file, give it the exact post and edit commands, and check that the comment starts with the summary heading when it reads it back.
nickvigilante pushed a commit that referenced this pull request Nov 12, 2026
…ment

The doc-check agent posted the raw JSON of its review request as the summary comment on #31385. Tell the agent to write the summary to its own Markdown file, give it the exact post and edit commands, and check that the comment starts with the summary heading when it reads it back.
nickvigilante added a commit that referenced this pull request Nov 12, 2026
…ment (#31994)

The doc-check agent posted the raw JSON of its review request as the
summary comment on #31385
([comment](#31385 (comment))),
so GitHub showed `{"commit_id": ..., "event": "COMMENT", "body": "##
Documentation Check\n..."}` with escaped newlines. The inline review on
that run posted correctly. Of the latest summary comments on 42 PRs
reviewed since 2026-10-25, this is the only malformed one.

This changes `.claude/skills/doc-check/output.md` so the agent:

- writes the review request to `review.json` and leaves the review
`body` empty, which matches what every other run does;
- writes the summary to its own `summary.md`, never reuses `review.json`
for it, and posts or edits it with exact `gh api ... -F
body=@summary.md` commands;
- checks, when it reads the comment back, that the body starts with `##
Documentation Check` and ends with the marker, and fixes it with `PATCH`
if not.

### Follow-up: workflow guard (not in this PR yet)

A workflow job that fails the run when the sticky summary comment does
not start with `## Documentation Check` is ready, but the bot that
opened this PR can't push changes under `.github/workflows/`. The patch
adds a `check-summary-comment` job (`needs: doc-check`, `pull-requests:
read`) at the end of `doc-check.yaml`, after `delete-workspace`, so it
stays clear of the hunks #31720 changes. It passed `actionlint` (with
shellcheck) and `zizmor --offline` with no findings, and a dry run
against live comments failed on #31385 and passed on #31896 and #31934.

Related open PRs: #31649 (draft) also edits `output.md`, and #31720
edits `doc-check.yaml`. Whichever lands second may need a small rebase.


Supersedes #31966, reopened under a human author for attribution.

Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com>
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