Skip to content

feat(agent): prepare 4.11.x EBA and AgentRunner integration#2277

Open
huanghuoguoguo wants to merge 70 commits into
masterfrom
dev/4.11.x
Open

feat(agent): prepare 4.11.x EBA and AgentRunner integration#2277
huanghuoguoguo wants to merge 70 commits into
masterfrom
dev/4.11.x

Conversation

@huanghuoguoguo

@huanghuoguoguo huanghuoguoguo commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Scope

This PR prepares the 4.11.x integration branch for LangBot. It brings together the EBA adapter foundation and the AgentRunner pluginization host work.

Included in this branch:

  • Event-based adapter structure and platform adapter implementations for supported IM platforms.
  • AgentRunner Protocol v1 host infrastructure: runner discovery, binding/config projection, run orchestration, event log, transcript, persistent state, run ledger, and run-scoped pull APIs.
  • Plugin runtime action handlers for AgentRunner resources, state, history/events, steering, run ledger, and minimal runtime control-plane primitives.
  • Removal of the old built-in provider runner path in favor of pluginized AgentRunner components.
  • Pipeline/preproc tests aligned with the pluginized runner path.
  • Status docs updated for the current 2026-06-23 state.

Linked branches and companion PRs

This PR is part of the 4.11.x AgentRunner integration set and should be reviewed/tested with the matching SDK branch:

Repository Branch / PR Purpose
langbot-app/LangBot dev/4.11.x -> master, #2277 Host-side EBA and AgentRunner integration branch.
langbot-app/langbot-plugin-sdk dev/4.11.x -> main, langbot-app/langbot-plugin-sdk#88 Matching SDK protocol/entity/runtime support required by this LangBot branch.
langbot-app/langbot-local-agent main, README.md Official local AgentRunner plugin consuming Protocol v1 through the host APIs.
langbot-app/langbot-agent-runner main, README.md Official external-service AgentRunner plugin set and Protocol v1 consumer guidance.
langbot-app/langbot-agent-control-plane main, README.md Control-plane plugin for host-owned run/runtime/descriptor inspection and admin actions.

Joint test surface

Use this PR together with the SDK companion PR and the three AgentRunner plugin repositories above:

  • LangBot must run against the local editable langbot-plugin-sdk from dev/4.11.x / PR [ENHANCE]使用限制,忽略某人私聊,忽略某群消息,忽略某群中某人消息 #88.
  • langbot-local-agent/README.md documents the in-process local runner path that exercises host model, prompt, history, tool, knowledge-base, state, and storage pull APIs.
  • langbot-agent-runner/README.md documents the external-service runner path, including run-scoped Host API/MCP access patterns and steering expectations.
  • langbot-agent-control-plane/README.md documents the admin plugin path for listing runs, runtimes, descriptors, event pages, reconciliation, and cancellation.

These repositories form the cross-repo validation set for AgentRunner Protocol v1 compatibility.

Current status

Done / unit covered:

  • SDK manifest schema, runner discovery, host resource authorization, run authorization snapshot, and result payload validation.
  • Skill activation has been moved to the skill-as-tool model; activate persists host.activated_skills best-effort and later runs restore from pipeline-visible skills.
  • Runtime Control Plane v2 foundation exists: host-owned run/event ledger, run control actions, runtime register/heartbeat/list/reconcile, and run claim/renew/release primitives.

Still intentionally out of scope for this PR:

  • Full Agent Platform product UI.
  • Daemon supervisor, runtime wakeup channel, distributed runtime management, and cross-host locking.
  • Full product E2E and real-provider smoke for every official runner.

Verification

LangBot was tested against the local editable langbot-plugin-sdk from the matching dev/4.11.x branch.

  • 467 passed, 64 warnings
  • Covered: tests/unit_tests/agent, tests/unit_tests/plugin/test_handler_actions.py, tests/unit_tests/provider/test_skill_tools.py, pipeline chat/preproc/media fallback tests, and Telegram EBA adapter tests.
  • Import smoke confirmed LangBot can load SDK agent_runner entities from the local SDK branch.

RockChinQ and others added 30 commits May 7, 2026 15:18
- TelegramAdapter inherits AbstractPlatformAdapter with all capabilities
- TelegramEventConverter handles all Update types: message, edited_message,
  chat_member, my_chat_member, callback_query, message_reaction
- TelegramAPIMixin implements: edit_message, delete_message, forward_message,
  get_group_info, get_group_member_list/info, get_user_info, get_file_url,
  mute/unmute/kick_member, leave_group
- PLATFORM_API_MAP for call_platform_api: pin/unpin message, set chat title/desc,
  get admins, send chat action, create invite link, answer callback query
