On-Demand Skill Loading in the Model Context Protocol

    This article explains how agents can move from a static, full tool-list approach to on-demand skill loading in the Model Context Protocol. It covers packaging domain knowledge into versioned skill packs, a three-layer loading model, context budgeting and invalidation, decoupling long-running tasks from sessions, structured in-session confirmation and authorization, by-reference passing of files and large objects, and security and multi-tenancy concerns, along with a practical rollout order for enterprise adoption.

    Early agent collaboration with external systems often relied on a “one session, full tool list, synchronous wait for results” model. This is acceptable when there are only a few tools. But once you connect retrieval, ticketing, data queries, file processing, and approval workflows at the same time, tool definitions, parameter descriptions, and examples fill up the context window. The model then struggles to focus on the current goal and is more likely to invoke irrelevant capabilities. A more reasonable direction is to separate “what can be called” from “what must be known right now”: the protocol layer maintains a capability catalog and skill packs, while the runtime loads only the part that matches the current intent.

    From Tool Lists to Skill Packs

    Tools are usually atomic operations: look up a record, send a message, change a config item. Real business rarely stops at a single call. The same domain often has terminology conventions, pre-checks, failure rollback, permission boundaries, and multi-step ordering. If this knowledge lives only in the system prompt, it is hard to reuse and bloats as the session grows.

    A skill pack can encapsulate a domain’s expert knowledge, recommended paths, and multi-step flows into a versionable unit. It does not replace tools; it tells the model which tools to use under what conditions, in what order to combine them, and which results need human confirmation. For different tenants or roles, it can also provide differentiated guidance: a read-only analysis role cannot see change-type steps, while an ops role must pass change-window validation. The key here is not to make the manual longer, but to let the manual enter the context on demand.

    On-demand loading can be organized in three layers. The first layer is the capability index, which keeps only skill names, applicable scenarios, and short trigger conditions—small enough to stay resident. The second layer is the selected skill’s operating instructions and constraints, injected after intent matching. The third layer is the specific tool’s parameter schema and return structure, expanded only when a call is imminent. Unselected skills stay outside the index to avoid irrelevant definitions interfering with planning.

    Matching should not rely on keywords alone. A more robust approach: first do a coarse filter using the current user goal, existing conversation state, and permission scope, then have the model make an explicit selection from the narrowed candidate set and record the reason for the choice. If confidence is insufficient, fall back to a clarifying question rather than reloading all skills into the context. Loading results should be observable: which skills were injected this time, how many tokens they consumed, and why other candidates were rejected—useful for later auditing and prompt tuning.

    Context Budget and Invalidation Strategy

    Context is a scarce resource. Besides skill text, historical messages, retrieval snippets, tool returns, and system constraints all compete for the same window. Engineering-wise, “skill instructions” should get a separate budget rather than being appended without limit.

    Strategies to consider: keep the index resident but capped; truncate skill text by priority, preserving constraints and steps while compressing examples; keep only a structured summary of tool returns, with large raw fields externalized; when the session grows long, unload completed skills, keeping only conclusions and traceable identifiers. Unloading is not discarding facts, but returning facts to state storage, so the model can retrieve them by identifier when needed.

    Invalidation must also be designed. After a skill version changes, an in-progress session should explicitly decide whether to continue with the old version or switch to the new one, avoiding inconsistent constraints before and after within the same task. Permission changes should immediately invalidate loaded instructions, preventing the model from continuing to plan based on outdated authorization.

    Decoupling Long Tasks from Sessions

    Synchronous tool calls assume “send request, wait for result, then think further.” Database migrations, batch validation, report generation, or cross-system orchestration often take minutes or longer. If the model waits idly, user experience suffers and connections time out; if the model keeps improvising while waiting, it may make wrong decisions based on stale state.

    A clearer model is to hand time-consuming work to a task runtime on the protocol server side. When the client submits a task, it carries the goal, input references, an idempotency key, and a completion policy, then immediately gets a task identifier and can proceed with other work that does not depend on the result. When the task finishes, fails, or needs human intervention, the client retrieves state and artifacts via events or polling.

    Tasks should at least distinguish these states: accepted, running, waiting on external conditions, succeeded, failed, canceled. Every state transition must be traceable, including time, executor, and error classification. The idempotency key prevents duplicate submission from causing double writes; cancellation should propagate downstream as much as possible, and provide compensation or a clear “cannot auto-rollback” note for side effects already produced.

    The agent flow can also be hosted as a whole: the server executes according to the step graph in the skill, and the model participates only at the planning start and key branch points. This reduces back-and-forth token consumption and keeps timeouts, retries, and concurrency control on the side better suited for engineering safeguards. The model side maintains “which task I am waiting on, and what to base continuation on after it completes,” avoiding mistaking background progress for a business fact already in effect.

    In-Session Confirmation and Authorization

    Fully automatic tool calls are often sufficient in read-only scenarios. Once payment, deletion, privilege escalation, or outbound sending is involved, the human needs to be brought back into the loop. A confirmation mechanism lets the server pause mid-step, collect confirmation, additional parameters, or explicit authorization from the user, then continue from the breakpoint—rather than letting the model fill in dangerous parameters by guessing.

    Confirmation should be structured, not open-ended long text. Common forms include: boolean confirmation, enum selection, required short fields, and one-time links that redirect to a controlled page to complete login or approval. Form fields should declare purpose, sensitivity, validation rules, and timeout. A timeout without response should enter failure or suspension, not default consent.

    High-risk actions require “intent-bound” confirmation. For example, a delete operation should require the user to review the target identifier, not just click “OK” once; before creating a resource that incurs charges, billing-related details and scope should be shown. Confirmation records must be written to the audit log: who, when, for which task, and what summary was confirmed. Link-based confirmation must be short-lived, single-use, and bound to the task identifier to prevent privilege escalation after being forwarded.

    From the model’s perspective, confirmation is a state, not a failure. The planner should be able to express “the current step is blocked on user input” and, after resumption, replay only the affected subsequent steps. Repeated pop-ups train users to click habitually, so low-risk items that a policy engine can decide automatically need not always be asked; those that cannot be decided are escalated to human confirmation.

    By-Reference Passing of Files and Large Objects

    Reading a PDF, spreadsheet, or image into the model context first and then handing it to a downstream service is usually wasteful. Files are large and varied in format, and the model often only needs to know “there is a document, where it is, and which skill will process it.” A more suitable path: the client or session store issues a short-lived accessible reference, the protocol server pulls it directly or receives the upload, and after processing returns a summary, extracted fields, or an error description.

    Four points to note in the design. First, references should carry a permission scope and expiration to avoid long-term exposure of object addresses. Second, the server must validate type, size, and malicious content, returning an actionable error on parse failure rather than pushing binary back into the conversation. Third, the model consumes only summaries and key snippets, while the raw file stays in general-purpose storage such as object storage. Fourth, when the same file is used by multiple skills, deduplicate by content identifier to prevent repeated uploads from inflating costs.

    The illustrative flow can be described with neutral pseudocode; it is not a specific vendor’s API but only expresses control relationships:

    1. on user_goal(goal, attachments):
    2. index = list_skill_index(principal=current_user)
    3. skills = select_skills(goal, index, budget="small")
    4. if needs_confirmation(skills, goal):
    5. pause_for_form(risk_summary(goal))
    6. if attachments:
    7. refs = upload_by_reference(attachments, ttl="short")
    8. task = submit_task(skills, goal, refs, idempotency_key=new_key())
    9. return task.id
    10. on task_event(task):
    11. if task.state == "needs_input":
    12. pause_for_form(task.form)
    13. if task.state == "succeeded":
    14. continue_with(task.summary)

    This logic emphasizes: index before text, files before context, long tasks return an identifier first, dangerous steps pause first.

    Security, Multi-tenancy, and Compatibility

    On-demand loading is not automatically more secure; it only shrinks the exposure surface. Skill instructions may still contain internal paths or sample data and should be isolated per tenant, prohibiting leakage of another customer’s custom guidance into the current session. Tool execution identity should be bound to user delegation and follow least privilege; background tasks inherit the delegation from submission time, not expand scope at runtime.

    The server and client should keep the protocol open: capabilities described with general semantics rather than hard-bound to a specific chat product. This way the same set of skills can be reused across different compatible clients, and enterprises need not rewrite flows for every frontend. Version negotiation, capability detection, and fallback paths should be agreed in advance—when an old client does not understand confirmation or background tasks, it should fall back to synchronous calls and clearly state the limitation, rather than silently dropping the confirmation step.

    For observability, at minimum record: skill selection hit rate, average injection size, task latency distribution, confirmation abandonment rate, and file parse failure rate. These metrics help judge whether the index is too coarse, the instructions too long, or the risk policy too strict. They are engineering measures and should not be dressed up as performance promises for a particular product.

    Rollout Order

    There is no need to do everything at once. First, change tool definitions from a resident prompt to index plus on-demand injection, and quantify the trend of context usage. Next, introduce task identifiers and status queries for long-running operations to eliminate synchronous idle waiting. Then add structured confirmation and auditing for change, delete, and payment-type actions. Finally, switch large files to reference passing so the model handles only summaries. Each step should come with permission, timeout, and failure semantics; otherwise “more flexible” becomes harder to troubleshoot.

    For enterprise users, the benefits mainly appear in three areas: the same window can hold more complete business reasoning; long-running processes no longer block the conversation; high-risk operations leave a reviewable human-machine breakpoint. These all come from the division of labor between protocol and runtime, not from piling more text into a single prompt.