A Systematic Approach to Running Agent Skills Reliably Across Heterogeneous Models

    Unstable agent skills are often a systems problem, not a prompting problem. This article explains why skills written for strong LLMs break on weaker models or different execution environments, categorizes the five common sources of hidden assumptions, and introduces a layered architecture—task semantics, capability contracts, environment adapters, and observation/fallback—to make skills portable across heterogeneous models and runtimes. It also covers how to write skills as executable specifications, shrink control flow for weaker models, run environment probes before generation, validate output formats deterministically, and measure migration stability.

    Unstable Skills Are First a Systems Problem

    Teams working with agent workflows repeatedly run into the same phenomenon: a skill that works fine on a stronger model breaks when moved to a smaller model or one with weaker instruction-following; output that is format-stable in one execution shell fails in another because of differences in paths, permissions, or tool return structures, triggering endless retries. On the surface this looks like a capability gap between models. In reality, the skill has baked a large amount of non-task logic into implicit assumptions. A strong model can patch the gaps with extra reasoning—at the cost of more tokens, more tool round trips, and longer waits. A weaker model gets stuck at the patching stage before the actual task even begins.

    Reframing this as a runtime problem makes it far more tractable. A skill is a program written in natural language. The model is a processor with non-uniform capabilities. The execution shell is the runtime that provides tools, a file system, network access, and observability. For a program to run reliably across heterogeneous processors and heterogeneous environments, it cannot rely on “cleverer prompts.” It needs an intermediate layer, analogous to a virtual machine: unified instruction semantics, explicitly declared dependencies, capability probing before execution, and outputs constrained to verifiable contracts.

    Where Hidden Assumptions Come From

    Common failures fall into five categories, which often overlap.

    Model capability assumptions. Skills assume the model can reliably perform multi-step planning, long-context retrieval, strict formatting, and self-correction. These capabilities are not at the same level across models. Pushing planning, retrieval, and formatting into a single generation means handing control flow to an unpredictable processor.

    Tool interface assumptions. Different execution shells use different names, parameters, return fields, and error codes for the same kind of action. A skill that hardcodes “call this tool and read this field” will mistake interface differences for task failures when migrated.

    Path and permission assumptions. Working directories, temp directories, relative paths, and writable scopes on the author’s machine may all be invalid elsewhere. Repeated errors and retries burn quota without advancing the task.

    Dependency environment assumptions. Scripts, interpreter versions, system libraries, and network egress are undeclared, so the shell only discovers missing items at runtime. If the model is allowed to “install it and try again,” it easily enters an unbounded repair loop.

    Output format assumptions. If downstream consumers require fixed fields, fixed order, or parseable structures but the skill only says “give a clear result,” a strong model may occasionally align while a weak model outputs prose, causing the parser to fail and feed errors back into the model.

    None of these are business goals. Leaving them to improvisation in natural language ties stability to whatever instruction-following ability the model happens to have that day.

    Isolate the Variable Parts with Layers

    Borrow the language-VM mindset without copying bytecode. A practical layering is: task semantics, capability contract, environment adapter, and observation/fallback.

    The task semantics layer describes only the business outcome, inputs, outputs, and invariants—for example, “generate a reviewable change description from the given spec and list open questions.” This layer must not contain concrete tool names, absolute paths, or shortcuts only one model understands.

    The capability contract layer declares the minimum capabilities the skill requires: whether external tools are mandatory, whether file writes are needed, coarse-grained context-window requirements, and whether output must be machine-parseable. Contracts are expressed as checkable items, not adjectives—for example, “the final answer contains four sections—status, summary, evidence citations, risks—and status may only be success, partial success, or failure.”

    The environment adapter layer maps the contract onto the current execution shell. Tool names, parameter shapes, working directories, and dependency probing live here, determined by the adapter rather than the skill body. When switching shells, replace the adapter; the skill body stays unchanged.

    The observation and fallback layer records, for each tool call, its purpose, input summary, result category, and whether the contract was satisfied. On failure, first distinguish “environment unsatisfied,” “contract unsatisfied,” and “task itself unsolvable,” then decide whether to stop, degrade, or switch to a declared alternative path. Never feed raw error messages back to the model indefinitely.

    Model differences are thus confined to “how to organize language within the contract,” environment differences are confined to the adapter, and skill authors no longer rewrite the entire text for every combination.

    Write Skills as Executable Specifications

    A portable skill should contain the following sections, kept short and strict.

    Goals and non-goals. State the completion criteria and what not to do, preventing scope creep such as modifying configs, installing undeclared components, or touching unrelated directories.

    Input schema. List required fields, optional fields, and default behavior. Missing a required field should immediately return “insufficient information” rather than guessing.

    Preconditions. Express as probe-able statements: workspace writable, required interpreter present, external dependencies listed, and how to degrade if something is missing. The default action on probe failure is to stop and report—not enter a repair loop.

    Tool usage policy. Describe only capability categories, such as “read workspace files,” “run controlled checks,” “write to a designated output.” Concrete bindings belong to the adapter. State the purpose in one sentence before each call, and extract only the fields the contract needs afterward—avoid sending large chunks of raw tool output back into the model.

    Output contract. Prefer fixed headings or lightweight structured text with stable field names, closed enum values, and no extra pleasantries. If downstream systems parse the output, provide an error structure that follows the same rules, so the parser always has a branch to take.

    Budget and stop conditions. Declare the maximum tool round trips, maximum retries, and permitted degraded results. When the budget is exceeded, return partial success with confirmed facts and reasons for incompleteness. This suits heterogeneous environments far better than “keep going until success.”

    The skeleton can be plain—boundaries matter, not prose style:

    1. Goal: produce a change description based on the input spec.
    2. Input: spec (required), constraints (optional).
    3. Forbidden: installing dependencies, modifying files outside spec, infinite retries.
    4. Steps: validate input; probe the workspace; collect evidence per contract; generate the four-section output.
    5. Output: status / summary / evidence / risks.
    6. Stop: on missing input or probe failure, status=failure; no further tool calls.

    Shrink Control Flow When Crossing Models

    The less predictable the model, the less and more explicit the control flow in the skill should be. Never write a branch as “use your judgment.” Write it as a decidable condition: input missing, probe failed, evidence insufficient, contract validation failed. Each branch has exactly one exit.

    For weaker models, split a long skill into several short skills orchestrated by the execution shell rather than asking the model to remember the whole flow. Each step consumes only the previous step’s contract output. Context per step stays shorter, and a formatting error cannot contaminate the entire process.

    For stronger models, do not drop the contract. A strong model’s advantage should go into organizing evidence and articulating edge cases—not into guessing paths and tool fields. Otherwise, the shortcuts masked by the strong model will surface all at once when you migrate.

    Probe the Environment Before Generating

    A read-only probe before execution usually costs less than a single failed retry. Keep probes generic: is the current working directory writable, can the agreed output path be created, does the declared interpreter or runtime exist, does network policy allow egress. Write results into a structured record; the skill reads only “pass / fail / unknown.”

    Dependencies must be itemized. The list only needs names and purposes—do not put install commands in the skill, which encourages the model to patch the environment on its own. If organizational policy forbids installation, the skill should degrade to “output the list of dependencies requiring manual preparation.” If artifacts go to object storage, tool traces to a log service, or failures to monitoring alerts in the cloud, those should be accessed only through the shell’s standard capabilities, avoiding hardcoded storage paths and project identifiers in the skill body.

    Put Format Validation Outside the Model

    Asking the model to “double-check its own format” is unreliable. A safer approach is deterministic validation by the execution shell after the model outputs: are all fields present, are enum values legal, do citations point to this run’s evidence. On validation failure, feed back only “which item is missing” and cap the retries—for example, one correction attempt. If it still fails, return the failure structure and let upstream decide on human intervention.

    Separating evidence from conclusions matters just as much. Evidence comes from excerpts of tool or input data; conclusions come from the model. Keep them in separate sections in the output for easy spot-checking and to avoid copying raw tool errors wholesale into the final answer.

    Measure Whether Migration Actually Got More Stable

    Do not judge a skill by a single demo. Track at least: first-pass rate, average tool round trips, share of format-related failures, share of early stops due to environment probe failures, and the proportion of partial successes. When comparing across models, use the same inputs and the same adapter version. If the pass rate rises but round trips explode, the model is still compensating for specification gaps through trial-and-error search—keep externalizing implicit steps.

    Make small, incremental regressions when changing skills: change only the contract or only the adapter, and avoid changing task semantics at the same time. An adapter change should never require rewriting the skill; a skill change should never require maintaining a separate copy per environment.

    Rollout Order

    Converge from highest risk to lowest. First, add output contracts and stop conditions to all externally facing skills—this immediately reduces parsing breakage and infinite retries. Next, move paths, dependencies, and tool names out of the skill body into adapters, and add pre-run probing. Only then optimize wording and examples. Most instability comes from undeclared environments and interfaces, not from insufficiently elegant prose.

    Once skills, models, and execution shells are treated as programs, processors, and runtime environments, the optimization goal shifts from “swap in a stronger model and hope” to “shrink implicit assumptions, make contracts explicit, and confine differences to the adapter layer.” Only then can the same skill run across heterogeneous models and environments with predictable cost and verifiable results.