Talegorithm 8b204cfba7 feat: step tree & visualization API il y a 1 mois
..
README.md 3ea53f3c71 refactor: core structure il y a 1 mois
__init__.py 3ea53f3c71 refactor: core structure il y a 1 mois
models.py 3ea53f3c71 refactor: core structure il y a 1 mois
protocols.py 3ea53f3c71 refactor: core structure il y a 1 mois
skill_loader.py 3ea53f3c71 refactor: core structure il y a 1 mois
stores.py 8b204cfba7 feat: step tree & visualization API il y a 1 mois

README.md

Agent Memory - 记忆系统

职责

记忆系统管理 Agent 的长期记忆和技能:

  1. 数据模型 (models.py)

    • Experience - 经验记录(从执行中提取的知识)
    • Skill - 技能定义(领域知识和最佳实践)
  2. 存储接口 (protocols.py, stores.py)

    • MemoryStore - 经验和技能存储接口
    • StateStore - 状态存储接口
    • MemoryMemoryStore - 内存实现
    • MemoryStateStore - 内存实现
  3. 技能加载 (skill_loader.py)

    • 从 Markdown 文件加载技能
    • 支持 YAML frontmatter 和行内元数据

模块边界

  • 只依赖:无(纯数据模型和接口)
  • 被依赖:core.runner(加载和注入记忆)
  • 独立开发:记忆检索、经验提取算法可独立迭代

使用示例

from agent.memory import (
    MemoryMemoryStore,
    Experience,
    Skill,
    load_skills_from_dir
)

# 创建存储
memory_store = MemoryMemoryStore()

# 添加经验
exp = Experience.create(
    scope="coding",
    context="Python type hints",
    pattern="Use Optional[T] for nullable types",
    outcome="success"
)
await memory_store.add_experience(exp)

# 加载技能
skills = load_skills_from_dir("./config/skills")
for skill in skills:
    await memory_store.add_skill(skill)

# 检索记忆
experiences = await memory_store.search_experiences(
    scope="coding",
    context="type hints",
    limit=5
)

技能文件格式

技能文件使用 Markdown + YAML frontmatter:

---
name: browser-automation
description: Browser automation best practices
category: web-automation
scope: agent:*
---

## When to use

- Scraping dynamic web pages
- Testing web applications

## Guidelines

- Always check if element exists before clicking
- Use explicit waits instead of sleep()

文件说明

  • models.py - Experience 和 Skill 数据模型
  • protocols.py - MemoryStore 和 StateStore 接口
  • stores.py - 内存存储实现
  • skill_loader.py - 技能加载器
  • __init__.py - 模块导出