Skip to content

fix: include file body in get_file_contents text content - #3234

Open
Bruce-Yii wants to merge 1 commit into
github:mainfrom
Bruce-Yii:fix/get-file-contents-text-content-3189
Open

fix: include file body in get_file_contents text content#3234
Bruce-Yii wants to merge 1 commit into
github:mainfrom
Bruce-Yii:fix/get-file-contents-text-content-3189

Conversation

@Bruce-Yii

Copy link
Copy Markdown

Summary

Text-file responses from get_file_contents now carry the file body in the TextContent as well as in the embedded resource, so client surfaces that drop embedded resources still expose the file to the model.

Why

Fixes #3189. In Claude voice mode the same get_file_contents call returned only [non-text content: resource] plus the successfully downloaded text file (SHA: …) line, while text mode worked — the body lived exclusively inside the EmbeddedResource.

What changed

  • pkg/github/repositories.go: in the text-file branch of GetFileContents, append the file body to the text message (SHA line + blank line + body). Embedded resource, content order/length, and tool schema are unchanged.
  • pkg/github/repositories_text_content_test.go: regression test asserting Content[0] (TextContent) contains the body and Content[1] (resource) still carries it.
  • Untouched: binary, >=1MB resource-link, empty-file, directory, and symlink-metadata paths (symlink metadata message must stay parseable JSON).

MCP impact

  • Tool schema or behavior changed — response text now includes the file body alongside the unchanged embedded resource (additive; no schema/snapshot change).

Prompts tested (tool changes only)

  • "Read the README.md of owner/repo via get_file_contents" — text clients see the body in TextContent; resource-unwrapping clients see it in both places.

Security / limits

  • No security or limits impact — the inlined bytes are exactly the bytes already returned in the resource; the existing 1MB cap still routes large files to ResourceLink.

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with golangci-lint run ./pkg/github/ (repo config, Go 1.25.12 toolchain): 0 issues; go vet clean; git diff --check clean
  • Tested locally: new regression test failed before the fix and passes after; all Test_GetFileContents* (incl. symlink, IFC, field-filtering) pass. Full pkg/github suite shows only the pre-existing Windows-checkout failure TestAssignCopilotToIssueWithIntent, which fails identically on clean main.
  • Docs — Not needed (no tool/schema change; toolsnaps unaffected)

For text files the tool returned the body only inside the EmbeddedResource while TextContent carried just the SHA line, so client surfaces that drop embedded resources (e.g. Claude voice mode) left the model with no file content. Carry the body in TextContent as well; resource, order and schema unchanged. Binary, large-file, empty-file and symlink-metadata paths untouched.

Fixes github#3189
@Bruce-Yii
Bruce-Yii requested a review from a team as a code owner September 7, 2026 00:05
@SamMorrowDrums SamMorrowDrums added the go Pull requests that update go code label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_file_contents returns [non-text content: resource] instead of file text in Claude voice mode

2 participants