cd /news/ai-agents/lazy-load-tool-schemas-keep-authoriz… · home › topics › ai-agents › article
[ARTICLE · art-173751] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Lazy-Load Tool Schemas. Keep Authorization Eager.

A developer argues that lazy-loading tool schemas in agent systems should be kept separate from authorization, which must happen eagerly at the execution boundary after the concrete tool and arguments are known. The writeup cites Google's Tool Retrieval preview and MCP client guidance as examples of progressive discovery, and references a DEV.to experiment measuring 24,522 tokens for 200 synthetic MCP tools and 61,302 for 500 before any useful work. It proposes a policy-object flow where catalog search and schema loading produce a candidate, while a separate authorization check validates identity, scope, target and freshness immediately before execution.

recommendation

Gate every tool call with an authorization check after arguments are planned, validating identity, scope, target and freshness, and record denied calls rather than relying on catalog filtering for permissions.

more in playbook: Securing agents and AI tools
by read4 min views2 publishedNov 21, 2026

A large tool catalog creates a real context problem. every parameter schema into every request makes the agent pay for tools it will never use.

The obvious fix is to load schemas on demand. The dangerous mistake is to treat that optimization as a permission system.

A tool can be discoverable without being usable. A schema can be loaded without authorizing the requested action. Those are separate states, and production agent systems need to keep them separate.

A useful mental model has three surfaces:

The first two are about selection and context management. The third is a decision at the side-effect boundary.

Google's Tool Retrieval preview makes the separation visible in its flow: retrieval, schema , and function calling appear as distinct steps. MCP client guidance describes a similar progressive-discovery pattern—catalog, search or filter, inspect the schema, then execute—while also treating access-control filtering as a host or application concern.

That separation matters even when every step is handled by the same model. A description that helps the model find delete_customer must not become evidence that the current request may delete a customer.

For a tool-using agent, the flow should look something like this:

Stage What it does What it must not decide
Catalog Exposes searchable names and descriptions Whether an action is permitted
Search/filter Narrows the candidate set Whether the selected tool is safe to call
Schema load Supplies parameters for the selected tool Whether the caller has current authority
Authorization check Validates identity, scope, target, and freshness The tool's parameter shape
Execution Performs the approved call A new or changed action without another check
Receipt Records the decision and result That a successful call proves future permission

The important detail is where the authorization check sits: immediately before execution, after the concrete tool and arguments are known.

A permission decision made during catalog search can go stale. The user's role may have changed. A resource may have moved to a different tenant. The agent may have turned a harmless read request into a write request while filling in parameters. The call boundary is where those differences become concrete.

A minimal policy object might therefore carry the request through an explicit gate:

const candidate = await searchCatalog(query)
const schema = await loadSchema(candidate.toolName)
const args = await planArguments(schema, task)

const decision = await authorize({
  identity: session.identity,
  tool: candidate.toolName,
  args,
  target: resolveTarget(args),
  scope: session.scope,
})

if (!decision.allowed) {
  return recordDeniedCall(decision)
}

return executeAndRecord(candidate.toolName, args, decision)

This is a proposed shape, not a tested implementation. Its value is the boundary: discovery produces a candidate, while authorization produces a current decision tied to the actual call.

The context cost is not theoretical. One DEV.to experiment reported 24,522 tokens for 200 synthetic MCP tools and 61,302 for 500 before the agent did useful work. The same author found that a real file server used more tokens per tool than the synthetic set.

Those numbers are measurements from one setup, not a universal budget or a benchmark reproduced here. They still point to the right engineering question: how much of the request is being spent describing tools that will not be selected?

Schema deferral can reduce that menu overhead by keeping lightweight metadata available and full definitions only for plausible candidates. It also makes the retrieval decision observable. If the trace distinguishes search, schema load, and function call, operators can see whether an agent is failing because it cannot find a tool, cannot form valid arguments, or cannot pass authorization.

Do not collapse all costs into “tool overhead,” though. Tool definitions, retrieved results, conversation history, and an extra retrieval turn are different surfaces. A progressive-discovery design can reduce one while increasing another through additional latency or model calls.

For a small, stable catalog, eager may still be the simpler and faster choice. Switch to progressive discovery when measurements show that definitions consume a meaningful share of context, not because lazy sounds more sophisticated.

A discovery-first design needs negative tests, not just a happy path.

At minimum, log the discovered candidate, the concrete requested action, the authorization decision, and the execution result as separate events. Test revocation between discovery and execution. Make denial explicit and auditable rather than returning a generic tool error.

Keep the catalog simple until it becomes expensive. When it does, make schema progressive—but keep authorization eager.

The useful boundary is not “the model may see this tool.” It is “this exact identity may perform this exact action against this exact target under the current policy.” Tool retrieval helps answer the first question. It does not answer the second.

That distinction is small in a diagram and decisive in production. Optimize context at discovery time. Recompute authority at execution time. Record both decisions so the next failure is diagnosable.

The workflow and code are proposals, not hands-on test results. The reported token figures are retained as the source author's measurements, not as benchmarks from this article.

── more in #ai-agents 4 stories · sorted by recency
── more on @google 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/lazy-load-tool-schem…] indexed:0 read:4min 2026-11-21 · —