Skip to content

Feat/agent runner plugin#82

Closed
huanghuoguoguo wants to merge 72 commits into
mainfrom
feat/agent-runner-plugin
Closed

Feat/agent runner plugin#82
huanghuoguoguo wants to merge 72 commits into
mainfrom
feat/agent-runner-plugin

Conversation

@huanghuoguoguo

@huanghuoguoguo huanghuoguoguo commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

状态 / Status

QA 完成。 SDK 侧 Agent Runner plugin 支持已联调通过。本 PR 已包含 #2271 的 box 修复(#87 已合入 main,并随本分支 rebase 一起带入)。合并后需发布新 SDK 版本,供 LangBot 侧 bump langbot-plugin pin。

This PR carries the SDK-side AgentRunner Protocol v1 infrastructure and the skill-as-tool resource surface. QA complete; the #2271 box fix is included via rebase. After merge, a new SDK release is needed so LangBot can bump its langbot-plugin pin.

关联 PR / Related PR

关联测试仓库 / Related Testing Repositories

概述 / Overview

提供 AgentRunner Protocol v1 的 SDK 基础设施 + 技能即工具的资源面 / SDK infrastructure for AgentRunner Protocol v1 plus the skill-as-tool resource surface:

  • AgentRunner component 定义、协议实体(AgentRunContext: event / input / context / resources / runtime / delivery)、runtime dispatch、run-scoped Host 拉取 API(history / event / artifact / state)
  • run-scoped MCP bridge(feat(agent-tools): add run-scoped MCP bridge #76)+ LangBot asset gateway(外部 harness 经 MCP 访问 host 资产)
  • ToolResource.parameters(完整 JSON schema 预填,runner 免逐工具 get_tool_detail
  • langbot_list_assets 新增 skills 资产类(外部 harness 技能发现)
  • skill-as-tool resource surface
  • 控制面 / control plane:run ledger 原语、admin control proxy、stats actions
  • box: 容器复用时 extra_mounts 变化则重建容器(#2271 修复,fix(box): recreate sandbox container when extra_mounts change #87

Runtime 组件(src/langbot_plugin/runtime/)按 AGPL 单独授权;其余为 Apache 2.0。

验收 / QA

  • SDK / host / local-agent 单元矩阵全绿,0 新失败
  • 沙箱技能 OPERATE 端到端在 nsjail + docker 均通过(#2271 修复验证):激活技能的 scripts/use.py 读到 data/input.json、写回文件穿透回 host 技能 store,全 exit 0
  • acp / claude-code 外部 harness 经 MCP gateway 发现并触达技能(remote-ssh 经 SSH reverse tunnel,无需 public-url

完整验收矩阵见 LangBot 仓库:skills/skills/langbot-testing/references/skill-all-tool-acceptance.md

@huanghuoguoguo huanghuoguoguo force-pushed the feat/agent-runner-plugin branch from 7aa3464 to 528e46f Compare June 20, 2026 02:13
RockChinQ and others added 29 commits June 22, 2026 11:12
Phase 0 integration complete - LangBot + SDK + runner repo minimal loop verified.

Key changes:
- Add RUN_AGENT action forwarding from runtime to plugin process
- Add AgentRunner to preinitialize_component_classes for initialization
- Implement Protocol v1 entities: AgentRunContext, AgentRunResult, capabilities, permissions
- Add resp_message_id field to Message class for LangBot integration
- Fix AgentInput.message_chain to accept list type (matches LangBot data)
- Add comprehensive tests for AgentRunner protocol

Integration verified: plugin:langbot/local-agent/default returns [stub] Echo response.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…support

- Refactor AgentRunAPIProxy to inherit from LangBotAPIProxy, reducing code duplication
- Pre-compute allowed resource IDs (frozenset) in __init__ for O(1) permission validation
- Add STATE_SCOPE_LITERAL type annotation in AgentRunResult.state_updated()
- Add AgentRunState TypedDict with 4 scopes (conversation, actor, subject, runner)
- Remove unused base64 import from agent_run_api.py
- Update documentation for params and state protocol

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Improve AgentRunAPIProxy with state scope support (conversation/session/run)
- Enhance plugin handler for agent run operations
- Add better error handling and logging
Add record of all 7 runner plugins migration completed on 2026-05-13
- Add INVOKE_RERANK to PluginToRuntimeAction enum
- Add invoke_rerank() method to AgentRunAPIProxy
- Support reranking documents with relevance scores
Reduces code duplication by composing LangBotAPIProxy instead of
directly calling plugin_runtime_handler. Adds get_tool_detail() for
LLM function calling support.

Changes:
- Compose LangBotAPIProxy for delegated API calls
- Add permission validation before each delegation
- Add get_tool_detail() method for tool schema fetching
- Reduce from ~460 lines to ~350 lines
Define Protocol v1 AgentRunContext with required fields: event, delivery,
context (ContextAccess), bootstrap, compatibility, metadata. Add history
and event pull APIs to AgentRunAPIProxy with run_id authorization.

Key changes:
- AgentRunContext: Protocol v1 structure with required event/delivery fields
- AgentEventContext: event_id, event_type, source required
- DeliveryContext: surface, streaming/edit/reaction capabilities
- ContextAccess: inline_policy, available_apis for pull APIs
- BootstrapContext: optional bootstrap messages (NOT core history)
- CompatibilityContext: legacy Query/Pipeline fields for migration
- AgentRunResult factories: all require run_id parameter
- AgentRunAPIProxy: history_page, history_search, event_get, event_page
- PluginToRuntimeAction: HISTORY_PAGE, HISTORY_SEARCH, EVENT_GET, EVENT_PAGE
- Legacy helpers: to_v1_result(run_id), create_legacy_context with event/delivery

Runner docs updated: use ctx.run_id in factories, ctx.bootstrap.messages
instead of ctx.messages (demoted to bootstrap for Protocol v1).
Return structured run.failed events for plugin-side RUN_AGENT failures, enforce plugin readiness before listing or running AgentRunners, and make AgentRunner class declarations flow into manifests.
huanghuoguoguo and others added 24 commits June 22, 2026 11:16
Move the scoped type-check module list out of the test.yml workflow into a
top-level mypy.ini ([mypy] files). The CI step becomes a generic
`uv run mypy`, so the workflow no longer enumerates AgentRunner/MCP/daemon
business modules; the scope is versioned with the source and reproducible
locally with `uv run mypy`.
- ToolResource gains a parameters field (full JSON schema) so the host can
  prefill it and runners build LLM tools without get_tool_detail round-trips
- langbot_list_assets exposes a 'skills' asset class so external harnesses
  can discover pipeline-visible skills under the unified tool model
@RockChinQ

Copy link
Copy Markdown
Member

continue in #88

@RockChinQ RockChinQ closed this Jun 23, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants