Flows category icon
MCP & Tooling
Intermediate

Tool Result Size Management

Stop tool outputs from flooding context: budgets per tool, smart truncation, pagination, and reference-based results.

4 steps12 verify checks60-90 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/4 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
One verbose command or giant file read can blow half my agent's context. Harness source analyses show mature agents budget every tool's output and use head+tail truncation, pagination, and result references to stay bounded.

GOAL:
Enforce output budgets across all tools with signal-preserving truncation, pagination for big result sets, and references for oversized artifacts.

REQUIREMENTS:
- A per-tool output token budget with a global default
- Head+tail truncation preserving both ends with an honest elision marker
- Pagination for list-like results (search hits, directory listings)
- Reference-based results for oversized artifacts: store, summarize, fetch-on-demand
- Truncation events logged and visible to the model

CONSTRAINTS:
- Truncation must state exactly what was omitted and how to get more
- Error-bearing regions of output (tails of failed commands) must survive truncation

DEFINITION OF DONE:
- No tool can return more than its budget regardless of input
- A failed build's error message survives truncation of the megabyte before it
- Search with thousands of hits returns page one plus retrieval instructions
- An oversized file result becomes a summary plus a working fetch reference

COMMON FAILURES TO AVOID:
- Naive head-only truncation cutting off the error at the tail
- Silent truncation the model does not know happened, breeding hallucinated completions
- No pagination, so 'list files' becomes a context bomb
- Dumping artifacts into context that should have been stored and referenced

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More MCP & Tooling flows that share ground with this one.

Flows category icon
MCP & Tooling

Deferred Tool Loading

Stop paying context for tools the task never needs: load a core set eagerly and expand the toolset on demand.

01Measure usage and pick the core
02Build the catalog and discovery
03Implement dynamic registration

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced
Flows category icon
MCP & Tooling

Build Your First MCP Server

Stand up a working MCP server exposing your own tools, connect a client, and validate the full call loop.

01Choose tools worth exposing and set up the SDK
02Implement the server and tools
03Connect a host and verify discovery

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps90-120 minutesIntermediate
Flows category icon
MCP & Tooling

Build a Repo Map for Code Navigation

Give your agent compressed, ranked codebase awareness - the tree-sitter repo-map pattern that beats raw file dumps.

01Extract symbols per file
02Rank by relevance
03Render within budget

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-150 minutesAdvanced

Made with Emergent