Coverage for app / models / simulation.py: 100%
44 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-31 11:23 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-31 11:23 +0000
1from __future__ import annotations
3from typing import Any
4from uuid import UUID
6from pydantic import BaseModel, Field
9class SimulationAgentSpec(BaseModel):
10 """Resolved agent descriptor passed from svc-core."""
12 agent_id: UUID
13 name: str
14 system_prompt: str | None = None
15 model: dict[str, Any] = Field(
16 default_factory=lambda: {
17 "provider": "openai", # "anthropic",
18 "model": "gpt-4o-mini", # "claude-haiku-4-5-20251001",
19 "temperature": 0.7,
20 "max_tokens": 1024,
21 }
22 )
23 tools: list[dict[str, Any]] = []
26class SimulationWorldSpec(BaseModel):
27 id: UUID
28 name: str
29 description: str | None = None
30 rules: dict[str, Any] = {}
31 logic: dict[str, Any] = {}
34class SimulationScenarioSpec(BaseModel):
35 id: UUID
36 name: str
37 description: str | None = None
38 strategy: str = "cooperative"
39 config: dict[str, Any] = {}
40 tags: list[str] = []
43class SimulationRunRequest(BaseModel):
44 simulation_id: UUID
45 world: SimulationWorldSpec
46 scenario: SimulationScenarioSpec | None = None
47 agents: list[SimulationAgentSpec]
48 initial_prompt: str | None = None
49 # Who ran the simulation — for the trace.
50 user_id: str | None = None
53class RoundResult(BaseModel):
54 round_number: int
55 agent_outputs: dict[str, str] # agent_id (str) → final synthesis output
56 artifacts: dict[
57 str, list[str]
58 ] = {} # agent_id → tool result strings from this round
59 terminated: bool = False
60 termination_reason: str | None = None
63class SimulationRunResult(BaseModel):
64 simulation_id: UUID
65 status: str # "completed" | "failed"
66 rounds: list[RoundResult] = []
67 final_summary: str | None = None
68 metrics: dict[str, Any] = {}
69 total_tokens: int = 0
70 error: str | None = None