Factory

AI Coding Agents

Guides

Token efficiency starts with smaller tool results

September 24, 2026 - 2 minute read

A tool can succeed and still give a coding agent too much to read. A repository-wide search returns unrelated matches. A connector returns an entire conversation when the task needs one decision. Every later turn may carry some of that material forward.

Token efficiency starts with filtering before the result enters the conversation. Select the relevant files, fields, or time window, then return enough surrounding context to understand the answer. Anthropic’s MCP research describes processing tool data before returning it to the model.

Keep tool results useful and bounded

Suppose a test failure names a serializer in one package. Search that package and the symbol first, keeping the matching line and nearby code. Expand to callers when the result shows a shared interface. Starting with a repository-wide dump makes unrelated matches compete with the error that prompted the investigation.

For a conversation lookup, request the relevant channel and time window around the decision. If the result belongs to a thread, include the replies needed to interpret it. Returning one isolated message can hide a later correction just as a raw conversation export can bury the answer.

Factory’s project instructions can record where important code and validation commands live. Its MCP integration connects external tools and data sources. Use the tools’ available filters and permissions so Droid receives the material needed for the task rather than an unrestricted export.

Keep the returned evidence understandable. A concise failure report should retain the command, relevant error, and affected file. Stripping those details can force a second call or send the agent down the wrong path. Smaller output is useful when it preserves the next correct action.

Factory's compression research studies a related problem, preserving information after it has entered a long session. Its findings about lost file state help explain what to retain, but they do not measure savings from filtering a tool response.

Evaluate token efficiency across the completed task

Compare total usage through accepted completion. Include retries, workers, and the follow-up calls needed to recover missing information. A smaller tool response that creates additional searches can increase the task’s overall cost.

Factory's hosted Analytics API supplies usage information separately from customer OpenTelemetry activity metrics. The customer metric catalog does not include token or cost data. For custom inference, use the relevant provider or gateway record. Keep token counts separate from billed cost because cached input and other token categories can have different prices.

For an initial experiment, change one recurring tool call or repository instruction and rerun representative tasks. Keep the model and acceptance tests stable. Preserve enough detail that another engineer can explain why the result improved or regressed.

Discuss measuring tool and context overhead in your own workflows with Factory.

Further reading

Ready to build the software of the future?

Start building

Arrow Right Icon