One Tool Call, 313,576 Characters: Shape What Your Agent Reads A developer measured a raw GitHub REST API response for the modelcontextprotocol/python-sdk issues endpoint at 313,576 characters, with issue bodies at 47% and full user profile objects at 16%, and argued that tool authors should shape what agents receive rather than passing API responses through. Drawing on Anthropic's guidance for writing tools for agents, the developer recommended returning only high-signal fields, adding a concise/detailed response_format parameter, paginating and truncating with explicit notices, and writing actionable error messages. "I Trimmed My Agent's Tool Results to Five Fields. It Solved More, Not Fewer." was one of the most-commented posts on DEV in the week to 22 November, with 67 comments. The title alone makes a point most of us skip: when an agent calls a tool, whatever the tool returns goes into the context, and somebody decided what that was. Often nobody decided, and the tool just passes the API response through. I wrote earlier about trimming what fills your agent's context https://dev.to/promptmaster/your-agents-context-fills-up-before-you-type-what-to-trim-first-36n0 from the user's side: check /context , disable servers, filter noisy test output. This article is for the other side, when you're the one writing the tool, whether that's an MCP server or a function in your own agent. The question is simple: what should a tool give back? Agents don't let a tool result grow forever, but the limits are a safety net, not a design. Claude Code's MCP documentation https://code.claude.com/docs/en/mcp lists them: MAX MCP OUTPUT TOKENS . So an oversized result doesn't break the session. But everything under those limits lands in the context as-is, and a result that gets moved to a file makes the agent spend another step reading it back. The size and the shape are still your job. I took a real response: the 50 most recently created open items from the GitHub REST API's issues endpoint for the modelcontextprotocol/python-sdk repository, fetched on 28 November. That endpoint also returns pull requests; 4 of the 50 were PRs. Then I measured it with a short Python script, standard library only, counting characters of the JSON. Characters, not tokens, because token counts depend on the model's tokenizer and I didn't want to guess. This is the raw response, unchanged, which is what a pass-through tool would return: raw response: 50 issues, 313,576 chars body 147,809 chars 47% user 49,854 chars 16% labels 27,502 chars 9% reactions 10,250 chars 3% title 4,732 chars 2% one 'user' object: 19 fields, 12 of them URLs, 964 chars Two things stand out. The issue bodies are almost half the size, and you rarely need all 50 of them to decide what to look at. And the user field takes 16%: each one is a full profile object with 19 fields, 12 of them URLs, when the agent needs one thing from it, the login name. The titles, which are what an agent actually reads to choose an issue, are 2%. At 313,576 characters, this single result is more than six times Claude Code's 50,000-character threshold. Returned by an MCP tool, it would be saved to a file rather than shown in the conversation. Anthropic's engineering post on writing tools for agents https://www.anthropic.com/research/writing-tools-for-agents is the clearest guide I've found on this. Four of its recommendations map directly onto the numbers above. 1. Return the fields an agent acts on. The post says tools should "return only high signal information" and avoid low-level identifiers such as uuid , 256px image url and mime type , in favour of fields like name , image url and file type . For issues, that means number, title, labels and a date, not the 12 profile URLs. 2. Let the agent ask for more detail. The post suggests a response format parameter with "concise" and "detailed" values, so the agent can get IDs and extra fields only when a follow-up call needs them. In its Slack example, the concise response used about a third of the tokens of the detailed one. 3. Page, filter and truncate by default, and say so. Its advice is "some combination of pagination, range selection, filtering, and/or truncation with sensible default parameter values," plus instructions in the response when you truncate, so the agent knows how to get the rest. 4. Write errors the agent can act on. Instead of an opaque error code or a traceback, say what was wrong with the input and what a correct one looks like. Here's the shaping part of my script. shape decides the fields; list issues adds the defaults 10 items, concise , a label filter, and a note telling the agent what to do next: python 2. Shape it: keep the fields an agent acts on, cap long text, page. def shape issue, fmt : out = {"number": issue "number" , "title": issue "title" , "labels": l "name" for l in issue "labels" , "updated": issue "updated at" :10 } if fmt == "detailed": body = issue.get "body" or "" out.update author=issue "user" "login" , comments=issue "comments" , url=issue "html url" , body=body :300 + "..." if len body 300 else "" return out def list issues fmt="concise", limit=10, page=1, label=None : pool = i for i in issues if label is None or label in l "name" for l in i "labels" start = page - 1 limit items = shape i, fmt for i in pool start:start + limit result = {"issues": items} left = len pool - start - len items if left 0: result "note" = f"{left} more issues. Call again with page={page + 1}, " "or pass label= to narrow the list." return result And the same 50 issues, shaped: detailed limit=50 50 issues, 30,509 chars concise limit=50 50 issues, 8,851 chars concise limit=10 10 issues, 1,825 chars concise label=bug 10 issues, 2,066 chars sample concise result first item + note : { "issues": { "number": 3934, "title": " v2 Use the documented middleware accessor in the tracing opt-out example", "labels": "v2" , "updated": "2026-11-26" } , "note": "40 more issues. Call again with page=2, or pass label= to narrow the list." } The detailed format, with all 50 issues and the first 300 characters of each body, is under a tenth of the raw response. The default call, 10 concise issues and a note, is 1,825 characters. Nothing here measures whether an agent does better with the smaller result. That depends on your tasks, and it's worth testing more on that below . What it shows is how much of the raw response was never chosen by anyone. Two parts of the MCP tools specification https://modelcontextprotocol.io/specification/2026-07-28/server/tools version 2026-07-28, the current one are worth knowing here. Structured content travels twice. A tool can return JSON in structuredContent , optionally validated against an outputSchema . But the spec also says "a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block." So trimming the structured result trims the text version too. There's no separate "machine-only" channel where extra fields come for free. Link instead of embedding. A tool may return a resource link , a URI the client can fetch, instead of the full content. For large files or logs, a link plus a short summary can replace pasting everything into the result. And when a large result really is necessary, Claude Code lets a tool declare it: setting meta "anthropic/maxResultSizeChars" in the tool's tools/list entry raises that tool's persist-to-disk threshold, up to a hard ceiling of 500,000 characters. The docs give database schemas and full file trees as examples. Use it for those cases, on purpose, rather than raising the limit for everything. Anthropic's post is clear that the right response structure "will vary widely by task and agent" and should be chosen from your own evaluation. A smaller result can also remove something the agent needed. The safe way to trim is to run the same small set of tasks before and after the change and compare task by task, the method from yesterday's article on testing your coding agent https://dev.to/promptmaster/is-your-coding-agent-actually-helping-test-it-on-your-own-old-fixes-hod . If a task starts failing, the field you removed was load-bearing. Put it back in the detailed format. When your tool list itself changes, this check for MCP tool changes https://dev.to/promptmaster/your-mcp-server-changed-its-tools-would-your-agent-notice-4j9a covers the other half. structuredContent lean, link large content, and declare a bigger limit only for tools that need one. Context Engineering: The Complete Guide https://promptmasterstore.gumroad.com/l/context-engineering-complete-guide?utm source=devto covers the wider discipline in 40 pages: the four core strategies Write, Select, Compress, Isolate , the anatomy of a context window and token budgets, the four failure modes context poisoning, distraction, confusion and clash and context rot, context formats and schema design, context engineering in Claude Code and Cursor, 20 reusable patterns, 12 common pitfalls, and a 30-day plan. What's the biggest tool result you've found in your own agent's context, and which field was taking the space? This article was written with the assistance of AI and reviewed by the author.