Home / Articles / Practical notes: Building skilled agents

This article is published in English.

Practical notes: Building skilled agents

Operable walkthrough of Practical notes: Building skilled agents: contracts, checks, and drop-in code slots for teams shipping this pattern.

2943 words

Use this as an operator-facing rebuild of the ideas in “Building skilled agents”: clear stages, ordered code slots, and recovery notes that survive a handoff. The Overview stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

What is a skill, actually?

For the What is a skill stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness.

The analogy

For the The analogy stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness.

In code

For the In code stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness. For the In code stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

skills/
└── weather-skill/
    ├── SKILL.md          # frontmatter + instructions
---
name: weather-skill
description: Get current weather for a location. Use when the user
  asks about weather, temperature, or conditions anywhere.
---

# Get weather skill

.... {other instructions here}

Let us build a light harness

When working through the Let us build a stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Log tool name, args hash, latency, and outcome for every call. Debugging agent loops without that trail wastes hours.

from dotenv import find_dotenv, load_dotenv

from langchain.agents import create_agent
from langchain.tools import tool
from langchain_openai import ChatOpenAI

_ = load_dotenv(find_dotenv())

llm = ChatOpenAI(
    model="gpt-5.6-luna",
    use_responses_api=True,
    reasoning={"effort": "low"},  #The reasoning is medium by default so set this to l
)

@tool
def get_weather(location: str) -> str:
    """
    Get the weather for a given location
    """
    return f"The weather in {location} is sunny"

@tool
def get_exchange_rate(currency_from: str, currency_to: str) -> str:
    """
    Get the exchange rate between two currencies
    """
    return f"The exchange rate for {currency_from} to {currency_to} is 1.00"

Using skills to guide tool use

When working through the Using skills to guide stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Log tool name, args hash, latency, and outcome for every call. Debugging agent loops without that trail wastes hours.

skills/
└── weather-skill/
    ├── SKILL.md
└── forex-skill/
    ├── SKILL.md
---
name: forex-skill
description: Get live exchange rates between two currencies. Use this whenever the user asks about currency conversion, exchange rates, how much something costs in another currency, or comparisons like "is the dollar strong right now" — even if they don't use the words "forex" or "exchange rate" explicitly (e.g. "how much is 500 SGD in yen", "should I exchange money now or wait"). Always use this instead of guessing from memory, since exchange rates move constantly and Claude's training data has no visibility into current rates.
---

# Forex Skill

Fetches the live exchange rate between two currencies and reports it back in a clear, practical format.

## Instructions

1. **Identify both currencies.** Convert casual references to standard 3-letter ISO codes before calling the tool (e.g. "dollars" → ask which dollar: USD, SGD, AUD, etc.; "yen" → JPY; "pounds" → GBP).
2. **Handle ambiguous currency names.** If the user says something like "dollars" or "pounds" without specifying which country, ask them to clarify before calling the tool — don't assume USD/GBP by default.
3. **Call the `get_exchange_rate` tool**, passing both currency codes:

   ```python
   get_exchange_rate(currency_from="<code>", currency_to="<code>")
   ```

4. **If the tool call fails or returns an error**, tell the user plainly that the rate lookup failed — don't fall back to guessing a rate from memory.
5. **Call once per currency pair.** For multi-currency questions (e.g. "compare SGD to USD, EUR, and JPY"), call the tool separately for each pair.
6. **Do the math for the user.** If they gave an amount ("convert 500 SGD to JPY"), multiply it out yourself using the returned rate — don't just hand back the raw rate and leave them to calculate it.

## Output format

...

## Examples

...

Experiment 1: Skills in Files

When working through the Experiment 1 Skills in stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node. When working through the Experiment 1 Skills in stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

from deepagents.backends import FilesystemBackend
from deepagents.middleware import FilesystemMiddleware, SkillsMiddleware

backend = FilesystemBackend(root_dir="../", virtual_mode=True)

agent = create_agent(
    model=llm,
    tools=[get_weather, get_exchange_rate],
    middleware=[
        SkillsMiddleware(backend=backend, sources=["./skills/"]),
        FilesystemMiddleware(
            backend=backend,
            tools=["read_file"],   # read_file and nothing else
            system_prompt=None,
        ),
    ],
)

Give it a spin

The Give it a spin stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts.

>>> agent.invoke({"messages": [HumanMessage("What is the weather in Singapore?")]})

Singapore is currently **sunny**. It's a good time for outdoor plans.

Experiment 2: Remote skills

The Experiment 2 Remote skills stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts.

from urllib.request import urlopen
from deepagents.backends import StateBackend
from deepagents.backends.utils import create_file_data

backend = StateBackend()

skill_url = "https://raw.githubusercontent.com/.../langgraph-docs/SKILL.md"
with urlopen(skill_url) as response:
    skill_content = response.read().decode('utf-8')

skills_files = {
    "/skills/langgraph-docs/SKILL.md": create_file_data(skill_content),
}

agent = create_agent(
    model= llm
    middleware=[
       SkillsMiddleware(
          backend=backend,
          sources=["./skills/"]
       ),
       FilesystemMiddleware(backend=backend)
    ]
)

result = agent.invoke(
    {
        "messages": [{"role": "user", "content": "What is langgraph?"}],

        # seeded into the in-state filesystem. needed for the first run
        "files": skills_files,
    },
)

Experiment 3: Zero tools

The Experiment 3 Zero tools stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Expose tools with narrow schemas and explicit side-effect labels. Hosts need to know which calls mutate state before they auto-approve. The Experiment 3 Zero tools stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

---
name: weather-skill
description: Get current weather for a location. Use when the user asks
  about weather, temperature, or conditions anywhere.
---

# Get weather skill

To get the weather of a location, run:

```bash
python skills/weather-skill/scripts/get_weather.py "<location>"
```

Returns JSON with weather condition. Parse and present naturally.

Run this script on each location the user asked for, one at a time.
#skills/weather-skill/get_weather.py
def main():
    location = sys.argv[1] if len(sys.argv) > 1 else None
    if not location:
        print(json.dumps({"error": "location argument required"}))
        sys.exit(1)
    print(json.dumps({"location": location, "weather": "sunny"}))

if __name__ == “__main__”:
    main()
from deepagents.backend import LocalShellBackend

backend = LocalShellBackend(
    root_dir=str(Path.cwd()),
    virtual_mode=False,
    inherit_env=True,
)

middleware = [
    FilesystemMiddleware(
        backend=backend,
        tools=["read_file", "ls", "glob", "execute"],
        system_prompt=None,
    ),
    SkillsMiddleware(backend=backend, sources=["./skills/"]),
]

agent = create_agent(model=llm, middleware=middleware)   # no tools=

Hold on. Did it actually run?

For the Hold on Did it stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness.

Today's weather:
**Sydney:** Sunny
- **Melbourne:** Sunny

The fix is logging – but not to stdout.

For the The fix is logging stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness.

from pathlib import Path
import logging

LOG = Path(__file__).resolve().parent.parent / "skill.log"
logging.basicConfig(
    filename=LOG, level=logging.INFO,
    format="%(asctime)s [pid=%(process)d] %(message)s",
)
logging.info("invoked argv=%r cwd=%s", sys.argv, os.getcwd())
22:29:55,316 [pid=45724] invoked argv=[...get_weather.py, 'Sydney']    cwd=.../notebooks
22:29:55,316 [pid=45724] resolved location=Sydney
22:29:56,795 [pid=45725] invoked argv=[...get_weather.py, 'Melbourne'] cwd=.../notebooks
22:29:56,795 [pid=45725] resolved location=Melbourne

The bug that explained the whole design

For the The bug that explained stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness. For the The bug that explained stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

What is virtual_mode?

When working through the What is virtualmode stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.

The accidental argument for the whole design

When working through the The accidental argument for stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.

So which one should you build?

When working through the So which one should stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node. When working through the So which one should stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

But do you actually need skills?

The But do you actually stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts.

Concluding Thoughts

The Concluding Thoughts stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts.

Operational checklist

When working through the Operational checklist stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest.

Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.

Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.

Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.

Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.

Before promoting the stack, freeze versions, capture a golden transcript for the critical path, and confirm rollback steps. Shared environments need rate limits, tenancy checks, and a clear owner for secret rotation. Prefer boring reliability over clever one-off demos.

Batch note for 835597b38be4: keep provider keys out of the repo, set a per-session token ceiling, and store transcripts next to the eval fixtures so later model swaps stay comparable.

When working through the hardening note 0 stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline.

Hardening detail 0/781: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.

The hardening note 1 stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.

Hardening detail 1/781: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.