techlist.io

Token Optimization

3 posts

Cloudflare2026-02-122 min readCurated summary

Introducing Markdown for Agents

AI agents increasingly need structured, efficient access to web content, making traditional HTML a costly format for machine consumption. Cloudflare’s Markdown for Agents lets enabled websites serve HTML pages as Markdown when clients request `text/markdown`, reducing token usage and parsing overhead. The post argues that websites should treat AI agents as first-class visitors alongside humans and search engines. ## Why Markdown Matters for AI - Markdown conveys document structure with far less surrounding markup than HTML. - A Markdown heading such as `## About Us` uses roughly 3 tokens, compared with 12–15 tokens for an equivalent HTML heading. - The post’s HTML uses about 16,180 tokens, while its Markdown version uses approximately 3,150—a reduction of about 80%. - Converting HTML to Markdown inside an AI pipeline adds computation, cost, and complexity, and may not preserve the publisher’s intended structure. ## How Markdown for Agents Works - Cloudflare-enabled zones can respond to content negotiation requests containing: ```http Accept: text/markdown ``` - Cloudflare fetches the original HTML from the origin, converts it to Markdown at the network edge, and returns the converted response. - Clients can request Markdown with `curl`, while Workers-based agents can use a `fetch()` request with `Accept: "text/markdown, text/html"`. - Responses use `Content-Type: text/markdown` and include `Vary: accept`. - Existing coding agents, including Claude Code and OpenCode, already send compatible `Accept` headers. ## Token Estimates and Agent Workflows - Converted responses include an `x-markdown-tokens` header. - Agents can use this estimate to: - Determine whether content fits within a context window - Plan chunking strategies - Manage processing costs and limits ## Content Signals - Markdown responses include: ```http Content-Signal: ai-train=yes, search=yes, ai-input=yes ``` - These signals indicate that the content may be used for AI training, search results, and AI input, including agentic applications. - Cloudflare says future versions will support custom Content Signal policies. ## Availability - Cloudflare enabled Markdown for Agents on its Developer Documentation and Blog. - AI crawlers and agents can test the feature by requesting those pages with `Accept: text/markdown`. Web publishers can make their content more accessible to AI systems by supporting Markdown negotiation, while agents should request `text/markdown` whenever available to reduce tokens, parsing work, and processing cost.

Dropbox2025-11-173 min readCurated summary

How Dash uses context engineering for smarter AI

Dash evolved from a traditional RAG search system into an agentic AI that can interpret information, plan tasks, and act on users’ behalf. Dropbox’s experience shows that better agent performance comes not from adding more tools and data, but from carefully engineering context: limiting choices, filtering for relevance, and delegating complex work to specialized agents. The central conclusion is that precise, timely context improves reasoning speed, accuracy, and efficiency. ## From Search to Agentic AI - Dash initially combined semantic and keyword search to retrieve documents and generate concise answers. - Users began asking it to interpret, summarize, and act on retrieved information. - This required Dash to plan and execute multi-step tasks rather than simply search and summarize. - The resulting challenge was determining which information and tools the model actually needed at each stage. ## The Cost of Too Many Tools - Every tool adds descriptions and parameters to the model’s context window. - More tools expand the model’s decision space, potentially causing slower or less reliable choices. - Tool definitions also consume tokens, increasing cost and reducing room for reasoning. - Longer-running tasks suffered from “context rot,” where accumulated tool-call information degraded accuracy. - Model Context Protocol (MCP) standardizes tool descriptions, but does not eliminate the problem of excessive context. ## Limiting Tool Definitions - Dash found that exposing retrieval tools from many services—such as Confluence, Google Docs, and Jira—created confusion. - Instead of requiring the model to choose among numerous APIs, Dash consolidated retrieval into one purpose-built tool backed by its universal search index. - A single retrieval interface: - Simplifies planning - Reduces tool-selection errors - Keeps the context window focused - Provides consistent access across connected services - The same principle shaped Dash’s MCP server, which exposes retrieval through one lean tool to applications such as Claude, Cursor, and Goose. ## Filtering Context for Relevance - Retrieved information is not automatically useful for the task at hand. - Dash combines data from multiple sources in a unified index and uses a knowledge graph to connect people, activity, and content. - These relationships help rank results according to the query and the user’s context. - By filtering results before presenting them to the model, Dash ensures that each piece of supplied context is relevant. - Precomputing the index and graph allows runtime retrieval to remain fast and focused. ## Using Specialized Agents for Complex Tasks - Some tools require substantial instructions and examples to use correctly. - Dash Search became complex because query construction involves: - Understanding user intent - Mapping intent to index fields - Rewriting queries for semantic matching - Handling typos, synonyms, and implicit context - Adding these instructions directly to the main planning agent consumed context that could otherwise support broader reasoning. - Dash therefore moved search into a specialized agent: - The main agent decides when searching is necessary. - The search agent independently constructs the query using its dedicated prompt. - This division lets the main agent focus on the overall task while the specialist handles search details. Dash’s approach recommends treating context as a limited engineering resource. Use a small number of well-designed tools, pre-filter information for relevance, and delegate technically demanding subtasks to specialized agents rather than overwhelming one general-purpose model.

