The problem
How it works
Yichao “Peak” Ji explains why Manus chose to build on the in-context learning of frontier models instead of training its own model, and lists the practices the team kept. Keep the start of the prompt identical between steps (no timestamp to the second), only append to the context, serialize data deterministically and mark cache breakpoints where a provider needs them. Do not add or remove tools in the middle of a task; Manus instead uses a state machine that masks token choices, helped by tool names that share prefixes such as browser_ and shell_. Treat the sandbox file system as memory and shrink context in ways that can be undone, for example by keeping a URL or file path in place of the content. Rewrite a todo.md file as work goes on so the plan stays near the end of the context, leave failed actions and error messages visible, and add small variations so the agent does not copy its own earlier steps during repetitive batch work.
Results and limitations
Manus reports an average input-to-output token ratio of about 100 to 1 and around 50 tool calls for a typical task, and notes that with Claude Sonnet cached input cost 0.30 USD per million tokens against 3 USD uncached. It says the lessons come from repeated rewrites and real use by millions of users, and calls them patterns that worked for Manus rather than universal rules. These are vendor-reported figures without published measurements.
Before you try it
Masking token choices and prefilling responses depend on what your model provider or inference server allows; many hosted APIs only offer tool-choice settings. The cache prices are a July 2025 example and change over time. Keeping errors in the context costs tokens, and undoable compression only works if the agent can fetch the URL or file again. The post is design advice, not a benchmark. Results depend on your setup and were not independently reproduced by Top 200 Repos.
Tools and repositories
No ranked repository is involved. This use case still stands on its own source.
- Tools
- A model API or inference server with prefix caching · A sandbox with a file system the agent can use
- Prerequisites
- An agent whose prompt and tool loop you control; masking token choices needs an inference stack that supports constrained decoding or response prefill.
Try it yourself: Audit an agent loop for cache and context problems
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
Here is the system prompt, tool list and a sample trace from my agent: [Prompt, tools and sample trace]. It runs on [Model and provider]. Review it against these rules: the prompt prefix stays the same between steps, context is only appended to, serialization is deterministic, tools are not added or removed mid-task, large observations are replaced by a path or URL that can be reloaded, the current plan is restated near the end of the context, and failed actions stay visible. For each rule, say whether my agent follows it, point to the part of the trace that shows it, and suggest the smallest change that would fix it. Flag anything that would stop prompt caching from working. My main problem right now is [Main problem].Remove secrets and personal data from traces before sharing them.
Sources
- Context Engineering for AI Agents: Lessons from Building Manus (opens in a new tab)
Vendor post · manus.im · Published 18 Jul 2025 · Source checked 12 Nov 2026, 07:54 UTC
What this source supports
- Manus chose context engineering on frontier models over training an end-to-end model
- The team rebuilt its agent framework four times
- Average input-to-output token ratio in Manus is around 100 to 1
- A typical Manus task takes around 50 tool calls
- With Claude Sonnet, cached input cost 0.30 USD per million tokens versus 3 USD uncached
- Recommends a stable prompt prefix, append-only context, deterministic serialization and explicit cache breakpoints
- Masks token logits with a state machine instead of adding or removing tools mid-task
- Uses the file system as restorable memory and rewrites a todo.md file to keep goals in recent context
- Keeps failed actions in context and adds variation to avoid repetitive patterns