Skip to main content

qi-pi 2.0

本地优先的 Agent Kernel + Runtime Plane。Session Event Log 是唯一持久事实源,Everything is a Plugin。

qi-pi 2.0 把执行内核、单机运行平面和传输层明确分开:

REST / WebSocket / SSE / DSH
              ↓
           qi_host
              ↓
      qi_runtime_plane
              ↓
         Agent Kernel
              ↓
     SQLite WAL Runtime Store
  • Kernel:Context、Session Actor、Agent Loop、Tool、Approval、Interrupt。
  • Runtime Plane:Durable Submission、Worker、Lease、Recovery、Outbox、Stream。
  • Host:鉴权、Wire 校验、DTO 映射与响应编码。
  • Plugins:标准能力、产品、媒体、Provider 和基础设施。

仓库不实现 Cloud Control Plane、Tenant、Billing、PostgreSQL、Redis、NATS 或多机调度。Runtime Store、 Lease 和 Stream 都通过接口可替换。

安装

Python 3.12+:

qi-agent wheel 包含 Kernel、Runtime Plane、Host、基础设施、标准插件和默认的 OpenAI / DashScope Provider。业务仓库只需安装这一个项目包;第三方依赖由安装器解析。 Python 嵌入调用使用 from qi_boot import AgentRuntime,见 独立业务仓库接入。

uv tool install qi-agent
export DASHSCOPE_API_KEY='...'
qi-agent serve

可选能力:

pip install 'qi-agent[memory]'
pip install 'qi-agent[media]'
pip install 'qi-agent[blog]'
pip install 'qi-agent[full]'

源码开发:

uv sync --all-extras
uv run pytest packages plugins tests
uv run ruff check packages plugins tests
uv run pyright
uv run python scripts/generate_references.py --check

Agent Protocol v3

创建 Session:

curl -X POST http://127.0.0.1:8765/api/v3/sessions \
  -H 'content-type: application/json' \
  -d '{"metadata":{"title":"demo"}}'

提交输入:

curl -X POST http://127.0.0.1:8765/api/v3/sessions/SESSION_ID/submissions \
  -H 'content-type: application/json' \
  -d '{
    "operationId":"client-op-1",
    "sessionId":"SESSION_ID",
    "kind":"user-input",
    "payload":{
      "model":{"id":"qwen3.7-max-2026-06-08","provider":"dashscope","display_name":"Qwen3.7 Max"},
      "content":[{"type":"text","text":"你好"}]
    },
    "source":{"transport":"rest"}
  }'

202 表示命令已经持久接纳,不表示 Turn 已完成。结果通过 GET /api/v3/sessions/{session_id}/events 或 /api/v3/agent/ws 获取。

WebSocket 是 JSON-RPC 2.0 双向通道,协议版本固定为 3。审批、Interrupt、Steer 和普通输入都 转换成同一种 Submission。DSH UI 保留自己的 Wire,但内部同样只提交 Submission。

持久化与恢复

默认事实存储是 <data-dir>/runtime.sqlite3:

submission/accepted + submissions + event_outbox
                   同一 SQLite 事务
                              ↓
                     durable receipt
                              ↓
                       Worker claim
                              ↓
               Session Lease + fencing generation
                              ↓
                      Session Actor

事件只在提交成功后向 SSE、WebSocket、DSH 和投影 Listener 发布。启动时会恢复 pending/过期 claim、 Active Turn,以及“input 已落盘但 turn/start 尚未产生”的输入。

旧 1.x JSONL/Zstd 数据不由新 Host 兼容读取。离线迁移:

qi-agent migrate runtime-v2 --data-dir /path/to/data

成功后旧目录保留为只读备份。

插件

标准能力随 qi-agent 一起发布,仍保留各自的插件 ID 和 Python Namespace:

插件 ID Namespace 能力
qi-agent-standard qi_standard Attachment、Title、System Prompt、Context Window、Notes、History
qi-agent-workflow qi_workflow Plan、Goal、Todo、Schedule、Skill
qi-agent-coding qi_coding Filesystem、Shell、Terminal、Jobs、MCP、LSP、Web Search
qi-agent-collaboration qi_collaboration Channel、Subagent、ACP、Claude/Codex/Peer Adapter
qi-agent-persona qi_persona Soul、Emotion、Local Refiner

可选插件使用 Manifest Schema 2,内置插件通过 qi_agent.bundled_plugins Entry Point 发现。 安装 Distribution 不等于启用能力;Profile、Bundle 和 cordis.yml 决定当前 Context Tree。2.0 不保留 qi_agent.plan、qi_agent.fs 等旧导入路径。

文档

Metadata

Release files for qi-agent 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qi-agent 2.0.1
File Size Uploaded
qi_agent-2.0.1.tar.gz 2.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for qi-agent 2.0.1
File Interpreter ABI Platform
qi_agent-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 4.9 MB

Release files / qi_agent-2.0.1.tar.gz

Download URL qi_agent-2.0.1.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
9ff9e77e3d2e42172c387372ec513c4ce4622a83df41a32f8f7ab191e7da3ff1
BLAKE2b-256 checksum
How to use checksums
97823c9f5bbb4d0987a3857cb8b293080381ce8867c6ae4beca3e516e989ec56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / qi_agent-2.0.1-py3-none-any.whl

Download URL qi_agent-2.0.1-py3-none-any.whl
Size 2.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ff5d0c867231ce79dba93294e8de4c49de71c90fdd7222f43f72cb52a137f919
BLAKE2b-256 checksum
How to use checksums
cc90fba58d30cd88a42b53a4c4a4b6d2c2277b872c9e5c824b02e0c1ee278d36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

2.1.0

2 release files

2.0.2

2 release files

This release

2.0.1 This release

2 release files

2.0.0

1 release file

1.0.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page