Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/__redirects
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@
/agents/concepts/agent-class/ /agents/agent-class/internals/ 301
/agents/concepts/memory/ /agents/concepts/context/ 301
/agents/concepts/conversation-state-and-memory/ /agents/concepts/sessions/ 301
/agents/concepts/agent-skills/ /agents/concepts/skills/ 301
/agents/skills/sources/computer/ /agents/skills/sources/#workspace 301
/agents/skills/sources/r2/ /agents/skills/sources/#r2 301
/agents/skills/sources/code/ /agents/skills/sources/#code 301
/agents/getting-started/prompting/ /workers/get-started/prompting/ 301
/agents/platform/prompting/ /workers/get-started/prompting/ 301
/agents/platform/prompt.txt/ /workers/prompt.txt 301
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class MyAgent extends Think<Env> {

This release includes:

- **Three sources.** Load skills from a [Computer Workspace](/agents/skills/sources/computer/), an [R2 bucket](/agents/skills/sources/r2/), or [code](/agents/skills/sources/code/). Think lists every source again before each turn.
- **Three sources.** Load skills from a [Computer Workspace](/agents/skills/sources/#workspace), an [R2 bucket](/agents/skills/sources/#r2), or [code](/agents/skills/sources/#code). Think lists every source again before each turn.
- **The open format.** Every `SKILL.md` is checked against the [Agent Skills specification](https://agentskills.io/specification). As the specification's guide for agents recommends, a skill that breaks a rule still loads, with a logged warning. Use `parseSkill()` to check a skill before you write it.
- **Scripts in the Workspace.** Skill scripts are Workspace files, and the model runs them with the Workspace `exec` tool. Refer to [Execution](/agents/skills/execution/).
- **Skill tools for any harness.** Use the same `activate_skill` and `read_skill_resource` tools in Think, Pi Durable, or the AI SDK. Refer to [Skills tools](/agents/tools/skills/).
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/agents/agent-class/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ flowchart TD
| **Diagnostics channels** | `subscribe()`, diagnostics channels | [Diagnostics channels](/agents/runtime/observability/diagnostics-channels/) |
| **Sub-agents** | `subAgent()`, `abortSubAgent()`, `deleteSubAgent()` | [Sub-agents](/agents/agent-class/sub-agents/) |
| **Agents as tools** | `runAgentTool()`, `clearAgentToolRuns()`, `hasAgentToolRun()` | [Agents as tools](/agents/agent-class/agent-tools/) |
| **Agent Skills** | `SKILL.md` parser, Workspace, R2, and manifest sources, script runner | [Agent Skills](/agents/skills/) |
| **Skills** | `SKILL.md` parser, Workspace, R2, and manifest sources, script runner | [Skills](/agents/skills/) |
| **Sessions** | `Sessions` capability: message history, branches, compaction, search | [Sessions](/agents/runtime/capabilities/sessions/) |
| **Think** | `Think` base class, workspace tools, lifecycle hooks, extensions | [Think](/agents/harnesses/think/) |
| **Chat SDK** | `createChatSdkState()`, `ChatSdkStateAgent` | [Chat SDK](/agents/agent-class/communication-channels/chat-sdk/) |
Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/agents/concepts/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Context is everything the model is told on a request besides the conversation it

**Tool descriptions.** Each tool's name, description, and input schema. The model reads them to decide which tool to call, so they go in every request, and a long tool list costs tokens on every turn.

**Skills.** A [skill](/agents/concepts/agent-skills/) is a set of instructions and files for one kind of task. The request carries a short catalog, one line per skill, and the model loads a skill's instructions with a tool call only when a task needs them. For most agents, skills are the way to add knowledge and procedures: they cost little until they are used, and other agents can read the same skill files.
**Skills.** A [skill](/agents/concepts/skills/) is a set of instructions and files for one kind of task. The request carries a short catalog, one line per skill, and the model loads a skill's instructions with a tool call only when a task needs them. For most agents, skills are the way to add knowledge and procedures: they cost little until they are used, and other agents can read the same skill files.

**Memory.** Facts the agent saves so they outlast the conversation that taught them, such as the user's time zone or the decision made last week. The agent writes them with a tool to storage you choose, such as SQLite in the Durable Object, and they reach the model again either in the system prompt or when the agent looks them up with a search tool. Memory is not the transcript: compaction can summarize the conversation that taught a fact, and the saved fact stays as it was.

Expand Down Expand Up @@ -58,12 +58,12 @@ To see whether you are hitting the cache, read the usage the provider returns wi
## How each harness builds context

- **[Think](/agents/harnesses/think/context/)** builds its system prompt from context blocks that you declare: read-only instructions, memory the model can write, and knowledge it can search. It freezes the prompt after the first turn, refreshes it after compaction, and sends changes to the environment after the latest message. Its skill catalog is one of those blocks.
- **[Pi](/agents/harnesses/pi/extensions/)** builds its system prompt from sections that extensions add. Its [skills extension](/agents/harnesses/pi/extensions/#add-skills) adds the skill catalog as a section.
- **[Pi](/agents/harnesses/pi/extensions/)** builds its system prompt from sections that extensions add. Its [skills extension](/agents/harnesses/pi/skills/) adds the skill catalog as a section.
- **[OpenCode](/agents/harnesses/opencode/)** builds its prompt from its own configuration and the plugins you bundle.
- **Your own loop** builds the request itself. [`agents/skills`](/agents/skills/) returns a skill catalog to add to your system prompt, and the order rules in [Prompt caching](#prompt-caching) are yours to follow.

## Related

- [Sessions](/agents/concepts/sessions/): the transcript, and how it becomes a request.
- [Skills](/agents/concepts/agent-skills/): instructions and files the model loads on demand.
- [Skills](/agents/concepts/skills/): instructions and files the model loads on demand.
- [Think context](/agents/harnesses/think/context/): context blocks in Think.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Agent Skills
title: Skills
pcx_content_type: concept
description: What Agent Skills are, how agents load them through progressive disclosure, what the open SKILL.md format specifies, and what you can build with them.
description: What skills are, how agents load them through progressive disclosure, what the open Agent Skills format specifies, and what you can build with them.
tags:
- AI
sidebar:
Expand All @@ -10,9 +10,9 @@ products:
- agents
---

[Agent Skills](https://agentskills.io/) are an open format for giving an agent specialized knowledge and repeatable workflows. A skill is a folder with a `SKILL.md` file. The file holds a name, a description, and instructions for one kind of task. The folder can also hold scripts, reference documents, templates, and other files.
A skill gives an agent specialized knowledge or a repeatable workflow. Skills follow [Agent Skills](https://agentskills.io/), an open format: a skill is a folder with a `SKILL.md` file. The file holds a name, a description, and instructions for one kind of task. The folder can also hold scripts, reference documents, templates, and other files.

Agent Skills was released as an open standard. Many agents support the standard, so a skill written once works across compatible agents. The [specification](https://agentskills.io/specification) defines what goes inside a skill folder. It does not define where skills are stored or how an agent loads them.
Many agents support the format, so a skill written once works across compatible agents. The [specification](https://agentskills.io/specification) defines what goes inside a skill folder. It does not define where skills are stored or how an agent loads them.

## Why skills

Expand Down Expand Up @@ -119,19 +119,16 @@ A skill adds instructions to the agent's context, and its scripts can run code.

## Skills in the Agents SDK

The Agents SDK reads the open format in `agents/skills` and checks every `SKILL.md` against the specification. As the specification's guide for agents recommends, it loads skills that break a rule and logs a warning, so skills written for other agents still work. Skills that cannot be used, such as ones without a description, are skipped. To check a skill when you write it, parse it with `parseSkill()` and require no warnings. It loads skills from three sources:
The Agents SDK reads the format in `agents/skills` and checks every `SKILL.md` against the specification. As the specification's guide for agents recommends, it loads skills that break a rule and logs a warning, so skills written for other agents still work. Skills that cannot be used, such as ones without a description, are skipped. To check a skill when you write it, parse it with `parseSkill()` and require no warnings.

| Source | Use it when |
| ------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| [Computer Workspace](/agents/skills/sources/computer/) | Skills should be files the agent, a user, or your code can add and edit at runtime |
| [R2](/agents/skills/sources/r2/) | Many agents share one set of skills managed outside your Worker |
| [Code](/agents/skills/sources/code/) | Tests, or a small fixed set of skills that ships with your Worker |
A skill is one kind of [context](/agents/concepts/context/), and it reaches the model in two parts. The catalog, one line per skill with its name and description, goes into the system prompt. The model then loads a skill's instructions with the `activate_skill` tool and its files with `read_skill_resource`. A loaded skill comes back as a tool result, so it is part of the [session](/agents/concepts/sessions/) from then on, like any other message.

The SDK uses the `.agents/skills/` folder convention that several agents share, so `/workspace/.agents/skills/` in a Workspace holds the agent's skills. The model loads skills with the [skill tools](/agents/tools/skills/) `activate_skill` and `read_skill_resource`. With a Workspace backend, the model runs skill scripts with the Workspace `exec` tool. Refer to [Execution](/agents/skills/execution/).
`agents/skills` builds the catalog and the tools. It does not decide where the catalog goes or how often it is reloaded: each harness does. Think puts the catalog in a [context block](/agents/harnesses/think/context/) and lists the sources again before each turn. Pi adds it as a section of its system prompt when its skills extension is built.

Skills come from three kinds of [source](/agents/skills/sources/): a Computer Workspace, an R2 bucket, or code. The SDK uses the `.agents/skills/` folder convention that several agents share, so `/workspace/.agents/skills/` in a Workspace holds the agent's skills. Refer to [Execution](/agents/skills/execution/) for running skill scripts.

## Related

- [Agent Skills](/agents/skills/): use skills in Think, Pi, and the AI SDK
- [Skills](/agents/skills/): load skills into an agent with `agents/skills`
- [Skills tools](/agents/tools/skills/): add the skill tools to your harness
- [Sessions](/agents/concepts/sessions/): the transcript, where a loaded skill's instructions are kept
- [Agent Skills specification](https://agentskills.io/specification): the full format
2 changes: 1 addition & 1 deletion src/content/docs/agents/harnesses/opencode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default Plugin.define({

Import this plugin and add it to `plugins`. Refer to [OpenCode MCP transforms](https://opencode.ai/v2/docs/build/plugins/#mcp) for server configuration.

## Add an Agent Skill
## Add a skill

Register skill content through a bundled plugin:

Expand Down
27 changes: 1 addition & 26 deletions src/content/docs/agents/harnesses/pi/extensions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,32 +130,7 @@ this.registry.install({

## Add skills

`skills(sources)` from `agents/harness/pi` turns [Agent Skills](/agents/skills/) sources from `agents/skills` into a Pi extension named `agents.skills`. Sources can read skills from a [Computer Workspace](/agents/skills/sources/computer/), [R2](/agents/skills/sources/r2/), or a [manifest](/agents/skills/sources/code/). The extension has two tools, `activate_skill` and `read_skill_resource`, and a `skills` section that lists the skills. It reads the sources, so install it in an `async` factory:

```ts
import { skills } from "agents/harness/pi";
import { manifest } from "agents/skills";

const handbook = manifest({
id: "handbook",
skills: [
{
name: "release-notes",
description: "Write release notes.",
body: "One line per change.",
},
],
});

harness = new PiHarness({
harness: async ({ storage, context, onWake }) => {
this.registry.install(await skills([handbook]));
// ...models, then Harness.open() with onWake
},
});
```

The tools match the ones [Think](/agents/harnesses/think/) offers, so a skill written for one works in the other. The sources are read once, when the factory builds the extension. The model can read a skill's instructions and resources. To run skill scripts, give the model a shell or Workspace tool. Refer to [Execution](/agents/skills/execution/).
The `skills()` extension from `agents/harness/pi` adds the skill tools and a `skills` prompt section. Refer to [Skills](/agents/harnesses/pi/skills/).

## Use more of Pi Durable

Expand Down
87 changes: 87 additions & 0 deletions src/content/docs/agents/harnesses/pi/skills.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
title: Skills
pcx_content_type: how-to
description: Load skills into a Pi agent with the skills() extension from agents/harness/pi, from a Workspace, R2, or code.
sidebar:
order: 2
products:
- agents
---

import { TypeScriptExample } from "~/components";

`skills(sources)` from `agents/harness/pi` turns [skills](/agents/skills/) sources from `agents/skills` into a Pi [extension](/agents/harnesses/pi/extensions/) named `agents.skills`. Sources can read skills from a [Computer Workspace](/agents/skills/sources/#workspace), [R2](/agents/skills/sources/#r2), or a [manifest](/agents/skills/sources/#code).

:::note
Skills are experimental. This page describes `agents` v0.34.0 with Pi 1.6.
:::

## Install the extension

The extension has two tools, `activate_skill` and `read_skill_resource`, and a `skills` section in Pi's system prompt that lists each skill's name and description. It reads the sources when it is built, so install it in an `async` harness factory, before `Harness.open()`:

<TypeScriptExample filename="src/index.ts">

```ts
import { DurableObject } from "cloudflare:workers";
import { createModels } from "@earendil-works/pi-ai/models";
import { createRegistry, Harness } from "@earendil-works/pi-durable";
import { PiHarness, skills } from "agents/harness/pi";
import { Lifecycle } from "agents/lifecycle";
import { createAI } from "agents/models/pi-ai";
import { manifest, r2 } from "agents/skills";

const handbook = manifest({
id: "handbook",
skills: [
{
name: "release-notes",
description: "Write release notes.",
body: "One line per change.",
},
],
});

export class Assistant extends DurableObject<Env> {
ai = createAI({ binding: this.env.AI });
registry = createRegistry();

harness = new PiHarness({
harness: async ({ storage, context, onWake }) => {
this.registry.install(
await skills([
r2(this.env.SKILLS_BUCKET, { prefix: "skills/" }),
handbook,
]),
);
const models = createModels();
models.setProvider(this.ai.provider);
return Harness.open(
storage,
{ models, registry: this.registry, onWake },
context,
);
},
defaults: { model: this.ai("@cf/deepseek-ai/deepseek-v4.1-flash-1017") },
});

lifecycle = Lifecycle.install(this).use(this.harness);
}
```

</TypeScriptExample>

Both tools are marked `replay: "safe"`. A tool failure, such as an unknown skill or a missing file, returns `isError: true`, so the model sees the error and can try again. The extension logs problems with a source or a skill with the prefix `pi skills:`.

## When skills change

The extension reads the sources once, when the factory builds it. A skill added to the Workspace or the bucket after that is not in the catalog until the factory runs again, which happens when the object starts.

## Run skill scripts

The model can read a skill's instructions and resources. The extension has no `run_skill_script` tool. To run skill scripts, give the model a shell or Workspace tool. Refer to [Execution](/agents/skills/execution/).

## Related

- [Skills](/agents/skills/): the format, sources, and validation
- [Extensions](/agents/harnesses/pi/extensions/): install extensions in the Pi harness factory
Loading