Initial commit: add .gitignore and README
This commit is contained in:
79
tests/test_integration_smoke.py
Normal file
79
tests/test_integration_smoke.py
Normal file
@@ -0,0 +1,79 @@
|
||||
"""Full integration smoke test: orchestrator -> planner -> executor -> reflection."""
|
||||
|
||||
from fusionagi.core import EventBus, StateManager, Orchestrator
|
||||
from fusionagi.agents import PlannerAgent, ExecutorAgent, CriticAgent
|
||||
from fusionagi.adapters import StubAdapter
|
||||
from fusionagi.tools import ToolRegistry, ToolDef
|
||||
from fusionagi.memory import ReflectiveMemory
|
||||
from fusionagi.reflection import run_reflection
|
||||
from fusionagi.schemas import AgentMessage, AgentMessageEnvelope
|
||||
|
||||
|
||||
def test_integration_smoke() -> None:
|
||||
bus = EventBus()
|
||||
state = StateManager()
|
||||
orch = Orchestrator(event_bus=bus, state_manager=state)
|
||||
reg = ToolRegistry()
|
||||
reg.register(ToolDef(name="noop", description="No-op", fn=lambda: "ok", permission_scope=["*"]))
|
||||
orch.register_agent("planner", PlannerAgent(adapter=StubAdapter()))
|
||||
orch.register_agent("executor", ExecutorAgent(registry=reg, state_manager=state))
|
||||
orch.register_agent("critic", CriticAgent())
|
||||
|
||||
tid = orch.submit_task(goal="Run a no-op step")
|
||||
env = AgentMessageEnvelope(
|
||||
message=AgentMessage(
|
||||
sender="orch",
|
||||
recipient="planner",
|
||||
intent="plan_request",
|
||||
payload={"goal": "Run no-op"},
|
||||
),
|
||||
task_id=tid,
|
||||
)
|
||||
orch.route_message(env)
|
||||
plan = orch.get_task_plan(tid)
|
||||
if not plan:
|
||||
plan = {
|
||||
"steps": [
|
||||
{
|
||||
"id": "s1",
|
||||
"description": "No-op",
|
||||
"dependencies": [],
|
||||
"tool_name": "noop",
|
||||
"tool_args": {},
|
||||
}
|
||||
],
|
||||
"fallback_paths": [],
|
||||
}
|
||||
env2 = AgentMessageEnvelope(
|
||||
message=AgentMessage(
|
||||
sender="orch",
|
||||
recipient="executor",
|
||||
intent="execute_step",
|
||||
payload={
|
||||
"step_id": "s1",
|
||||
"plan": plan,
|
||||
"tool_name": "noop",
|
||||
"tool_args": {},
|
||||
},
|
||||
),
|
||||
task_id=tid,
|
||||
)
|
||||
orch.route_message(env2)
|
||||
reflective = ReflectiveMemory()
|
||||
run_reflection(
|
||||
orch.get_agent("critic"),
|
||||
tid,
|
||||
"completed",
|
||||
state.get_trace(tid),
|
||||
plan,
|
||||
reflective,
|
||||
)
|
||||
lessons = reflective.get_lessons(limit=5)
|
||||
assert len(lessons) == 1
|
||||
assert lessons[0]["task_id"] == tid
|
||||
assert lessons[0]["outcome"] == "completed"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_integration_smoke()
|
||||
print("Integration smoke test OK")
|
||||
Reference in New Issue
Block a user