- Full backward compat: legacy FriendMessage/GroupMessage listeners still work
- Preserves all existing functionality: stream output, markdown card, forum topics
- Old sources/telegram.py untouched for gradual migration
Expose skill tools (activate/register_skill/native exec) like native tools
instead of gating them behind the skill_authoring capability:
- toolmgr.get_all_tools drops include_skill_authoring; SkillToolLoader
  self-gates on sandbox + skill_mgr
- preproc drops the include_skill_authoring branch; pipeline-bound skills
  and the skills resource gate on skill_mgr presence

Persist activated skills into host.activated_skills conversation state so
they survive across runs (host writes at activate; last-write-wins); drop
the dead restore_activated_skills helper.

Prefill ToolResource.parameters host-side (tool_mgr.get_tool_schema) so
runners build LLM tools without per-tool get_tool_detail round-trips.

Align agent-runner-pluginization design docs to the all-tool model.
- references/skill-all-tool-acceptance.md: acceptance matrix for the skill
  all-tool model (runner x lifecycle x backend), case status, exit criteria,
  and the #2271 known issue (pre-existing box nested-mount, not this branch)
- cases/skill-discovery-via-mcp-gateway.yaml: schema-valid case proving an
  external harness discovers skills via langbot_list_assets (the new 'skills'
  asset class); marked blocked-env until remote claude-code is responsive
@huanghuoguoguo

Copy link
Copy Markdown
Collaborator Author

这里建议把 EBA / Agent 编排相关文档口径再收敛一下,避免把目标形态和当前实现混在一起。

我理解当前更准确的分层是:

事件源
  ├─ IM 平台
  ├─ GitHub / GitLab / Jira / Linear webhook
  ├─ 内部业务系统
  ├─ Scheduler
  ├─ Monitoring / CI/CD
  └─ WebUI / API

EventGateway / adapter
  -> canonical event / EBAEvent
  -> Bot event_bindings / future EventRouter
  ├─ target_type=agent
  │    -> 产品层 Agent 编排实例
  │    -> AgentBinding
  │    -> AgentRunOrchestrator.run(event, binding)
  │    -> AgentRunner
  ├─ target_type=pipeline
  │    -> legacy Pipeline,仅 message.*
  └─ target_type=discard

几个关键判断:

  1. Agent 确实是从原来 Pipeline 里的 AI/agent 阶段被抽出来,变成一等公民。它现在有独立 agents 表、/home/agents 产品入口,并且可以通过 Bot event_bindings 直接绑定事件。

  2. 但这不等于 Pipeline 被 Agent 吃掉。当前更像是 /home/agents 作为统一管理入口,里面有两类同级处理单元:Agent 编排面向 EBA / AgentRunner,可以处理 message、group、friend、bot、feedback、platform 乃至未来 GitHub/internal/scheduler 等事件;Pipeline 是兼容保留的消息流水线,只处理 message.*

  3. 对产品层 Agent 来说,背后的实现应该一视同仁:local-agent、外部 runner、Dify、n8n、Coze、DashScope、webhook、未来 workflow runner,本质都应该收敛成 runner_id + runner_config + resource/state/delivery policy,再投影为 AgentBinding,最后走 AgentRunner 协议。

  4. 插件 EventListener 不是 Agent 的同级响应者,而是观察者广播链路。它可以做审计、风控、统计、拦截,并且可以 prevent_default;但不应该被收编进 AgentRunner 抽象。

  5. 当前实现不是完整通用 EventGateway -> EventRouter 已经落地。代码里已经有 bot 侧 EBAEvent -> event_bindings -> target agent/pipeline/discard 的轻量路由,并且命中 Agent 时会构造 AgentEventEnvelope + AgentBindingAgentRunOrchestrator.run()。但完整 EventGateway/EventRouter、跨 workspace/project/integration 的 binding scope、通用 webhook/scheduler/internal event 接入,仍应视为后续平台化能力。

因此建议文档上做两个调整:

  • docs/event-based-agents/07-agent-orchestration.md 标清为早期方向稿/目标讨论,不再作为当前实现口径。里面 “pipeline-wrapper 收编 Pipeline”、“SDK 第七种 Agent 组件”、“所有 handler 统一为 Agent” 这些表述已经和当前 AgentRunner Protocol v1 / 08 文档有偏差。
  • docs/event-based-agents/08-agent-page-and-event-orchestration.md 作为当前产品口径继续推进:Agent 页面统一管理 Agent 编排与 Pipeline,但运行语义保持分层;Agent 编排走 AgentRunOrchestrator.run(event, binding),Pipeline 走 legacy message pipeline。

更宏观一点,这个设计的价值不只是 IM Bot。IM 是当前落点,因为 LangBot 既有资产在 platform adapter、bot、message pipeline 和投递能力上。但 AgentEventEnvelope + AgentBinding + AgentRunOrchestrator 的上限应该是事件驱动 Agent Host:GitHub webhook、内部系统事件、监控告警、CI/CD、定时任务、审批事件、知识库变更事件都可以被标准化成 event,再绑定到 Agent 执行。

- Replace legacy pipeline binding card + RoutingRulesEditor with unified
  EventBindingsEditor; remove use_pipeline_uuid/pipeline_routing_rules
  from bot form schema and API update handler
- Add _augment_event_data() to botmgr for filter virtual fields
  (message_text, message_element_types, chat_type)
- Add alembic migration 0009: migrate use_pipeline_uuid and
  pipeline_routing_rules into event_bindings on first run
- Fix command.tsx: data-[disabled] -> data-[disabled=true] so cmdk 1.x
  items (data-disabled=false) are not pointer-events:none
- EventBindingsEditor: onSelect on CommandItems, filter conditions panel,
  disabled bindings section, dnd reorder
- i18n: add filter/condition keys for zh-Hans and en-US
- Update tests to match new bot service behavior

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread web/src/app/home/bots/components/bot-form/EventBindingsEditor.tsx Fixed
Comment thread web/src/app/home/bots/components/bot-form/EventBindingsEditor.tsx Fixed
groupByCategory pushed multi-category adapters (lark, wecom, discord,
slack) into every matching bucket, so the adapter Select rendered
duplicate SelectItem values — triggering React duplicate-key warnings
and corrupting Radix item tracking. Assign each item to its highest
-priority matching category only. Also de-dupes the wizard card grid.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RockChinQ and others added 23 commits June 26, 2026 19:09
Unorchestrated events are discarded by default, so an explicit discard
target is redundant. Drop the discard CommandGroup (and the now-unused
CommandSeparator import); the currentLabel() discard branch is kept so
any pre-existing discard bindings still render correctly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The 12 old adapters that now have an EBA replacement are tagged
`spec.legacy: true` in their source manifests. Principle: don't delete,
de-emphasize.

- sources/*.yaml (aiocqhttp, dingtalk, discord, kook, lark,
  officialaccount, qqofficial, slack, telegram, wecom, wecombot,
  wecomcs): add spec.legacy: true
- Adapter / IChooseAdapterEntity types: add optional legacy flag
- BotForm adapter Select: split legacy adapters into a collapsed,
  grayscale group at the bottom with an explanatory hint; auto-expand
  when the bot already uses a legacy adapter
- Wizard platform picker: same collapsed legacy section
- i18n: legacyAdapters / legacyAdaptersHint (zh-Hans, en-US)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Telegram (EBA) manifest was missing spec.categories, so it fell
into the uncategorized/protocol bucket. Restore popular + global to
match the legacy telegram adapter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Move conditions toggle between event select and arrow; drop "IF" label
- Remove "all events" (*) option from event select
- Add i18n labels for concrete event names (zh/en/ja) via bots.eventNames
- Narrow fallback event set to message.received for adapters without
  declared supported_events (legacy adapters only emit message.received)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Only surface `ns.*` wildcard when the namespace has 2+ concrete events,
  so single-event adapters (legacy) show just the one event
- Show raw event code as a muted subtitle under each option's label

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a trailing badge (icon + label) to each entry in the sidebar Agent
section so users can tell Agent orchestration apart from legacy Pipeline.
Thread the agent `kind` field through SidebarEntityItem.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the text label; keep the icon with a title tooltip so names have
more room in the narrow sidebar.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a toggle (left of the "+" button) that groups the Agent section by
kind, showing "Agent" and "Pipeline" sub-headers. State persists in
localStorage, mirroring the extensions group-by-type pattern.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Add group-by-type button to extensions category header (mirrors the
  agent group-by-kind pattern) — syncs with the extensions page Switch
  via shared SidebarDataContext state
- Relocate both group and refresh controls to sit left-aligned
  immediately after the title for both Agent and Extensions sections
- Add plugins.groupByTypeShort i18n key to all 8 locales

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts:
#	src/langbot/pkg/pipeline/preproc/preproc.py
#	src/langbot/pkg/pipeline/process/handlers/chat.py
#	src/langbot/pkg/provider/runners/localagent.py
#	src/langbot/pkg/provider/tools/toolmgr.py
#	src/langbot/templates/metadata/pipeline/ai.yaml
#	tests/unit_tests/test_preproc.py
#	web/src/app/home/components/dynamic-form/DynamicFormComponent.tsx
#	web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx
# Conflicts:
#	pyproject.toml
#	uv.lock
#	web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eh: Feature enhance: 新功能添加 / add new features IM: aiocqhttp OneBot 协议适配器相关 / OneBot adapter related IM: Discord Discord 适配器相关 / Discord adapter related IM: Lark 飞书 Lark 适配器相关 / Lark adapter related IM: qqofficial QQ 官方 API Webhook 适配器相关 / QQ API (Webhook) adapter related m: Lifecycle 启动/关闭流程 / Bootstrap & application life cycle m: Platform 机器人管理相关 / Bots management m: Plugins 插件加载及管理模块 / Plugins loading and management size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants