Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
40f717d
chore: docs
RockChinQ Mar 21, 2026
0923da6
feat: Telegram EBA adapter - full implementation
RockChinQ Mar 22, 2026
116634e
refactor: improve component loading logic and add resource directory …
RockChinQ Mar 22, 2026
a26ffd9
fix: handle telegram eba non-message updates
RockChinQ May 7, 2026
01f717a
docs: add eba feedback event design
RockChinQ May 7, 2026
8666b15
feat: route telegram eba events to plugins
RockChinQ May 7, 2026
59084e0
test: expand telegram eba api coverage
RockChinQ May 7, 2026
112d91a
test: cover telegram upload file capability
RockChinQ May 7, 2026
005db16
docs: add eba adapter migration records
RockChinQ May 7, 2026
5f9672d
feat: add discord eba adapter
RockChinQ May 7, 2026
ca8ba04
feat: migrate aiocqhttp adapter to eba
RockChinQ May 10, 2026
8b6e51e
docs: add eba adapter acceptance report
RockChinQ May 10, 2026
55727b9
feat: complete eba adapter acceptance path
RockChinQ May 10, 2026
b879d11
feat(platform): add dingtalk eba adapter
RockChinQ May 10, 2026
432df63
docs: update eba inbound media evidence
RockChinQ May 10, 2026
c7c7cc8
feat(platform): add lark eba adapter
RockChinQ May 11, 2026
6a7314b
feat(platform): add wecom eba adapters
wangcham May 27, 2026
2d0d718
feat(platform): add wecom customer service eba adapter
wangcham May 27, 2026
4a23927
feat(officialaccount): add eba adapter
wangcham May 28, 2026
78e42c7
feat(platform): add qqofficial eba adapter
wangcham Jun 2, 2026
f01e014
feat(platform): add slack eba adapter
wangcham Jun 2, 2026
30ad20e
feat(kook): add eba adapter
wangcham Jun 4, 2026
7bc07b9
chore(deps): pin langbot-plugin to 0.5.0a1
RockChinQ Jun 10, 2026
1314991
test(api): adapt bot service webhook tests to manifest-driven detection
RockChinQ Jun 10, 2026
558b98c
chore(deps): pin langbot-plugin to 0.5.0a2
RockChinQ Jun 10, 2026
02921f1
docs(eba): record agent-unified orchestration direction and final pro…
RockChinQ Jun 12, 2026
dcec8f6
feat(agent-runner): add plugin runner host integration
huanghuoguoguo Jun 20, 2026
0bd5084
feat(skill): unify skill activation as authorized tools
huanghuoguoguo Jun 21, 2026
e559259
test(qa): skill all-tool acceptance matrix + mcp-gateway discovery case
huanghuoguoguo Jun 21, 2026
efcf108
test(qa): record claude-code-agent skill discovery PASS + acp transpo…
huanghuoguoguo Jun 22, 2026
703202e
test(qa): correct acp parity verdict — passes on clean runtime, no pu…
huanghuoguoguo Jun 22, 2026
c4e8df7
test(qa): sandbox-skill-authoring OPERATE passes on nsjail + docker (…
huanghuoguoguo Jun 22, 2026
b386b88
refactor(plugin): split agent-runner action handlers out of handler.py
huanghuoguoguo Jun 22, 2026
5d9e6ad
refactor(tools): unify tool-detail normalization in ToolManager
huanghuoguoguo Jun 22, 2026
96c1ed8
test(agent): remove obsolete local agent runner attachment tests
huanghuoguoguo Jun 22, 2026
3767cd2
test(agent): align tests with agent runner plugin path
huanghuoguoguo Jun 22, 2026
29f552d
docs(agent): update pluginization status
huanghuoguoguo Jun 23, 2026
3dd49a8
fix(web): add agent runner component i18n
RockChinQ Jun 23, 2026
59e0edb
feat(agent): add event orchestration surface
RockChinQ Jun 23, 2026
96f2e47
test(agent): cover pluginized agent runner runtime
huanghuoguoguo Jun 24, 2026
d08f163
test(agent): cover agent service event bindings
huanghuoguoguo Jun 24, 2026
4aa0ac4
feat(eba): consolidate event bindings, fix command.tsx pointer-events
RockChinQ Jun 26, 2026
8eb5ca1
fix(web): place each adapter in a single category bucket
RockChinQ Jun 26, 2026
47a967d
fix(web): remove discard option from event target selector
RockChinQ Jun 26, 2026
c34a543
feat(adapters): mark EBA-superseded adapters as legacy and collapse them
RockChinQ Jun 26, 2026
a275740
fix(adapters): add categories to telegram EBA manifest
RockChinQ Jun 26, 2026
8aedb57
feat(bots): refine event binding editor UI and i18n
RockChinQ Jun 26, 2026
55ed1d4
fix(bots): hide redundant namespace wildcard and show raw event code
RockChinQ Jun 26, 2026
bd4626a
feat(sidebar): mark Agent entries as Agent or Pipeline
RockChinQ Jun 26, 2026
d6be272
refine(sidebar): show Agent/Pipeline marker as icon only
RockChinQ Jun 26, 2026
1a3599e
feat(sidebar): add group-by-kind toggle to Agent section
RockChinQ Jun 26, 2026
0027ea8
feat(sidebar): add group-by-type toggle to installed extensions section
RockChinQ Jun 26, 2026
7d29564
i18n: add missing agents block to es-ES, ru-RU, th-TH, vi-VN, zh-Hant
RockChinQ Jun 26, 2026
df6c94f
feat(agent-runner): support scoped token counting
huanghuoguoguo Jun 26, 2026
801ffbf
fix(debug-chat): preserve websocket pipeline routing
huanghuoguoguo Jun 26, 2026
66c900f
fix(platform): align eba event declarations
wangcham Jun 28, 2026
705845b
docs(agent-runner): align protocol compatibility notes
huanghuoguoguo Jun 29, 2026
35d970c
test(provider): support fake token counting
huanghuoguoguo Jun 29, 2026
bdc6704
fix: stabilize 4.11 branch runtime state
RockChinQ Jun 30, 2026
6dd2966
fix: remove internal adapter terminology from UI
RockChinQ Jun 30, 2026
d0f8f08
feat: improve sidebar usability
RockChinQ Jun 30, 2026
995888f
test(agent-runner): strengthen local agent e2e gate
huanghuoguoguo Jul 1, 2026
0d6aa8d
refactor: consolidate bot event routing
RockChinQ Jul 1, 2026
2004ac0
docs: add EBA productization release plan
RockChinQ Jul 1, 2026
4e9464d
feat(agent-platform): add bot route dry-run
huanghuoguoguo Jul 8, 2026
3c6e87a
feat(agent-platform): show bot route runtime status
huanghuoguoguo Jul 8, 2026
c59616f
feat(agent-platform): productize bot event route testing
huanghuoguoguo Jul 11, 2026
bda0e68
test(skills): add bot event routing product flow
huanghuoguoguo Jul 11, 2026
f15f004
feat(agent-platform): explain route conflicts and fallback
huanghuoguoguo Jul 11, 2026
a2b3095
feat(agent-platform): add scenario-based route creation
huanghuoguoguo Jul 11, 2026
2432283
feat(wizard): start bot setup from scenarios
huanghuoguoguo Jul 11, 2026
11bd5c6
feat(wizard): add scenario templates and EBA release gate
huanghuoguoguo Jul 11, 2026
2968996
feat(market): support AgentRunner component filters
RockChinQ Jul 11, 2026
e6384aa
feat(agent-runner): finalize 4.x processor integration
huanghuoguoguo Jul 12, 2026
99d9c22
feat(agent-runner): enforce 4.x host-owned execution
huanghuoguoguo Jul 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Config keys to verify in `data/config.yaml` / `src/langbot/templates/config.yaml
## Change Rules

- HTTP API changes that should be agent-accessible must update the matching MCP tool in `src/langbot/pkg/api/mcp/server.py` and the relevant skill under `skills/` in the same pass.
- New schema changes use Alembic under `src/langbot/pkg/persistence/alembic/versions/`; do not add legacy `dbmXXX` migrations.
- New schema changes use Alembic under `src/langbot/pkg/persistence/alembic/versions/`. LangBot 4.x does not support upgrading 3.x databases.
- New platform behavior belongs in platform adapters only for platform translation; pipeline/business logic belongs in `pkg/pipeline/` or services.
- User-facing strings must support i18n (`en_US`, `zh_Hans`; include `ja_JP` where the repo already does).
- Code comments and docstrings must be English.
Expand Down
21 changes: 11 additions & 10 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ LangBot/
│ │ ├── api/ # HTTP API + MCP server mount
│ │ ├── platform/ # IM adapters and runtime bot manager
│ │ ├── pipeline/ # Message routing and pipeline stages
│ │ ├── provider/ # LLM runners, model manager, tools
│ │ ├── provider/ # Model providers and Host-owned tools
│ │ ├── agent/ # Agent/AgentRunner orchestration and run state
│ │ ├── plugin/ # LangBot-side Plugin Runtime connector/handler
│ │ ├── box/ # LangBot-side Box service/connector
│ │ ├── skill/ # Skill metadata/activation integration
│ │ ├── rag/ , vector/ # Knowledge-base and vector DB integration
│ │ ├── persistence/ # SQLAlchemy/SQLModel, Alembic, legacy migrations
│ │ ├── persistence/ # SQLAlchemy/SQLModel and Alembic migrations
│ │ ├── storage/ # Local/S3 file storage abstraction
│ │ └── config/, entity/, utils/, telemetry/, survey/
│ ├── libs/ # Vendored third-party platform SDKs
Expand All @@ -80,7 +81,7 @@ Platform adapter
→ Controller
→ RuntimePipeline
→ PipelineStage chain
RequestRunner / ToolManager / PluginRuntimeConnector / BoxService
AgentRunner orchestrator / ToolManager / PluginRuntimeConnector / BoxService
→ response via adapter
```

Expand All @@ -107,7 +108,7 @@ Inbound platform messages enter through adapter-specific SDK callbacks. The comm
3. `MessageAggregator` batches/normalizes messages before adding a `Query` to `QueryPool`.
4. `Controller` in `pkg/pipeline/controller.py` selects queries subject to global pipeline concurrency and per-session concurrency.
5. `RuntimePipeline` in `pkg/pipeline/pipelinemgr.py` runs configured pipeline stages using a responsibility-chain style executor that supports generator stages.
6. The chat stage emits plugin events, calls a configured `RequestRunner`, handles streaming/non-streaming responses, records telemetry, and appends conversation history.
6. The chat stage emits plugin events and projects the current query into the AgentRunner Host orchestrator. The selected plugin AgentRunner returns streaming or final results while the Host owns authorization, tools, telemetry, and conversation history.
7. Output stages send text, cards, chunks, files, or error notices back through the original platform adapter.

Pipeline components are registered by decorators and package import side effects. When adding a new stage, loader, runner, or adapter, check the corresponding preregistration mechanism instead of inventing a second registry.
Expand Down Expand Up @@ -136,12 +137,12 @@ Important pieces:

Pipelines are configuration-driven. Prefer adding a stage or extending an existing stage family over hard-coding behavior in platform adapters.

## Provider, RAG, and Tools
## Agents, Providers, RAG, and Tools

Provider code lives under `pkg/provider/`.
Agent orchestration lives under `pkg/agent/`; model providers and tools live under `pkg/provider/`.

- `modelmgr/` manages configured model providers and requesters.
- `runners/` implements request runners such as the local agent runner and external workflow integrations.
- `pkg/agent/runner/` discovers plugin AgentRunner components, resolves bindings, constructs run-scoped context/resources, and records execution state.
- `tools/toolmgr.py` aggregates tools from native tools, plugin tools, external MCP servers, and skill-authoring tools.
- `tools/loaders/mcp.py` is the MCP client side: external MCP servers that LangBot connects to for agent tools.
- RAG lives across `pkg/rag/`, `pkg/vector/`, model services, and plugin KnowledgeEngine actions.
Expand Down Expand Up @@ -206,8 +207,8 @@ Persistence is centered on `pkg/persistence/mgr.py`.

- SQLite is the default database; PostgreSQL is supported.
- Models live under `pkg/entity/persistence/`.
- Fresh schemas are created from metadata, then legacy migrations run up to the frozen 3.x baseline, then Alembic migrations run to head.
- New schema changes should use Alembic under `pkg/persistence/alembic/versions/`; do not extend the frozen legacy migration chain.
- Fresh schemas are created from current metadata, then Alembic migrations run to head. LangBot 4.x does not upgrade 3.x databases.
- New schema changes use Alembic under `pkg/persistence/alembic/versions/`; there is no legacy migration chain in 4.x.

Configuration starts from `src/langbot/templates/config.yaml` and is generated into `data/config.yaml` on first run. Most long-lived managers read from `ap.instance_config.data`.

Expand Down Expand Up @@ -239,7 +240,7 @@ When one of these changes, update the others if the behavior or contract changed
- New LLM tool source: extend `pkg/provider/tools/loaders/` and `ToolManager` intentionally.
- New plugin component/API/protocol: change `langbot-plugin-sdk` first or in lockstep, then update LangBot bridge code.
- New Box capability: change both `pkg/box/` and `langbot-plugin-sdk/src/langbot_plugin/box/`, plus config and tests.
- New database schema: add an Alembic migration, not a legacy `dbmXXX` migration.
- New database schema: add an Alembic migration.

## Design Biases

Expand Down
149 changes: 149 additions & 0 deletions docs/agent-runner-pluginization/AGENT_CONTEXT_PROTOCOL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Agent-owned Context 协议设计

本文档描述插件化 AgentRunner 场景下的上下文边界**设计理由**。结论先行:LangBot 不应成为最终 agentic context manager;它提供 context substrate,AgentRunner 或其背后的 runtime 自己决定如何管理历史、压缩、召回和 KV cache。

> 涉及的数据结构(`AgentRunContext`、`ContextAccess`、`AgentRunAPIProxy` 等)唯一定义在 [PROTOCOL_V1.md](./PROTOCOL_V1.md)。本文只讲语义和约束,不重抄 schema。

## 1. 设计原则

### 1.1 Agent 拥有上下文策略

不同 runner 背后的 runtime 差异很大:

- 官方 local-agent 可能依赖 LangBot 的模型、工具、知识库和存储。
- Claude Code SDK / Codex 类 runtime 有自己的 session、transcript、tool loop 和上下文压缩。
- Pi Agent SDK 或外部 agent 平台可能只需要当前事件和一个外部 conversation key。

因此 LangBot 不应强行决定最终传给模型的历史窗口。Host 只提供:当前事件的完整结构化信息、稳定身份和会话引用、可授权读取的 history / event / state API、sandbox/workspace 文件能力、可投影给外部 harness 的 scoped context / SDK-owned MCP bridge / resource handles、payload hard cap 和权限 guardrail。

### 1.2 Host 不定义通用历史窗口

历史窗口策略不是 AgentRunner 协议或 Query entry adapter 的核心概念。Host 只提供 history pull API、cursor、hard cap 和权限边界;runner 自己决定是否读取、读取多少、如何截断和压缩。

正确的问题不是"LangBot 每轮裁几轮历史给 agent",而是:

- 这类 runner 是否自管 context?
- 事件到来时 host 应 inline 哪些最小信息?
- agent 需要更多上下文时通过什么 API 拉取?
- host 如何保证安全、可审计和可分页?

### 1.3 Host 保存事实源,Agent 管理 working context

三类数据要分开:

- `EventLog`: Host 保存原始事件、工具调用、投递结果、错误和系统事件。
- `Transcript`: Host 从 EventLog 投影出的对话视图,用于 UI、审计和按需历史读取。
- `Working context`: Agent 本轮实际送进模型或 runtime 的上下文,由 AgentRunner 决定。

LangBot 不提供 host-side inline history window。简单 runner 如果需要历史窗口,应在 runner 内部通过 Host history API 拉取并裁剪。

## 2. Event 到来时传什么

默认 `AgentRunContext`(PROTOCOL_V1 §5.2)应尽量小且稳定。默认规则:

- Host MUST NOT inline full history by default.
- Host SHOULD inline only current event / input and context handles.
- Runner owns working-context assembly.
- Runner MAY use Host history / event / state / storage API and sandbox/workspace file tools when authorized.
- Official runners MUST consume Host infrastructure through the same public API as third-party runners.

### 2.1 必须 inline 的内容

当前 event 的类型/id/时间/source;当前输入文本和结构化内容;附件/文件/图片的 metadata、path 或 URL;actor / subject / conversation / thread / bot / workspace;delivery 能力;已授权资源列表;context cursors 和可用 API 能力;Agent/runner config。这些是 agent 决定下一步所需的最低信息。

### 2.2 默认不 inline 的内容

完整历史消息、大文件全文、大工具结果、全量知识库内容、平台原始 payload 大对象、每轮重新生成的大段 summary。这些会破坏跨进程序列化成本、泄露范围、KV cache 稳定性,也会迫使 host 替 agent 做 context 策略。

### 2.3 不提供 Host Inline History Window

`AgentRunContext` 不包含 `bootstrap` 字段。Host 不下发历史窗口,也不通过 Pipeline 配置决定窗口大小。runner 若需要类似 `recent_tail` 的策略,应在自己的 manifest/config schema 中声明参数,并在 runner 内部通过 history API 读取、裁剪和压缩。Host 只负责权限、分页、hard cap 和事实源。

## 3. ContextAccess 的作用

`ContextAccess`(PROTOCOL_V1 §5.8)是 host 交给 agent 的上下文读取入口描述,告诉 agent:当前事件位于哪条 conversation / thread、若需要更多历史从哪个 cursor 开始拉、host inline 了什么没 inline 什么、当前 run 有哪些 context API 权限。

## 4. Agent 如何获取更多上下文

所有 API 都走 `AgentRunAPIProxy`(PROTOCOL_V1 §8),由 host 用 `run_id` 校验。

外部 harness 不能直接访问 LangBot 资源。无论是 history、event、state、model、tool、knowledge base,还是 LangBot skills,都必须通过 SDK runtime 转发到 Host API,并由 Host 按 active `run_id`、runner identity、binding resource policy 和 caller plugin identity 校验。当前运行文件进入授权 sandbox/workspace 后,再由 runner 用 read/write/exec 类工具按需访问。harness 自己的 native tools 只属于 harness 执行环境,不能绕过 SDK runtime 访问 LangBot 内部资源。

### 4.1 History

```python
await api.history_page(conversation_id=ctx.context.conversation_id,
before_cursor=ctx.context.latest_cursor,
limit=50, direction="backward", include_attachments=False)
```

返回 `HistoryPage`(schema 见 PROTOCOL_V1 §8)。

约束:`limit` 有 host hard cap;默认只能读当前 conversation / thread;跨会话读取需 binding policy / run authorization snapshot 授权;可返回 attachment ref,不默认返回大文件内容。

### 4.2 Search

```python
await api.history_search(query="用户之前提到的数据库连接信息",
filters={"conversation_id": ..., "event_types": ["message.received"]},
top_k=10)
```

Search 可先用数据库全文索引,后续接 embedding recall。它是 host 检索能力,不等于 agent 的长期记忆策略。

### 4.3 Event / State

- Event API(`events.get` / `events.page`)用于读取非消息事件、工具事件、系统事件。Agent 不应把所有事件都当成 user/assistant message。
- State API(`state.get` / `set`)是可选寄宿能力。自管 runtime 可以完全不用;依附 LangBot 的官方 runner 可以使用,例如 `external.session_id`、`summary.checkpoint`。

### 4.4 大文件与工具协作

大文件、多模态输入和工具产物不要内联进 prompt 或 tool result:message/content 里只放小文本和必要摘要;当前事件附件由 Host staged 到授权 sandbox/workspace,并在 input attachment 中给出轻量 metadata/path。工具之间传递大结果时传 sandbox path 或 attachment ref,不传完整 blob。Host 只保证当前 run 授权范围,默认不允许插件直接读任意本地路径;临时文件由 sandbox 生命周期和清理机制管理。

### 4.5 External harness context projection

外部 harness 的总体边界以 [HOST_SDK_INFRASTRUCTURE.md](./HOST_SDK_INFRASTRUCTURE.md) §4.8 为准。本节只描述 context projection 的推荐形态。

Claude Code、Codex、Kimi Code 这类 runtime 通常已有自己的 session、工具 loop、MCP 加载、上下文压缩和工作目录。LangBot 不应把它们改造成"host prompt assembler",而应提供可审计的事件和资源投影。推荐 projection 形态:

- `agent-context.json`:结构化 JSON,包含 `run_id`、`event`、`actor`、`subject`、`input`、`delivery`、`resources`、`context`、`state`、`runtime`。
- `LANGBOT_CONTEXT.md`:人类可读摘要。
- `resources`:只包含本次 run 授权后的资源句柄和能力摘要,不暴露 Host 内部私有对象、secret 或资源内容。
- `skills`:LangBot skills 不是直接投影给 harness native tool loop 的文件能力,而是**一组被授权的 tool**。发现走 `list_skills`(或 `langbot_list_assets` 增加 skills 一类),激活/注册走 `activate` / `register_skill`,包内操作走 native exec/read/write,统一通过 `ctx.resources.tools`、`AgentRunAPIProxy` 或 SDK-owned MCP bridge 暴露。Host 不向 prompt 注入 skill 索引(无 progressive-disclosure 注入);harness 通过调用发现工具主动查询 skill 清单。`agent-context.json` 的 `skills` 字段仅作发现工具的数据来源与可选 `suggested_skill_prompt` 的输入。
- `MCP config`:只投影 per-run、scoped 的 SDK-owned bridge 或外部 MCP 连接配置;LangBot 资源访问必须回到 SDK runtime / Host API,不允许 harness 通过自带 MCP/native tool 直接读 Host 内部资源。
- `state pointers`:外部 session id、working directory、checkpoint 等小型 JSON 状态通过 Host state API 保存。

当前官方外部 harness 路径由 ACP / Claude Code / Codex 等 runner 插件承担(现状见 OFFICIAL_RUNNER_PLUGINS §7)。这类 projection 是"把 LangBot 事实源和授权资源句柄交给 harness",不是"把 LangBot 资源本体或内部权限交给 harness",也不是"由 LangBot 决定最终模型上下文"。

## 5. Runner 上下文边界

Host 只给当前事件、当前输入和 context handles。Runner 是否能拉取历史、事件、state 或 storage、是否能访问 sandbox/workspace 文件,以运行时 `ctx.context.available_apis` 和工具授权为准;runner 自己决定是否拉取历史、是否搜索、何时摘要、如何构造最终 prompt。

## 6. KV cache 友好的上下文管理

支持 Claude Code SDK、Codex、Pi Agent SDK 等 runtime 时,必须避免每轮由 LangBot 重组大块 prompt:

- 稳定 session key:`workspace/bot/binding/runner/conversation/thread`。
- 每轮只传 delta:当前 event、attachment refs/path、少量 runtime metadata。
- 历史 append-only:不要每轮改写同一段 history 文本。
- Summary checkpoint 稳定:只有压缩发生时产生新 checkpoint。
- 大文件和工具结果写入 sandbox/workspace。
- Tool/context API schema 稳定,数据通过 API 拉取而非塞入 prompt。
- 对自管 runtime,优先让它复用自身 session/cache,而不是强制 LangBot 每轮重放 transcript。
- 模型窗口元信息应作为 resource/runtime metadata 暴露给 runner,由 runner 决定预算和压缩策略。

稳定 session key 的用途是隔离外部 runtime 的 resume/cache/state,不是改变 PROTOCOL_V1 §13 定义的 Agent 复用和 dispatch 边界。只有当某个外部 harness 的同一 native session 不支持并发 turn 时,runner 或 future runtime control plane 才应按 external session key 做 turn-level 串行化。

对长期运行的 external harness / daemon,推荐运行形态是 reader 与 writer 分离:一个 session reader 独占读取 stdout/SSE/native event stream,并把 native event 转成 `AgentRunResult` 或 task progress;用户输入只作为 turn write 进入该 session。当前一次性 CLI subprocess runner 可以继续在单次 `run(ctx)` 内同步收集 stdout,但后续改成长连接时不应让多个 request 同时读取同一 native stream。

## 7. Host guardrail

Agent 自管 context 不代表无限制访问。LangBot 仍必须控制:每次 run 的 active `run_id`、runner identity、当前 binding 的 resource policy、conversation / actor / subject scope、page size / sandbox file read size / API rate limit、跨会话读取权限、数据脱敏和敏感变量过滤、审计日志。Host 不负责"最佳上下文策略",但负责"不越权、不爆内存、不不可审计"。

外部 harness 的 native tools、shell、MCP 或 skill 机制不构成 LangBot 资源授权边界。只要访问的是 LangBot 持有的资源,就必须经 SDK runtime 转发并接受 Host 校验;完整边界见 HOST_SDK §4.8。

## 8. 官方 runner 与业务编排边界

官方 runner 插件可以把状态寄宿在 LangBot,但必须和第三方 runner 一样通过公开 Host API 消费。LangBot core 不内置官方 agent 的业务流程(prompt 组装、tool loop、RAG 编排、summary/compaction、"local-agent 专用"状态字段)。

官方 local-agent 应作为"依附 LangBot 基础设施的复杂 runner 参考实现":transcript/history 通过 `api.history_page()` / `api.history_search()` 读取,summary/checkpoint/外部 session id/用户偏好通过 `api.state_get()` / `api.state_set()` 或 storage 方法保存,图片/文件/工具大结果通过 sandbox/workspace read/write 工具访问,模型/工具/知识库通过 `api.invoke_llm()` / `api.call_tool()` / `api.retrieve_knowledge()` 调用。这样 LangBot 保持为通用 agent host,不变成内置 agent 框架。具体迁移要求见 [OFFICIAL_RUNNER_PLUGINS.md](./OFFICIAL_RUNNER_PLUGINS.md)。
Loading
Loading