haive.agents.supervisor.state¶
State management for Dynamic Supervisor V2.
This module defines the state structures used by the dynamic supervisor to track agents, tasks, metrics, and workflow execution.
Classes¶
Represents an active agent instance in the supervisor. |
|
State structure for dynamic supervisor execution. |
|
Metrics tracking for the supervisor's performance. |
Functions¶
|
Create initial state for dynamic supervisor. |
Module Contents¶
- class haive.agents.supervisor.state.ActiveAgent(/, **data)¶
Bases:
pydantic.BaseModelRepresents an active agent instance in the supervisor.
- Parameters:
data (Any)
- name¶
Unique identifier for the agent
- instance¶
The actual agent instance (excluded from serialization)
- capability¶
Full capability metadata for this agent
- created_at¶
When this agent was instantiated
- last_task¶
Description of the last task assigned
- task_count¶
Number of tasks completed
- total_execution_time¶
Cumulative execution time in seconds
- error_count¶
Number of errors encountered
- state¶
Current agent state (idle, busy, error)
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- update_metrics(execution_time, success=True)¶
Update agent metrics after task execution.
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class haive.agents.supervisor.state.DynamicSupervisorState¶
Bases:
TypedDictState structure for dynamic supervisor execution.
This TypedDict defines the state that flows through the supervisor’s execution graph in LangGraph.
- messages¶
Conversation history (LangGraph standard)
- active_agents¶
Currently instantiated agents
- agent_capabilities¶
All known agent capabilities
- discovered_agents¶
Set of agent names that have been discovered
- available_specs¶
Agent specifications that can be instantiated
- current_agent¶
Name of agent handling current task
- agent_task¶
Task assigned to current agent
- agent_response¶
Response from current agent
- next_agent¶
Next agent to route to
- supervisor_metrics¶
Performance metrics
- discovery_cache¶
Cache of discovery results
- workflow_state¶
Current workflow state (routing, executing, etc.)
Initialize self. See help(type(self)) for accurate signature.
- class haive.agents.supervisor.state.SupervisorMetrics(/, **data)¶
Bases:
pydantic.BaseModelMetrics tracking for the supervisor’s performance.
- Parameters:
data (Any)
- total_tasks¶
Total tasks processed
- successful_tasks¶
Tasks completed successfully
- failed_tasks¶
Tasks that failed
- agent_creations¶
Number of agents created
- discovery_attempts¶
Number of discovery attempts
- successful_discoveries¶
Successful discoveries
- total_execution_time¶
Total time spent on tasks
- start_time¶
When supervisor was created
- last_task_time¶
Timestamp of last task
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- haive.agents.supervisor.state.create_initial_state(available_specs=None, discovery_cache=None)¶
Create initial state for dynamic supervisor.
- Parameters:
available_specs (list[haive.agents.supervisor.models.AgentSpec] | None) – Initial agent specifications
discovery_cache (dict[str, list[haive.agents.supervisor.models.AgentSpec]] | None) – Pre-populated discovery cache
- Returns:
Initialized supervisor state
- Return type: