feat(agent): AgentRunner runtime dispatcher (Agent SDK migration, phase 2)#30
feat(agent): AgentRunner runtime dispatcher (Agent SDK migration, phase 2)#30PalmPalm7 wants to merge 1 commit into
Conversation
Route a sub-agent task to the legacy Anthropic loop or the Claude Agent SDK adapter based on agent.runtime (legacy|sdk, default legacy), returning the same structured result dict either way. Additive and dormant: nothing in the request path imports it yet (mirrors how the rhpds#24 adapter shipped behind the flag). A follow-up PR wires the Icinga sub-agent to dispatch through it. With the default legacy runtime it is a transparent pass-through to src.agent.agents.run_sub_agent — zero behavior change. The SDK branch surfaces token/cost/cache usage under data.usage, which the Phase-2 cost benchmark compares against legacy. 11 tests: runtime resolution, legacy pass-through, SDK result normalization, and SDK-unavailable error handling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Test results.
|
Code Review — PR #30 (Draft)Scope: 2 files, +402 lines — AgentRunner runtime dispatcher Findings (4)1. SDK path omits today's date from system prompt ( 2. SDK path does not forward conversation_history ( 3. Missing catch-all exception handler in SDK path ( 4. Result dict shape mismatch between runtimes ( Cross-PR noteThe |
What
Adds
src/agent/runner.py— anAgentRunnerthat routes a sub-agent task to either the legacy Anthropic tool-use loop (src.agent.agents.run_sub_agent) or the Claude Agent SDK adapter (src/llm/AgentSdkClient, #24), based on the existingagent.runtimeflag (legacy|sdk, defaultlegacy). Both paths return the same structured result dict.Why
Phase-2 foundation. The orchestrator currently calls
run_sub_agentdirectly; this introduces a single dispatch seam so a sub-agent can be moved onto the SDK behind the flag without touching the request path. The SDK branch surfaces token/cost/cache usage underdata.usage, which the Phase-2 cost benchmark compares against legacy.Scope / safety
legacyruntime,run_sub_agentis a transparent pass-through → zero behavior change.complete()→ normalized result); per-agent skill + tool wiring lands in the Icinga PR.How to test
Result (local gate)
black --check✓ ·ruff check✓ ·mypy✓ (clean on both files)pytest tests/test_agent_runner.py→ 11 passedPart of the Agent SDK migration (Phase 1: #23 skills loader, #24 SDK adapter, #25 Skills UI — all merged). Plan:
artifacts/parsec-agent-sdk-migration-plan.md.