Spaces:
Runtime error
Runtime error
Download src/backend/models/agent_result.py from HAK-Tech/ciro-backend: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/spaces/HAK-Tech/ciro-backend/resolve/main/src/backend/models/agent_result.py
- Command line
-
hf download hf://spaces/HAK-Tech/ciro-backend/src/backend/models/agent_result.py
-
curl -L -o agent_result.py https://huggingface.co/spaces/HAK-Tech/ciro-backend/resolve/main/src/backend/models/agent_result.py
2.05 kB
| """ | |
| AgentResult β the canonical contract every agent in the CIRO pipeline returns. | |
| Why this exists | |
| --------------- | |
| The pipeline (detection β analysis β planning β simulation) chains heterogeneous | |
| agents together. Each stage feeds the next, and the agent-trace UI renders every | |
| step uniformly. To keep that working, every agent β regardless of what it does β | |
| must produce the same outer shape. That shape is `AgentResult`. | |
| `output` is intentionally a free-form dict so individual agents can return their | |
| own domain payload (detection verdict, risk tier, action plan, etc.) without | |
| having to grow this base schema each time a new agent ships. | |
| """ | |
| from datetime import datetime, timezone | |
| from typing import Any | |
| from pydantic import BaseModel, Field | |
| class AgentResult(BaseModel): | |
| """Uniform output every CIRO agent must produce. | |
| Attributes: | |
| agent_name: Stable identifier of the agent that produced this result | |
| (e.g. "detection_agent"). Used in trace logs + downstream routing. | |
| success: True iff the agent completed without raising. A `success=False` | |
| result still carries `reasoning` describing why it failed so the | |
| pipeline can short-circuit gracefully. | |
| output: Free-form domain payload produced by the agent. Each agent | |
| documents its own output keys in its own module. | |
| reasoning: Plain-language explanation of how the agent reached its | |
| decision. Surfaced directly in the in-app agent-trace timeline. | |
| confidence: Self-reported confidence in `output`, clamped to [0, 1]. | |
| Downstream stages (risk tiering, crowd verification) use this. | |
| timestamp: When the result was finalized (UTC). Used for ordering | |
| steps in the trace log. | |
| """ | |
| agent_name: str | |
| success: bool | |
| output: dict[str, Any] = Field(default_factory=dict) | |
| reasoning: str = "" | |
| confidence: float = Field(default=0.0, ge=0.0, le=1.0) | |
| timestamp: datetime = Field(default_factory=lambda: datetime.now(timezone.utc)) | |