Small Models and Agent Skills: Building Local AI Agents with POMDPs

    This article explains how small language models can power reliable, locally deployed AI agents when combined with structured Agent Skills, layered context, task routing, state management, and programmatic validation. It introduces a POMDP-based view of agent decision-making and presents an architecture for secure, auditable, and cost-controlled enterprise automation.

    In enterprise AI applications, agents have evolved from “chat models that can call tools” into complex software systems capable of understanding tasks, retrieving information, executing workflows, and continuously adjusting their strategies based on feedback. At the same time, local deployment is becoming increasingly important. Financial services, manufacturing, government, energy, and high-security research environments often require business data to remain within private networks, inference processes to be auditable, operating costs to remain manageable, and systems to run reliably over the long term.

    This raises a practical question: can Agent Skills remain effective when an agent relies on a locally deployed small language model rather than a very large model?

    The answer is not simply yes or no. Small models are often less capable in open-ended reasoning, complex planning, and long-horizon decision-making. However, with well-designed skill encapsulation, layered context, task routing, and state management, they can still handle a large amount of structured, procedural, and domain-specific work.

    The key is not to make one model do everything. Instead, an agent should be designed as a system that controls information costs, assigns tasks according to difficulty, and continuously detects and corrects errors.

    1. Why Small-Model Agents Need a Different Design

    Traditional agent implementations often place extensive tool descriptions, business rules, conversation history, and execution results into the context window at once. The model is then expected to determine the next action. This approach can work reasonably well with large models, but it quickly exposes weaknesses when used with local small models.

    First, small models have limited context comprehension. Long skill descriptions, too many available tools, or poorly organized historical records can increase the likelihood of incorrect or missed tool calls.

    Second, the inference budget is constrained by hardware. Local deployment requires trade-offs among GPU memory, system memory, throughput, and response latency. It is not always possible to increase model size or inference iterations indefinitely.

    Third, complex tasks are vulnerable to cascading errors. An incorrect skill selection at the beginning can cause subsequent retrieval, computation, and execution steps to drift away from the original objective.

    Fourth, enterprise environments require control and traceability. The system must not only produce a plausible answer. It should also explain why a skill was selected, which data was used, what actions were executed, and how the workflow can recover from failures.

    For these reasons, the primary design goal of a small-model agent should shift from “making the model smarter” to “making the system easier to control correctly.”

    2. Modeling Agent Decisions with a POMDP

    An agent usually operates in an environment that is only partially observable. The user’s intent may be incomplete, business data may be distributed across multiple systems, and the current stage of a workflow may not be immediately clear. The model can only reason from messages, historical records, and tool responses that it has already received.

    This type of problem can be modeled as a partially observable Markov decision process, or POMDP. A simplified definition includes the following elements:

    • State space S: The actual task state, which may not be directly observable. This can include the user’s goal, the current workflow stage, completed steps, facts that still require confirmation, and potential risks.
    • Observation space O: The information available to the agent, such as the user’s input, structured business fields, loaded skill descriptions, tool results, and system alerts.
    • Action space A: Actions such as selecting a skill, retrieving additional skill details, calling a tool, updating task state, asking the user a question, or submitting a final result.
    • State transitions: The task state may change after an action. For example, after data validation is completed, a task may move from “awaiting verification” to “ready for approval.”
    • Observation probabilities: Different states and actions may produce different results. A tool may time out, return no data, or provide incomplete information.
    • Reward function: A measure of task completion, result accuracy, execution cost, response latency, and security risk.

    The agent cannot directly observe the true state. Instead, it maintains a belief about the current state:

    1. b_t(s) = P(s_t = s | o_1:t, a_1:t-1)

    Here, b_t represents the estimated state at step t, o represents historical observations, and a represents previously executed actions. Whenever new information becomes available, the agent should update this belief rather than continue relying on its initial assumption.

    In practical systems, it is not necessary to calculate a complete probability distribution. A structured state representation can be used instead:

    1. {
    2. "goal": "Complete procurement application review",
    3. "current_stage": "Document verification",
    4. "confirmed_facts": [
    5. "The requesting department exists",
    6. "The budget field has been completed"
    7. ],
    8. "pending_facts": [
    9. "Whether the contract attachment is valid"
    10. ],
    11. "risk_level": "medium",
    12. "candidate_next_actions": [
    13. "Read the attachment",
    14. "Ask the user for additional information",
    15. "Submit for human review"
    16. ]
    17. }

    This type of representation reduces the memory burden on a small model and makes system behavior easier to explain and audit.

    3. An Agent Skill Is More Than a Prompt

    A reusable Skill can be viewed as consisting of three parts.

    3.1 Skill Description

    The skill description explains what problem the capability solves, what inputs it requires, what outputs it produces, and when it should not be used. It should be concise and specific. A complete business manual should not be inserted into the main context.

    For example:

    1. Skill name: Contract attachment verification
    2. Purpose: Check whether contract attachments are complete and properly formatted, and return missing items.
    3. Inputs: Application ID, attachment list
    4. Outputs: Verification result, missing items, risk warnings
    5. Limitations: Cannot determine legal validity and must not replace human approval

    3.2 Skill Policy

    The skill policy defines how execution should proceed, including prerequisites, operational steps, exception handling, and termination conditions. It can be implemented through model-driven behavior, deterministic programs, rule engines, workflows, or a combination of these components.

    For small models, high-risk and highly repetitive steps should preferably be implemented as program logic. The model can then focus on intent recognition, parameter completion, and result explanation. File-format validation, field-range checks, and permission checks should not be delegated entirely to a language model.

    3.3 References and Extensions

    A skill may need to load additional domain rules, tool specifications, or related skills. A layered reference mechanism can be used:

    • Layer 1: Keep only the skill name and a one-sentence summary.
    • Layer 2: Load input and output formats after the task matches the skill.
    • Layer 3: Load operational details, constraints, and examples immediately before execution.
    • Layer 4: Load failure-handling rules only when an exception occurs.

    This “progressive disclosure” approach can significantly reduce context length and lower the risk that a small model will be distracted by irrelevant information.

    4. Treat Information Retrieval as a Costly Action

    Many agent failures are not caused by a lack of tools. They occur because all available information is provided to the model at once. Reading skill documentation, querying a database, calling an external system, and asking the user a question should all be treated as actions with costs.

    These costs may include:

    • Context consumption;
    • Inference time;
    • Number of tool calls;
    • Data-access risk;
    • Compute usage;
    • User waiting time.

    At every step, the agent should therefore balance immediate execution against obtaining more information first.

    A simplified action-scoring function might be defined as follows:

    1. Score(a) =
    2. α × expected task benefit
    3. - β × context cost
    4. - γ × execution latency
    5. - δ × risk penalty

    When the model has sufficient confidence about the task state, it can execute an action directly. When multiple skills appear applicable or a critical parameter is missing, the agent should first retrieve more information or ask the user for clarification. When the risk is high, it should add confirmation and audit steps even if doing so reduces efficiency.

    This is a central principle for reliable small-model agents. The model does not need to perform complex reasoning at every step. It needs to recognize when it should pause, retrieve information, or request confirmation.

    5. A Local Architecture for Small-Model Agents

    A practical local agent can be divided into six layers.

    5.1 Request Ingestion Layer

    This layer receives the user request, identity information, session identifier, and authorization context. It should also perform basic input cleaning, sensitive-information detection, and request rate limiting.

    5.2 Task Parsing Layer

    This layer converts a natural-language request into a structured task containing the objective, target, constraints, time range, and expected output format. A small model does not need to generate a complex plan directly. It only needs to produce a constrained intermediate representation.

    5.3 Skill Routing Layer

    The routing layer filters a small set of candidate skills based on the task summary, skill labels, permission scope, and previous execution results. The candidate set should not be unnecessarily large, because too many options increase the difficulty of model selection.

    Routing can use a multi-stage strategy:

    1. Perform initial filtering with keywords and rules.
    2. Retrieve relevant skills using vectors or other features.
    3. Ask a small model to rank the candidate skills.
    4. Escalate high-risk tasks to a stronger model or human confirmation.

    5.4 State Management Layer

    This layer stores the workflow stage, confirmed facts, missing information, tool-call records, and error states. State should be structured whenever possible rather than relying solely on a long conversation history.

    5.5 Execution Layer

    The execution layer performs database queries, file processing, business approvals, message delivery, and other interactions with the environment. It must enforce permission isolation, parameter validation, timeout controls, and idempotent execution.

    5.6 Audit and Observability Layer

    This layer records input summaries, the reasons for skill selection, tool parameters, execution results, exception details, and final outputs. In sensitive environments, it should also record the scope of data access and the identity of the operator. At the same time, logs should avoid exposing raw sensitive content.

    6. Model Routing: Do Not Make One Model Do Everything

    A common mistake in small-model agent design is asking one model to interpret requirements, plan tasks, select tools, generate parameters, explain results, and handle exceptions at the same time. A better approach is to assign model capabilities according to task difficulty.

    A possible routing strategy is:

    • Simple classification, field extraction, and format conversion: Use a lightweight model.
    • Routine skill selection and parameter completion: Use a medium-sized model.
    • Multi-step planning, conflict resolution, and complex exception analysis: Use a stronger model.
    • Final confirmation for high-risk decisions: Use a rule engine or human approval.

    Routing conditions should not depend only on input length. They should also consider task risk, the number of available tools, state uncertainty, and historical failure rates. For example, if a task fails to call a tool successfully twice in succession, the system should automatically raise its processing level instead of allowing the small model to retry indefinitely.

    7. Key Engineering Constraints

    7.1 Tool Interfaces Must Be Strictly Structured

    Tool inputs and outputs should use stable data structures. The model should not be allowed to freely construct complex commands. Every parameter must be validated for type, range, and authorization.

    1. {
    2. "tool": "Query application status",
    3. "arguments": {
    4. "application_id": "A20250001"
    5. }
    6. }

    Tool responses should also include explicit status fields:

    1. {
    2. "success": true,
    3. "data": {},
    4. "error_code": null,
    5. "retryable": false
    6. }

    7.2 Failure Types Require Different Handling

    Network timeouts, insufficient permissions, missing data, and invalid parameters should not use the same retry strategy. The system should distinguish retryable from non-retryable errors and enforce a maximum retry count.

    7.3 Important Actions Must Be Idempotent

    Actions such as sending notifications, submitting approvals, and modifying business data may be triggered more than once when a request times out. Request IDs, operation tokens, or state checks should be used to prevent duplicate execution.

    7.4 Results Must Be Validated

    A conclusion generated by a model should not automatically be treated as fact. Amounts, dates, permissions, statuses, and compliance fields should be checked again by program logic. The model can provide explanations, while deterministic rules provide the final safeguards.

    8. How to Evaluate Whether a Small-Model Agent Is Usable

    Evaluation should not focus only on whether the final answer sounds fluent. Performance should be broken down into multiple metrics:

    • Skill-selection accuracy;
    • Parameter completion accuracy;
    • Tool-call success rate;
    • Completion rate for multi-step tasks;
    • Average number of calls;
    • Average response latency;
    • Context usage;
    • Exception recovery success rate;
    • Rate of blocked unauthorized calls;
    • Result traceability.

    The test set should include normal tasks, missing information, ambiguous requests, tool timeouts, insufficient permissions, conflicting data, and malicious inputs.

    Layered comparison experiments are also useful:

    1. Use only the model without skills.
    2. Provide complete skill descriptions.
    3. Use layered skill loading.
    4. Add structured state.
    5. Introduce routing and rule-based validation.

    By adding system components incrementally, teams can determine whether performance improvements come from increasing model size or from improving the architecture.

    9. Appropriate Boundaries and Final Takeaways

    Small models are not suitable for every type of agent task. In highly open-ended scenarios that require broad knowledge, long-horizon reasoning, and few structured tools, model scale still has a significant impact on results.

    However, small models can provide substantial value when workflows are stable, domains are well defined, tool boundaries are clear, and data should not leave the local environment. Their advantages include:

    • Lower local deployment costs;
    • Easier data isolation;
    • More predictable response latency;
    • Better auditability of task behavior;
    • More targeted optimization for specific business processes;
    • Suitability for high-concurrency and edge deployments.

    “Small models plus Agent Skills” is therefore not simply a matter of shrinking a large model. It requires redesigning how an agent works:

    • Use structured state instead of unbounded memory;
    • Use layered skills instead of verbose prompts;
    • Use routing to assign tasks according to difficulty;
    • Use programmatic validation to constrain model output;
    • Use a POMDP perspective to manage uncertainty and the cost of acquiring information.

    For enterprises, the most valuable system is not a monolithic model that can answer every question. It is a localized agent system that can complete tasks reliably under limited resources, actively seek confirmation when uncertain, provide an auditable execution process, and keep critical actions under control.