feat: add the hierarchical Execution engine on LangGraph
Increment 4 of .scratch/solution-architect-agent/spec.md, test-first. - app/agents/runtime.py: framework-neutral AgentRuntime interface (RoleSpec, AgentTask, ToolSpec, outcomes); fake_runtime.py replays scripted tool calls through the real tools with step budgets. - app/execution/graph.py: Orchestrator turn fans out to parallel Specialist tasks (Send), pauses with interrupt() for questions, Approvals and cloud-read permission, and finalizes or ends with warnings. Only the Orchestrator turn writes the Ledger. - app/execution/tools.py: Orchestrator tools, Specialist submit and needs_input, and the cloud-read permission gate. - app/execution/engine.py: ExecutionEngine.start/resume returning an Interaction; the single interface for A2A, /generate and eval. - Recorders (in-memory, DatabaseManager), configurable checkpointer (memory, sqlite, postgres), engine settings, langgraph checkpoint dependencies. - 19 new tests; full suite 121 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
35
app/execution/state.py
Normal file
35
app/execution/state.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""The checkpointed state of one Execution. Plain, JSON-compatible data only."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import operator
|
||||
from typing import Annotated, Any, TypedDict
|
||||
|
||||
|
||||
class ExecutionState(TypedDict, total=False):
|
||||
execution_id: str
|
||||
session_id: str
|
||||
workflow_request: str
|
||||
pre_approved: bool
|
||||
allow_cloud_read: bool | None
|
||||
|
||||
ledger: dict[str, Any] # Ledger.to_dict()
|
||||
deliverables: dict[str, dict[str, Any]] # kind -> {content, attachments}
|
||||
|
||||
conversation: list[dict[str, str]] # {"from": "user" | "orchestrator", "text"}
|
||||
notes: list[str] # facts for the Orchestrator's next turn
|
||||
pending_questions: list[dict[str, Any]] # {kind, questions} not yet asked
|
||||
awaiting_questions: list[dict[str, Any]] # {kind, questions} asked, not answered
|
||||
answers: dict[str, list[dict[str, Any]]] # kind -> [{questions, reply}]
|
||||
pending_permission: dict[str, Any] | None # {tier, requested_by}
|
||||
prompt: dict[str, Any] | None # what the user is being asked
|
||||
|
||||
# Specialist outcomes, appended concurrently by parallel Specialist tasks and
|
||||
# applied to the Ledger by the next Orchestrator turn.
|
||||
outcomes: Annotated[list[dict[str, Any]], operator.add]
|
||||
outcomes_applied: int
|
||||
events_recorded: int
|
||||
|
||||
turns: int
|
||||
status: str # running | completed | completed_with_warnings
|
||||
warnings: list[str]
|
||||
Reference in New Issue
Block a user