Models¶
This page documents the core PydanTask models as defined in pydantask.models.models.
These models define:
- Task lifecycle and evaluation (
TaskStatus,TaskItem,TaskResult,TaskQAResult) - Knowledge and citations (
KnowledgeRecord,SourceRef) - Capabilities and runtime state (
CapabilityDescription,RuntimeState) - Supervisor and planner structures (
SupervisorDecision,Plan,SubAgentInstruction,TaskSpec) - Run/tracing utilities (
DeepAgentRunResult,TracingBackend)
All content below is rendered from the code via mkdocstrings.
Task Lifecycle¶
TaskStatus¶
Bases: Enum
Lifecycle state for a :class:TaskItem within a DeepAgent plan.
Values
PENDING: Waiting for dependencies to complete.
READY: All dependencies met; eligible to run.
RUNNING: Currently being executed by a sub-agent.
COMPLETED: Successfully finished and accepted.
ERRORED: Execution error occurred (tools, runtime, etc.).
FAILED: Evaluator/critic rejected the result.
NEEDS_REVIEW: Needs evaluator/supervisor review.
RERUN: Marked to be re-executed with revised instructions.
CANCELLED: Task that is no longer needed or relevant to complete the objective.
Source code in src/pydantask/models/models.py
TaskQAResult¶
Bases: BaseModel
Evaluation result produced by the critic/QA agent for a single task.
Attributes:
| Name | Type | Description |
|---|---|---|
task_id |
int
|
ID of the :class: |
reasoning |
str
|
Detailed explanation of how the result was judged and why you scored the way you did. |
passed |
bool
|
True if the worker output sufficiently meets the task objective. |
Source code in src/pydantask/models/models.py
TaskResult¶
Bases: BaseModel
Canonical result type for any sub-task executed by DeepAgent.
TaskResult stores the output from any given task.
Attributes:
| Name | Type | Description |
|---|---|---|
task_id |
int
|
ID of the :class: |
status |
TaskStatus
|
Outcome of this task execution (COMPLETED/ERRORED/FAILED/etc.). |
summary |
str
|
Human-readable summary of what this task produced or concluded. |
notes |
List[str]
|
Any notes or scratch references used while completing this task. |
sources |
List[SourceRef]
|
Structured list of :class: |
error_msg |
Optional[str]
|
Explanation of what went wrong if the task errored or failed. |
metadata |
dict
|
Optional free-form metadata specific to this task execution. |
Source code in src/pydantask/models/models.py
TaskItem¶
Bases: BaseModel
One sub-task in a DeepAgent plan.
Created by the planner and then updated over the life of the run as it moves
through :class:TaskStatus states and accumulates results and feedback.
Attributes:
| Name | Type | Description |
|---|---|---|
task_id |
int
|
Unique integer task identifier. Integer value. |
overall_objective |
str
|
The overall objective this task contributes to. |
sub_task_objective |
str
|
The specific objective for this sub-task. |
status |
TaskStatus
|
Current lifecycle state of the task. |
result |
Optional[TaskResult]
|
The :class: |
capability |
str
|
Name of the capability (sub-agent) that should execute this task (e.g. "research_agent", "producer_agent"). |
sub_task_dependencies |
Optional[List[int]]
|
IDs of tasks that must be COMPLETED before this task is eligible to run. |
task_feedback |
Optional[TaskQAResult]
|
Latest :class: |
error_msg |
Optional[str]
|
Any error message associated with this task. |
iteration_history |
List
|
Optional history of prior attempts/outputs. |
time_scope |
Optional[str]
|
Optional temporal scope string ("2026", "last 7 days", etc.). |
parameters |
dict
|
Arbitrary structured parameters (e.g. supervisor feedback). |
attempt_count |
int
|
How many times this task has been attempted. |
max_attempts |
int
|
Maximum times this task is allowed to be attempted. |
metadata |
dict
|
Optional free-form metadata for this task. |
Source code in src/pydantask/models/models.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
Knowledge and Sources¶
KnowledgeRecord¶
Bases: BaseModel
Logical record of a knowledge artifact (file, summary, notes, etc.).
Stored in :class:RuntimeState.knowledge_store to track long-lived documents
and their relationship to tasks.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Logical identifier (what tools use as key). |
path |
Optional[str]
|
Filesystem path if this record is backed by a file. |
task_ids |
list[int]
|
IDs of TaskItems this record is associated with. |
summary |
Optional[str]
|
Short human-readable description of the content. |
source_task_ids |
List[int]
|
IDs of tasks that produced or updated this record. |
created_at |
datetime
|
Timestamp when the record was created. |
metadata |
dict
|
Arbitrary extra info (tags, type=research/plan/etc.). |
Source code in src/pydantask/models/models.py
SourceRef¶
Bases: BaseModel
Structured citation / source reference used in TaskResult.sources.
Each id is intended to be referenced from text as [id] (e.g., [1]).
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Short integer identifier used in inline citations. |
kind |
Literal['web', 'document', 'code', 'data', 'other']
|
Type of source (web page, document, code, data, other). |
title |
Optional[str]
|
Human-readable title of the source, if available. |
url |
Optional[str]
|
URL for online sources. |
path |
Optional[str]
|
Filesystem path or document ID for local artifacts. |
snippet |
Optional[str]
|
Short excerpt of key evidence taken from this source. |
accessed_at |
Optional[datetime]
|
When this source was accessed (for date-sensitive content). |
metadata |
Dict[str, Any]
|
Extra structured info (author, publisher, etc.). |
Source code in src/pydantask/models/models.py
Capabilities and Runtime State¶
CapabilityDescription¶
Bases: BaseModel
Metadata describing a capability (sub-agent or tool) available to DeepAgent.
The planner and supervisor see name and description when deciding
which capability to assign to TaskItem.capability. tool_func holds
the underlying implementation (often a :class:pydantic_ai.Agent or
callable tool).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Identifier of the capability (e.g. "research_agent"). |
description |
str
|
Human-readable description of what this capability does. |
tool_func |
Any
|
Concrete implementation (agent instance or callable tool). |
input_schema |
Optional[type[BaseModel]]
|
Optional Pydantic model class describing structured input for this capability. |
Source code in src/pydantask/models/models.py
RuntimeState¶
Bases: BaseModel
Shared mutable state passed between agents during a DeepAgent run.
Holds the current plan, objective, registry of capabilities, and simple in-memory stores for documents and knowledge.
Attributes:
| Name | Type | Description |
|---|---|---|
plan |
Dict[int, TaskItem]
|
Mapping from task_id to :class: |
objective |
str
|
The overall user objective being solved. |
capability_registry |
Dict[str, Any]
|
Mapping from capability name to its description/ implementation (excluded from serialization). |
completed_steps |
set[int]
|
Set of task_ids that have been completed. |
runtime_steps |
int
|
Number of outer control-loop cycles executed so far. |
tokens_used |
int
|
Placeholder for token accounting. |
task_queue |
List[TaskItem]
|
Optional queue of additional tasks. |
knowledge_store |
Dict[str, KnowledgeRecord]
|
Mapping of logical IDs to :class: |
document_store |
Dict[str, str]
|
Mapping of logical document keys to in-memory content or identifiers. |
Source code in src/pydantask/models/models.py
Supervisor and Planner Models¶
SupervisorDecision¶
Bases: BaseModel
Supervisor's decision for a single control-loop iteration.
Attributes:
| Name | Type | Description |
|---|---|---|
reasoning |
str
|
Explanation of why particular tasks were chosen or why the run should end. |
tasks_to_execute |
List[int]
|
IDs of tasks that should be executed next. |
feedback_to_subagents |
Optional[Dict[int, str]]
|
Optional mapping from task_id to feedback string to be injected into sub-agent execution. |
all_tasks_completed |
bool
|
True if the plan is complete or cannot be progressed further. |
Source code in src/pydantask/models/models.py
Plan¶
Bases: BaseModel
Planner output: internal reasoning plus the list of tasks.
DeepAgent converts tasks into a Dict[int, TaskItem] for
:class:RuntimeState.plan.
Attributes:
| Name | Type | Description |
|---|---|---|
reasoning_steps |
str
|
Planner's internal reasoning/chain-of-thought. |
tasks |
list[TaskItem]
|
Ordered list of :class: |
Source code in src/pydantask/models/models.py
SubAgentInstruction¶
Bases: BaseModel
Helper model for passing structured instructions to a sub-agent.
Attributes:
| Name | Type | Description |
|---|---|---|
reasoning |
Optional[str]
|
Optional reasoning or context for the instructions. |
instructions |
str
|
Concrete instructions the sub-agent should follow. |
Source code in src/pydantask/models/models.py
TaskSpec¶
Bases: BaseModel
Specification for a planned task, useful for external planners/tools.
Attributes:
| Name | Type | Description |
|---|---|---|
task_id |
int
|
ID of the task. |
task_objective |
str
|
Human-readable objective for this task. |
capability |
Literal['researcher', 'writer', 'synthesizer']
|
High-level capability type (researcher, writer, synthesizer). |
inputs |
dict
|
Structured inputs the task expects. |
success_criteria |
str
|
How to decide if the task was successful. |
constraints |
list[str]
|
List of constraints or guidelines for execution. |
overall_objective |
str
|
The broader objective this task serves. |
Source code in src/pydantask/models/models.py
Run and Tracing¶
DeepAgentRunResult¶
Bases: BaseModel
High-level summary of a DeepAgent run.
Wraps the final :class:TaskResult (if any) together with the final plan,
runtime statistics, and high-level status. Suitable as a public return type
from :meth:DeepAgent.run.
Attributes:
| Name | Type | Description |
|---|---|---|
objective |
str
|
The original user objective. |
final_result |
Optional[TaskResult]
|
The final :class: |
status |
Optional[TaskResult]
|
High-level outcome of the run (success/partial/failed). |
plan |
Dict[int, TaskItem]
|
Final mapping from task_id to :class: |
runtime_steps |
Dict[int, TaskItem]
|
Number of DeepAgent control-loop cycles executed. |
errors |
list[str]
|
Any top-level errors or important warnings. |