Talegorithm 8b204cfba7 feat: step tree & visualization API hace 1 mes
..
README.md 3ea53f3c71 refactor: core structure hace 1 mes
__init__.py 3ea53f3c71 refactor: core structure hace 1 mes
config.py 3ea53f3c71 refactor: core structure hace 1 mes
runner.py 8b204cfba7 feat: step tree & visualization API hace 1 mes

README.md

Agent Core - 核心引擎模块

职责

核心引擎是框架的"心脏",负责:

  1. Agent 主循环逻辑 (runner.py)

    • 单次调用模式:call() - 简单的 LLM 调用
    • Agent 模式:run() - 循环执行 + 记忆 + 工具调用
  2. 配置数据类 (config.py)

    • AgentConfig - Agent 配置参数
    • CallResult - 单次调用返回结果
  3. 事件定义 (events.py)

    • AgentEvent - Agent 事件数据结构
    • AgentEventType - 事件类型枚举

特点

  • 最小依赖:核心模块只依赖 execution, memory, tools
  • 最稳定:核心 API 变更频率最低
  • 可扩展:通过插件化的 tools, execution, memory 扩展功能

使用示例

from agent.core import AgentRunner, AgentConfig

# 创建 Runner
runner = AgentRunner(
    llm_call=my_llm_function,
    config=AgentConfig(max_iterations=10)
)

# 单次调用
result = await runner.call(
    messages=[{"role": "user", "content": "Hello"}]
)

# Agent 模式
async for event in runner.run(task="Complete this task"):
    print(event)

文件说明

  • runner.py - AgentRunner 类,核心执行逻辑
  • config.py - 配置类定义
  • events.py - 事件系统
  • __init__.py - 模块导出