Agent Harness Tutorial · End to end · Zoom level 3
Which tools the model sees
The model can only ask for tools it has been shown. So the safest place to stop a forbidden action is to never show the tool at all.
Before the first trip, the harness asks the claims system for its tools and keeps only those whose required scope is in Rohan's token. The model sees 8. The one that actually pays money, issue_payout, needs a staff scope, so the model can't even ask for it. A payout can only start through request_payout, which waits for a person above ₹25,000.
The list is kept in a stable order so the model provider can cache it. It is about 500 tokens of the prompt.
Code view: input, process, output, the call stack, the classes
Goes inThe signed-in customer's identity
What happensThe claims system lists its tools, each tool's metadata becomes a spec, and only the tools this identity's scopes allow are kept and shown to the model
Comes outA scope-filtered tool registry, and the tool definitions in each model request
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
agent_harness/tools/__init__.py:106Keep only the tools the token's scopes allow async def list_tools(self, identity: Identity) -> ToolRegistry:
"""The action surface for this identity.
MCP permits `tools/list` to vary by the authorization presented, so a
scope-filtered surface is protocol-legal rather than a local invention.
"""
with tel.span("agent.tools.list") as span:
specs, rejected = await self._transport.advertised()
visible = tuple(
s for s in specs if not s.required_scope or identity.may(s.required_scope)
)
self.rejected = rejected
span.set_attribute("agent.tools.count", len(visible))
for offered in visible: # AACP-0026: a tool on the surface nobody calls
tel.counters.tools_offered.add(1, {"tool": offered.name})
span.set_attribute("agent.tools.rejected", len(rejected))
return ToolRegistry(tools=visible)