Feat/agent runner plugin#2210
Draft
huanghuoguoguo wants to merge 32 commits into
Draft
Conversation
Phase 0 integration complete - verified minimal loop with local-agent stub runner. Changes: - Add AgentRunOrchestrator for plugin-based agent execution - Add AgentResultNormalizer for Protocol v1 result conversion - Add AgentRunnerDescriptor for runner ID parsing (plugin:author/name/runner) - Update chat handler to use new orchestrator instead of direct runner lookup - Add plugin handler methods for list_agent_runners and run_agent - Add connector methods for AgentRunner protocol forwarding - Update pipeline API to include runner options in metadata - Add integration docs and implementation plan Integration verified: - Runner: plugin:langbot/local-agent/default - Input: "你好" - Output: [stub] Echo: 你好 - Date: 2026-05-10 10:09 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add pre-computed _authorized_ids (frozenset) at session registration for O(1) lookup - Refactor is_resource_allowed() from linear search to set membership check - Add thread-safe locking to get_session_registry() singleton - Cache _session_registry and _state_store references in orchestrator __init__ - Add asyncio.gather() for parallel resource building in AgentResourceBuilder - Create shared test fixtures in tests/unit_tests/agent/conftest.py - Update test files to import from shared conftest.py Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add DEPRECATED docstring to all legacy runners in pkg/provider/runners/ - Mark migration target for each runner (local-agent, dify, n8n, coze, dashscope, langflow, tbox) - Add PROGRESS.md to track agent-runner-pluginization implementation status - Remove completed PHASE0_INTEGRATION_RECORD.md
…zation - Add invoke_rerank action handler in plugin handler - Validate rerank model access via run session - Cap documents at 64 for API limit - Return sorted results by relevance score
Add unified tool lookup method that searches both plugin and MCP loaders. Also add _get_tool method to MCPLoader for consistency with PluginToolLoader.
5e9c854 to
19557c3
Compare
This was referenced May 19, 2026
Add EventLog and Transcript persistence entities for storing auditable event facts and conversation history projection. Implement event-first AgentRunContext builder that produces Protocol v1 compliant context payloads with required fields: event, delivery, context (ContextAccess). Key changes: - EventLog ORM: auditable event records with indexes - Transcript ORM: conversation history projection with composite indexes - AgentRunContextBuilder: Protocol v1 payload with delivery, context, bootstrap - EventLogStore/TranscriptStore: async stores for fact sources - Host action handlers: HISTORY_PAGE, HISTORY_SEARCH, EVENT_GET, EVENT_PAGE - Context validation: build_context output validates via SDK AgentRunContext - Alembic migration for event_log and transcript tables - Alembic env.py imports all ORM models for autogenerate discovery Legacy compatibility: max-round messages go into bootstrap.messages and compatibility.legacy_messages, not top-level messages field.
- run_from_query() now delegates to run(event, binding) instead of maintaining a separate legacy execution path - Pipeline Query is converted to AgentEventEnvelope via PipelineCompatAdapter - Pipeline config is converted to AgentBinding with StatePolicy - bound_plugins authorization preserved from Pipeline - Legacy compatibility fields preserved: - query_id → context.runtime.query_id → session registry - prompt → context.compatibility.extra.prompt (not top-level) - params → context.compatibility.extra.params (with proper filtering) - max-round → bootstrap.messages and compatibility.legacy_messages - Pipeline path gains event-first host capabilities: - EventLog and Transcript writing - ArtifactStore registration - PersistentStateStore for state.updated - Removed legacy handlers: - _handle_artifact_created_query() (replaced by _handle_artifact_created) - _handle_state_updated() (replaced by _handle_state_updated_event) This change unifies the execution path while preserving backward compatibility for Pipeline-based runners. EventGateway is not implemented in this branch; only the event-first entry point is reserved.
| def mock_session_registry(self): | ||
| """Create a fresh session registry for testing.""" | ||
| # Reset global registry | ||
| import langbot.pkg.agent.runner.session_registry as reg |
| @pytest.fixture | ||
| def session_registry(self): | ||
| """Create a fresh session registry for testing.""" | ||
| import langbot.pkg.agent.runner.session_registry as reg |
Comment on lines
+18
to
+36
| from langbot.pkg.entity.persistence import ( | ||
| agent_runner_state, | ||
| apikey, | ||
| artifact, | ||
| bot, | ||
| bstorage, | ||
| event_log, | ||
| mcp, | ||
| metadata, | ||
| model, | ||
| monitoring, | ||
| pipeline, | ||
| plugin, | ||
| rag, | ||
| transcript, | ||
| user, | ||
| vector, | ||
| webhook, | ||
| ) |
| from sqlalchemy.orm import sessionmaker | ||
|
|
||
| from ...entity.persistence.event_log import EventLog | ||
| from ...entity.persistence.transcript import Transcript |
Comment on lines
+10
to
+16
| from langbot_plugin.api.entities.builtin.agent_runner.event import ( | ||
| AgentEventContext, | ||
| ConversationContext, | ||
| ActorContext, | ||
| SubjectContext, | ||
| RawEventRef, | ||
| ) |
|
|
||
| import typing | ||
| import json | ||
| import asyncio |
| from sqlalchemy.ext.asyncio import AsyncEngine | ||
| from sqlalchemy import select, delete, update | ||
|
|
||
| from langbot_plugin.api.entities.builtin.pipeline import query as pipeline_query |
| from __future__ import annotations | ||
|
|
||
| import typing | ||
| import time |
| ) | ||
| from langbot_plugin.api.entities.builtin.agent_runner.input import AgentInput | ||
| from langbot_plugin.api.entities.builtin.agent_runner.delivery import DeliveryContext | ||
| from langbot_plugin.api.entities.builtin.agent_runner.trigger import AgentTrigger |
| from unittest.mock import MagicMock, AsyncMock, patch | ||
| import base64 | ||
| import datetime | ||
| import asyncio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
状态 / Status
测试中,请勿合并。
该 PR 是 LangBot 侧 Agent Runner Plugin 联调入口,当前需要和 Plugin SDK PR 以及两个 runner 仓库一起测试。
关联 PR / Related PR
关联测试仓库 / Related Testing Repositories
当前测试重点 / Current Test Focus
概述 / Overview
更改前后对比截图 / Screenshots
检查清单 / Checklist
PR 作者完成 / For PR author
请在方括号间写
x以打勾 / Please tick the box withx项目维护者完成 / For project maintainer