Commit Graph

21 Commits

Author SHA1 Message Date
huanghuoguoguo
0705680ed7 docs(agent-runner): align runner protocol boundaries 2026-06-03 17:41:52 +08:00
huanghuoguoguo
a25d9e0ef2 fix(agent-runner): stabilize event context and streams 2026-06-03 17:41:52 +08:00
huanghuoguoguo
2ee4880ff6 refactor(agent-runner): tighten protocol v1 runtime boundaries 2026-06-03 17:41:52 +08:00
huanghuoguoguo
69c4749e84 feat(agent-runner): align protocol adapter terminology 2026-06-03 17:41:52 +08:00
huanghuoguoguo
a0d15ea054 feat(agent-runner): route pipeline runs through event-first flow
- 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.
2026-06-03 17:41:52 +08:00
huanghuoguoguo
fa6b40a82b feat(agent-runner): add persistent state APIs 2026-06-03 17:41:52 +08:00
huanghuoguoguo
ad6bf5b478 feat(agent-runner): scope event-first state by binding 2026-06-03 17:41:52 +08:00
huanghuoguoguo
92d28bfcb0 feat(agent-runner): persist created artifacts 2026-06-03 17:41:52 +08:00
huanghuoguoguo
6fc93235f7 feat(agent-runner): add artifact store pull APIs 2026-06-03 17:41:52 +08:00
huanghuoguoguo
bf73414884 feat(agent-runner): add event-first context facts and pull APIs
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.
2026-06-03 17:41:52 +08:00
huanghuoguoguo
bc4610a2a9 fix(agent-runner): package context for plugin execution 2026-06-03 17:41:52 +08:00
huanghuoguoguo
be8d30894a feat: make agent runner config schema driven 2026-06-03 17:41:52 +08:00
huanghuoguoguo
0a4009d14c chore(agent): remove v1 wording from runner internals 2026-06-03 17:40:36 +08:00
huanghuoguoguo
5b45c867b4 feat(agent): reserve stable runner event names 2026-06-03 17:40:35 +08:00
huanghuoguoguo
4e0a670fe2 feat(agent-runner): enrich plugin runner host context 2026-06-03 17:40:35 +08:00
huanghuoguoguo
c286f97b26 fix: log agent runner best-effort failures 2026-06-03 17:40:35 +08:00
huanghuoguoguo
95b3ab036c test: address agent runner review comments 2026-06-03 17:40:35 +08:00
huanghuoguoguo
711f12d71f feat: support dynamic agent runner defaults 2026-06-03 17:38:59 +08:00
huanghuoguoguo
d9280f64eb feat(plugin): implement INVOKE_RERANK handler with run-scoped authorization
- 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
2026-06-03 17:38:59 +08:00
huanghuoguoguo
dc82fb584a perf(agent-runner): improve session registry and orchestrator efficiency
- 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>
2026-06-03 17:38:33 +08:00
huanghuoguoguo
d6b8f48e73 feat(agent-runner): integrate AgentRunner Protocol v1 with plugin system
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>
2026-06-03 17:38:12 +08:00