Executable, Just-in-Time Micro-Docs
Design onboarding into the critical path with ultra-concise inline canonical examples and pull-based deep playbooks.
Every team has a wiki, and every wiki has a page that's partly out of date. Here it's the page for the company's own feature-flag service, and a release agent reads all of it, every session.
On a Thursday morning, the agent gets a routine request: turn on the new checkout for 10% of EU users in production. It has a tool for the flag service, update_flag. The team did the responsible thing and pasted the service's wiki page into the system prompt. All 4,000 words of it, about 5,300 tokens.
The agent's first call is update_flag(flag="checkout-v2", percentage=10, region="eu"). It fails with a 400. The second call nests the values in a rule and fails again. The third uses the wrong segment format. The fourth works. Four calls, three errors, about a minute of wall-clock time.
The same thing happened on Tuesday. And Monday. Every session starts with the full wiki in context and still opens with the same wrong call, because the agent pulled that first guess from section 2 of the wiki, "History," which shows how flags worked in v1. The correct example lives in section 7, around word 2,900.
Then one Thursday the first try succeeds. The service still accepts the old top-level percentage field for backward compatibility, and it applies that field to every region. The agent leaves out the region argument this time, the call returns ok, and the new checkout goes live for 10% of all users worldwide. That includes markets where the payment provider integration isn't ready. The on-call engineer finds out from a spike in failed payments.
Why it happens
A human engineer meets the flag service once. They read the wiki on day one, copy a snippet from a colleague, get it wrong, fix it, and by the second week the call shape is in their fingers. Their editor autocompletes the arguments. The wiki becomes something they open twice a year.
The agent never gets to week two. Every session is its first day with your tools, with no memory of yesterday's three errors or the call that finally worked. The Guide calls this condition the perpetual noviceLexicon · 09The Perpetual NoviceAn agent starting every session without accumulated interface familiarity.: a user who arrives fresh every time, no matter how often it has been here before. For this user, onboarding is no longer a tutorial you take once. It sits in the critical path of every task.
Pasting the wiki into the system prompt looks like the obvious answer to that. It is the opposite of how help works for people. Everything is loaded at turn 0, whether the session needs it or not, and the agent has to find the one relevant paragraph among 4,000 words when it finally makes the call. The alternative is to let the agent fetch documentation when it needs it, in pieces, at the moment of use. The Guide calls these two strategies push and pull contextLexicon · 43Push vs. Pull ContextUpfront pre-loaded retrieval versus just-in-time active agent foraging.. The wiki is pure push.
Jakob Nielsen's tenth usability heuristic, help and documentation, gives the human version of the rule. The best system needs no documentation at all. When some is needed, it should be easy to search, focused on the task at hand, list concrete steps, and stay short. A 4,000-word page in the prompt fails all four for an agent. It is not searchable, it covers every task at once, its steps are spread across prose, and it is long.
The real problem is distance. The agent knows what it wants: 10% of EU users in prod. It has to turn that intent into exact arguments, and every name, nesting and format is a chance to be wrong. The Guide calls that gap the gulf of invocationLexicon · 29Gulf of InvocationFriction between an agent's intent and issuing a valid call.: the distance between what the agent means to do and a call the tool will accept. A wiki narrates the service. It doesn't put a valid call next to the moment the agent has to write one.
The figure below follows both setups through the same four steps. Look at where the help sits relative to the call in each row, and which example the agent meets first.
In the top row, the closest thing to a recipe is the wrong one. Given a ready-made snippet and a paragraph of rules, an agent tends to copy the snippet. Here that means the v1 example wins over the correct rule described 2,000 words later. In the bottom row there is exactly one example, it is current, and it sits in the tool definition the agent reads when it decides to make the call.
What it costs
A tax on every session. An onboarding cost paid once is an investment. Paid every session, it's rent. The Guide's name for this is the teaching cost lawLexicon · 36The Teaching Cost LawRecurring per-session onboarding tax paid by any out-of-distribution tool.: any tool the model doesn't already know from training charges a recurring tuition, every time a fresh agent meets it. Here the tuition is 5,300 tokens of wiki in every prompt plus three failed calls, multiplied by every session that touches a flag.
Slow starts. The turns an agent spends before it does anything useful are its orientation costLexicon · 53Orientation CostTurns and tokens spent before the first productive action.. Three failed calls is three turns of orientation on a task that should take one. On a busy release day, that is latency on every flag change and noise in every trace.
Wrong actions that look right. The validation errors are the cheap failures. The expensive one is the first try that succeeds by accident through a legacy path, like the worldwide rollout in the hook. Stale examples in docs are dangerous because they still work.
Docs nobody can trust. After the incident, the natural reaction is to add more to the wiki: a warning box in section 2, a "read this first" banner, a longer prompt. Each addition makes the right paragraph harder to find. Meanwhile, a human now has to approve every flag change the agent makes.
The fix
In plain words: put the documentation where the call is made, and make it small enough to read in one glance.
- One canonical example in the tool definition, copy-ready, for the most common task.
- Constraints in the schema, as enums, ranges and formats, instead of in prose.
- Deep material behind a pull: a help tool or resource the agent calls only when the example isn't enough.
- Every example executable: it runs in CI against the real service, so it can't go stale.
The first three are the "just in time" part. The fourth is the "executable" part, and it's what stops the hook from happening again. An example that runs in a test suite fails the build when the API changes, long before an agent copies it.
Here is the update_flag definition from the hook, before and after.
name: update_flag description: | Updates a feature flag. See the Flag Service wiki for details. 1 parameters: flag: string env: string rules: array 2
- 1The description sends the agent to a 5,300-token wiki instead of teaching the call. The help is everywhere in the prompt and nowhere near the tool.
- 2An untyped array gives no hint of what a rule looks like, so the agent fills the gap from the first example it can find, which is the stale one.
name: update_flag description: | Set who sees a flag in one environment. Replaces the flag's current rules. 1 Example, 10% of EU users in prod: 2 update_flag(flag="checkout-v2", env="prod", rules=[{segment: "region:eu", percent: 10}]) More: flags_help(topic="targeting") 3 parameters: flag: string, e.g. "checkout-v2" env: "dev" | "staging" | "prod" 4 rules: list of {segment: "<kind>:<value>", percent: 0-100}
- 1Two short sentences say what the tool does and the one side effect that surprises people: rules are replaced, not merged.
- 2One complete, copy-ready call for the most common task. It is the same example the CI suite runs against the flag service on every build.
- 3The deep playbook is one call away and costs nothing until it is needed. The agent must know it exists, which is why the description names it.
- 4Allowed values live in the schema, where the agent reads them at the moment it fills in the argument.
Pin 1 is easy to skip, and you shouldn't. The description's first job is to say what the tool changes. "Replaces the flag's current rules" is the one fact that prevents a whole class of accidents, and the old description never said it.
Pin 2 does most of the work. One example beats ten paragraphs, because it shows the nesting, the field names and the value formats all at once. The agent's job shrinks from writing a call based on prose to editing a working call. Pick the task the agent does most often, and resist adding a second example until traces show the first one isn't enough.
Pin 3 is the pull. The wiki doesn't disappear. Its sections on gradual rollouts, kill switches and audit history become topics behind flags_help(topic=…), about 600 tokens each, loaded only by sessions that need them. Most sessions never call it.
Pin 4 moves constraints into the schema. The names, types and allowed values in a tool definition are cues the agent reads at the exact moment it writes the arguments. The Guide calls these cues schema affordancesLexicon · 31Schema AffordancesUsage cues communicated through tool names, parameters and types., and an enum is the cheapest one there is: it makes env: "production" impossible to guess when only "prod" exists.
The same pattern on other tools
Every tool with a non-obvious call has a wiki version and a micro-doc version. Here are the common shapes:
| Where the agent needs help | Wiki version | Micro-doc version |
|---|---|---|
| Tool description | "See the docs for usage" | One tested, copy-ready call for the top task |
| Query or filter syntax | A syntax reference in the prompt | Two example queries in the parameter description |
| Validation error | 400 invalid rule | The rejected field, plus a corrected call |
| Multi-step workflow | A runbook pasted at turn 0 | help(topic=…) returning the steps for that workflow |
| Legacy argument shape | Still accepted, documented in "History" | Rejected, with a pointer to the current shape |
The error row deserves attention. A validation error arrives at exactly the moment the agent is wrong, so it's the best-timed documentation you can ship. Give it the same treatment as the description: name what was wrong and show one call that would have worked.
The legacy row is the one that bit the hook. Backward compatibility for humans is a kindness. For an agent that copies whatever example it finds, an old shape that still succeeds is a trap. Either remove it, or make it fail loudly with the new shape in the error.
In MCP terms
Every MCP tool definition already has a slot right at the moment of the call. The MCP spec says a tool's description "can be thought of like a 'hint' to the model," and the agent reads it when it decides to call update_flag. That is where the one tested example goes.
- Tool description (
description). Put the two sentences, the example call and the pointer toflags_helphere. The spec sets no length or format, so the discipline is yours: one example, for the top task. - Property schemas (
inputSchema). Each property gets its owndescriptionand constraints:envas anenumof"dev","staging"and"prod",percentwithminimumandmaximum, andsegmentwith apatternforregion:eu-style values. - Server instructions (
instructions). Keep them to cross-tool guidance, such as where deep topics live. The spec says they "should not duplicate information already in tool descriptions," and clients may put them in the system prompt. That makes them push context, so never paste the wiki here. - Resources (
resources/read). The wiki's topics can also be resources. But resources are application-driven: the host decides what enters context. If the agent should pull a topic on its own, a help tool likeflags_helpis the version it can call. - Not in the protocol. There is no examples field. JSON Schema's
exampleskeyword is allowed ininputSchema, but nothing promises that a client shows it to the model. Put the canonical call in the description text.
Spot it in your traces
Here is a typical session from the hook, before the fix. The agent is not careless. It is reading a long document and copying the most concrete thing it can find, and the session tells you exactly where that went wrong.
- T1
update_flag(flag="checkout-v2", percentage=10, region="eu")→ 400 { "error": "unknown field: region" }The wiki's first example uses percentage. Maybe region goes in a rule.The call shape comes from the v1 example in the wiki's History section. The help nearest the top of the prompt was the stale help. - T2
update_flag(flag="checkout-v2", env="prod", rules=[{region: "eu", rollout: 0.1}])→ 400 { "error": "invalid rule" }Rules need different keys. Try segment and percent.The error names no field and shows no valid rule, so the agent goes back to scanning 5,300 tokens of prose. - T3
update_flag(flag="checkout-v2", env="prod", rules=[{segment: "eu", percent: 10}])→ 400 { "error": "unknown segment: eu" }Segments must be prefixed. The wiki mentions region:eu somewhere.Close now. The segment format is documented in one sentence of section 7. - T4
update_flag(flag="checkout-v2", env="prod", rules=[{segment: "region:eu", percent: 10}])→ { "status": "ok", "rules": 1 }The first valid call, on turn 4. Tomorrow's session starts from turn 1 again.
None of these errors is dramatic. Look at the next session, though, and the one after: the same three errors in the same order. To find this in your own logs, look for these signals:
- First-call failures that repeat across sessions. For each tool, measure how often the first call in a session fails validation and how often the third does. A high first-call failure rate that drops to zero within a few turns is the perpetual novice learning your tool from scratch, again.
- The same wrong arguments across many sessions. Group validation errors by the rejected field. When dozens of sessions send the same wrong field, it is coming from your docs, usually from an example.
- Reasoning that cites the docs right before a wrong call. Search the agent's reasoning for "the wiki says," "according to the docs" and "the example shows." Then check which passage it quoted. It is often the oldest one.
- Legacy shapes that succeed. Log every call that hits a backward-compatibility path. Each one is a stale example being copied, and some of them are doing something nobody intended.
- Docs loaded but never used. Compare the documentation in the system prompt with the tools each session actually calls. Pages loaded into every session for a tool called in a few of them are push context that should be pull.
Review checklist
Run these against every tool whose arguments aren't obvious from their names. Each check takes a few minutes, and the list pastes straight into a pull request template for new tools.
- Put one complete, copy-ready example of the most common call in the tool description.How to check Give a fresh agent only the tool definition, with no wiki in the prompt, and ask it to do the most common task. Its first call should pass validation.
- Run every documented example as a test against the real service or a sandbox.How to check Rename one parameter in a branch. The test suite should fail on the example in the tool description.
- Express allowed values in the schema as enums, ranges and formats, instead of in prose.How to check Read the input schema. Every parameter that accepts a fixed set of values should list them, and numeric fields should state their range.
- Move deep documentation behind a pull, such as a help tool or resource with named topics, and name it in the description.How to check Search the system prompt for tool manuals. Nothing longer than a few hundred tokens should be pushed for a single tool, and each description should name where to get more.
- Make validation errors name the rejected field and include one valid call.How to check Send the most common wrong call from your traces. The error should name the field and show a corrected call the agent could copy.
- Reject legacy argument shapes that the current docs no longer teach.How to check Send the old shape. It should fail with the new shape in the error, never succeed with different behavior.
- Track first-call success per tool across sessions.How to check Query a week of traces for the share of sessions whose first call to the tool passed validation. Sessions after a docs change should show it improving.
When laws collide
Micro-docs add text to tool definitions and move other text out of the prompt, so they pull against some laws and reinforce others.
- Pulls against · H-03Token Hygiene & High Observation YieldWhere they clashToken Hygiene asks every token in context to earn its place. An example in every tool description costs tokens in every session, and a server with 40 tools pays for 40 examples even when the session calls two of them.How to have bothAdd an example only where the arguments aren't obvious from their names and types. A
get_flag(flag)needs none. Keep each one to a single call for the most common task, and move everything else behind the pull. One 60-token example is still far cheaper than a 5,300-token wiki. - Works with · H-05Align with Interface PriorsHow they combineAlign with Interface Priors says to prefer shapes the model already knows from training. A micro-doc teaches whatever can't be made familiar. The more conventional the tool, the shorter its docs.What you getMake the call look like something the model has seen a thousand times, then document only the part that is truly yours. The best micro-doc is a one-line example for a tool that is already almost obvious.
- Works with · H-11Errors as Steering PromptsHow they combineA description teaches before the call. An error teaches right after a wrong one. Errors as Steering Prompts turns every failure into a corrected next call, which makes the error the best-timed micro-doc on the surface.What you getThe description carries the canonical example, and the error repeats the relevant part of it when the agent strays. Between the two, the agent is never more than one turn from a valid call, and neither one needs the wiki.
Model size changes how much documentation a tool needs. A large model may infer a sensible call from a good name and schema alone. A small, fast model leans harder on the example and is more likely to copy a stale one. A tested example in the definition serves both.
Terms from this page
- 09The Perpetual Novice
- An agent starting every session without accumulated interface familiarity.
- 43Push vs. Pull Context
- Upfront pre-loaded retrieval versus just-in-time active agent foraging.
- 29Gulf of Invocation
- Friction between an agent's intent and issuing a valid call.
- 36The Teaching Cost Law
- Recurring per-session onboarding tax paid by any out-of-distribution tool.
- 53Orientation Cost
- Turns and tokens spent before the first productive action.
- 31Schema Affordances
- Usage cues communicated through tool names, parameters and types.