Anthropic2025-11-044 min readCurated summary

Code execution with MCP for efficient agents

Connecting AI agents to many tools through the Model Context Protocol (MCP) becomes inefficient at scale, because loading every tool definition upfront and passing intermediate results through the model's context window consumes large numbers of tokens. The post argues that presenting MCP servers as code APIs, which agents interact with by writing and running code, lets them load only the tools they need and process data outside the model. In the author's example, this cut token usage from about 150,000 to 2,000, a 98.7% reduction. ## Why Tool Use Becomes Expensive - **Tool definitions crowd the context window.** Most MCP clients load every tool's schema, description, and parameters into context up front. Agents connected to thousands of tools may need to process hundreds of thousands of tokens before they even read a request. - **Intermediate results pass through the model twice.** When the model moves data from one tool to another, such as copying a Google Drive transcript into a Salesforce record, the full content flows into context and then must be written out again. A two-hour meeting transcript can add around 50,000 tokens, and very large documents can exceed context limits entirely. Copying long data also increases the chance of errors. ## Presenting MCP Servers as Code - **Filesystem layout.** Each MCP server becomes a directory (e.g., `servers/google-drive/`, `servers/salesforce/`), and each tool becomes a typed TypeScript file such as `getDocument.ts` or `updateRecord.ts`, which wraps a call to `callMCPTool`. - **Workflows as scripts.** The Drive-to-Salesforce task becomes a short script that reads the document content into a variable and passes it directly to `updateRecord`, so the transcript never enters the model's context. - **Cloudflare's "Code Mode"** reached similar conclusions, based on the idea that LLMs write code well. ## Benefits of Code Execution - **Progressive disclosure.** The agent explores the directory tree to find servers and reads only the tool files it needs. Alternatively, a `search_tools` tool can return results at adjustable detail levels, such as name only, name plus description, or full schema. - **Filtering before the model sees data.** When fetching a 10,000-row spreadsheet, the script can filter for pending orders and log only a count and a sample of five rows, so the model sees a tiny fraction of the data. - **Native control flow.** Loops, conditionals, and retries run in code rather than through repeated model turns. For example, polling a Slack channel for a deployment message can happen in a single script with a sleep between checks, avoiding a model round-trip for each check. - **Privacy-preserving operations.** Intermediate results stay in the execution environment by default. An MCP client can also tokenize PII such as emails, phone numbers, and names before they reach the model, then restore the real values when data moves to the next tool. This keeps sensitive data out of the model while still letting it flow between systems, and it supports deterministic rules about where data may go. - **State persistence and reusable skills.** Agents can write intermediate files to a workspace to resume work later, and they can save working code as reusable functions. Adding a `SKILL.md` file turns these saved functions into structured skills that build up a toolbox over time. ## Trade-offs to Weigh Code execution requires a secure sandbox with resource limits and monitoring, which adds operational overhead and security concerns that direct tool calls avoid. Teams should weigh the savings in token cost, latency, and tool composition against these infrastructure costs. The author encourages anyone implementing this approach to share their findings with the MCP community.