|
1 | 1 | --- |
2 | | -title: Quickstart |
3 | | -description: "Set up long-term skill for your agent in 3 steps" |
| 2 | +title: "What is Long-term Skill" |
| 3 | +description: "Persistent agent memory stored as structured skill files — filesystem-compatible, configurable, and human-readable" |
4 | 4 | --- |
5 | 5 |
|
6 | | -Create a learning space, run your agent, and Acontext automatically builds long-term skills from completed tasks. |
| 6 | +Long-term skill is Acontext's approach to persistent agent memory: your agents store memory as **skill files** — plain markdown organized by configurable schemas you control. |
| 7 | + |
| 8 | +``` |
| 9 | +Session messages ──► Task extraction |
| 10 | + └► Learner ──► Skill files |
| 11 | + ┌─────────────────────┘ |
| 12 | + ▼ |
| 13 | + social-contacts/ |
| 14 | + ├── SKILL.md (your schema) |
| 15 | + ├── alice-chen.md (learner-created) |
| 16 | + └── bob-martinez.md (learner-created) |
| 17 | +``` |
| 18 | + |
| 19 | +## Quickstart |
7 | 20 |
|
8 | 21 | <Steps> |
9 | 22 | <Step title="Create a learning space and run a session"> |
@@ -48,7 +61,7 @@ await client.sessions.storeMessage(session.id, { role: "user", content: "My name |
48 | 61 | </CodeGroup> |
49 | 62 |
|
50 | 63 | <Note> |
51 | | -Call `.learn()` before the agent runs. When tasks complete during the session, Acontext automatically picks them up for learning. |
| 64 | +Call `.learn()` before the agent runs. When [tasks](/observe/agent_tasks) complete during the session, Acontext automatically picks them up for learning. A **task** is a unit of work the agent completes — Acontext extracts them from session messages automatically. |
52 | 65 | </Note> |
53 | 66 | </Step> |
54 | 67 |
|
@@ -115,16 +128,117 @@ for (const skill of skills) { |
115 | 128 | } |
116 | 129 | ``` |
117 | 130 | </CodeGroup> |
| 131 | +</Step> |
| 132 | + |
| 133 | +<Step title="Use learned skills in your agent"> |
| 134 | + |
| 135 | +Give your agent access to the learned skills via [Skill Content Tools](/tool/skill_tools). The agent can then look up what it learned in previous sessions: |
| 136 | + |
| 137 | +<CodeGroup> |
| 138 | +```python Python |
| 139 | +from acontext.agent.skill import SKILL_TOOLS |
| 140 | +from openai import OpenAI |
| 141 | +import json |
| 142 | + |
| 143 | +openai_client = OpenAI() |
| 144 | + |
| 145 | +# Get skill IDs from the learning space |
| 146 | +skills = client.learning_spaces.list_skills(space.id) |
| 147 | +skill_ids = [s.id for s in skills] |
| 148 | + |
| 149 | +# Give the agent access to those skills |
| 150 | +ctx = SKILL_TOOLS.format_context(client, skill_ids) |
| 151 | +tools = SKILL_TOOLS.to_openai_tool_schema() |
| 152 | + |
| 153 | +messages = [ |
| 154 | + {"role": "system", "content": f"You have access to skills from past sessions.\n\n{ctx.get_context_prompt()}"}, |
| 155 | + {"role": "user", "content": "Do you know my name?"} |
| 156 | +] |
| 157 | + |
| 158 | +while True: |
| 159 | + response = openai_client.chat.completions.create( |
| 160 | + model="gpt-4.1", messages=messages, tools=tools |
| 161 | + ) |
| 162 | + message = response.choices[0].message |
| 163 | + messages.append(message) |
| 164 | + |
| 165 | + if not message.tool_calls: |
| 166 | + print(f"Assistant: {message.content}") |
| 167 | + break |
| 168 | + |
| 169 | + for tc in message.tool_calls: |
| 170 | + result = SKILL_TOOLS.execute_tool(ctx, tc.function.name, json.loads(tc.function.arguments)) |
| 171 | + messages.append({"role": "tool", "tool_call_id": tc.id, "content": result}) |
| 172 | +``` |
| 173 | + |
| 174 | +```typescript TypeScript |
| 175 | +import { SKILL_TOOLS } from '@acontext/acontext'; |
| 176 | +import OpenAI from 'openai'; |
| 177 | + |
| 178 | +const openai = new OpenAI(); |
| 179 | + |
| 180 | +// Get skill IDs from the learning space |
| 181 | +const skills = await client.learningSpaces.listSkills(space.id); |
| 182 | +const skillIds = skills.map(s => s.id); |
| 183 | + |
| 184 | +// Give the agent access to those skills |
| 185 | +const ctx = await SKILL_TOOLS.formatContext(client, skillIds); |
| 186 | +const tools = SKILL_TOOLS.toOpenAIToolSchema(); |
| 187 | + |
| 188 | +const messages: OpenAI.ChatCompletionMessageParam[] = [ |
| 189 | + { role: "system", content: `You have access to skills from past sessions.\n\n${ctx.getContextPrompt()}` }, |
| 190 | + { role: "user", content: "Do you know my name?" }, |
| 191 | +]; |
| 192 | + |
| 193 | +while (true) { |
| 194 | + const response = await openai.chat.completions.create({ |
| 195 | + model: "gpt-4.1", |
| 196 | + messages, |
| 197 | + tools, |
| 198 | + }); |
| 199 | + const message = response.choices[0].message; |
| 200 | + messages.push(message); |
| 201 | + |
| 202 | + if (!message.tool_calls) { |
| 203 | + console.log(`Assistant: ${message.content}`); |
| 204 | + break; |
| 205 | + } |
| 206 | + |
| 207 | + for (const tc of message.tool_calls) { |
| 208 | + const result = await SKILL_TOOLS.executeTool(ctx, tc.function.name, JSON.parse(tc.function.arguments)); |
| 209 | + messages.push({ role: "tool", tool_call_id: tc.id, content: result }); |
| 210 | + } |
| 211 | +} |
| 212 | +``` |
| 213 | +</CodeGroup> |
| 214 | + |
118 | 215 | </Step> |
119 | 216 | </Steps> |
120 | 217 |
|
| 218 | +## Why Skill Files? |
| 219 | + |
| 220 | +<Accordion title="Comparison with other memory approaches"> |
| 221 | + |
| 222 | +| | Long-term Skill (Acontext) | Vector Store | Knowledge Graph | Plain-text Files | |
| 223 | +|--|--|--|--|--| |
| 224 | +| Storage format | Markdown files | Embeddings | Nodes & edges | Text files | |
| 225 | +| Human-readable | Yes | No | Partially | Partially | |
| 226 | +| Configurable schema | Yes (SKILL.md) | No | Complex upfront | No | |
| 227 | +| Filesystem-native | Yes | No | No | Yes | |
| 228 | +| Version controllable | Yes | No | No | No | |
| 229 | + |
| 230 | +</Accordion> |
| 231 | + |
121 | 232 | ## Next Steps |
122 | 233 |
|
123 | | -<CardGroup cols={2}> |
124 | | -<Card title="What is Long-term Skill?" icon="brain" href="/learn/skill-memory"> |
125 | | - Understand how long-term skill compares to other approaches |
| 234 | +<CardGroup cols={3}> |
| 235 | +<Card title="Custom Skills" icon="sparkles" href="/learn/custom-memory"> |
| 236 | + Define your own memory schemas with SKILL.md |
126 | 237 | </Card> |
127 | | -<Card title="Learning Spaces" icon="sparkles" href="/learn/learning-spaces"> |
| 238 | +<Card title="Learning Spaces" icon="brain" href="/learn/learning-spaces"> |
128 | 239 | Default skills, custom skills, and managing learning spaces |
129 | 240 | </Card> |
| 241 | +<Card title="Skill Content Tools" icon="wand-magic-sparkles" href="/tool/skill_tools"> |
| 242 | + Full reference for the skill reading tools |
| 243 | +</Card> |
130 | 244 | </CardGroup> |
0 commit comments