HR¶
Agent lifecycle management -- hiring, firing, onboarding, offboarding, performance tracking, and promotion/demotion.
Models¶
models
¶
HR domain models.
Frozen Pydantic models for hiring, firing, onboarding, offboarding, and agent lifecycle events.
CandidateCard
pydantic-model
¶
Bases: BaseModel
Generated candidate for a hiring request.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique candidate identifier. |
name |
NotBlankStr
|
Proposed agent name. |
role |
NotBlankStr
|
Proposed role. |
department |
NotBlankStr
|
Target department. |
level |
SeniorityLevel
|
Proposed seniority level. |
skills |
tuple[NotBlankStr, ...]
|
Agent skills. |
rationale |
NotBlankStr
|
Why this candidate was generated. |
estimated_monthly_cost |
float
|
Estimated monthly cost in USD (base currency). |
template_source |
NotBlankStr | None
|
Template used for generation, if any. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
name(NotBlankStr) -
role(NotBlankStr) -
department(NotBlankStr) -
level(SeniorityLevel) -
skills(tuple[NotBlankStr, ...]) -
rationale(NotBlankStr) -
estimated_monthly_cost(float) -
template_source(NotBlankStr | None)
estimated_monthly_cost
pydantic-field
¶
Estimated monthly cost in USD (base currency)
HiringRequest
pydantic-model
¶
Bases: BaseModel
Request to hire a new agent.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique request identifier. |
requested_by |
NotBlankStr
|
Agent or human who initiated the request. |
department |
NotBlankStr
|
Target department. |
role |
NotBlankStr
|
Desired role. |
level |
SeniorityLevel
|
Desired seniority level. |
required_skills |
tuple[NotBlankStr, ...]
|
Skills the candidate must have. |
reason |
NotBlankStr
|
Business justification. |
budget_limit_monthly |
float | None
|
Maximum monthly cost, if constrained. |
template_name |
NotBlankStr | None
|
Template to use for candidate generation. |
status |
HiringRequestStatus
|
Current request status. |
created_at |
AwareDatetime
|
When the request was created. |
candidates |
tuple[CandidateCard, ...]
|
Generated candidate cards. |
selected_candidate_id |
NotBlankStr | None
|
ID of the chosen candidate. |
approval_id |
NotBlankStr | None
|
ID of the associated approval item. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
requested_by(NotBlankStr) -
department(NotBlankStr) -
role(NotBlankStr) -
level(SeniorityLevel) -
required_skills(tuple[NotBlankStr, ...]) -
reason(NotBlankStr) -
budget_limit_monthly(float | None) -
template_name(NotBlankStr | None) -
status(HiringRequestStatus) -
created_at(AwareDatetime) -
candidates(tuple[CandidateCard, ...]) -
selected_candidate_id(NotBlankStr | None) -
approval_id(NotBlankStr | None)
Validators:
-
_validate_status_candidate_consistency
FiringRequest
pydantic-model
¶
Bases: BaseModel
Request to terminate an agent.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique request identifier. |
agent_id |
NotBlankStr
|
Agent to be terminated. |
agent_name |
NotBlankStr
|
Agent's display name. |
reason |
FiringReason
|
Reason for termination. |
requested_by |
NotBlankStr
|
Initiator of the firing. |
details |
str
|
Additional context. |
created_at |
AwareDatetime
|
When the request was created. |
completed_at |
AwareDatetime | None
|
When the firing was completed. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
agent_name(NotBlankStr) -
reason(FiringReason) -
requested_by(NotBlankStr) -
details(str) -
created_at(AwareDatetime) -
completed_at(AwareDatetime | None)
Validators:
-
_validate_temporal_order
OnboardingStepRecord
pydantic-model
¶
Bases: BaseModel
Record of a single onboarding step.
Attributes:
| Name | Type | Description |
|---|---|---|
step |
OnboardingStep
|
The onboarding step. |
completed |
bool
|
Whether this step is complete. |
completed_at |
AwareDatetime | None
|
When this step was completed. |
notes |
str
|
Optional notes from the step. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
step(OnboardingStep) -
completed(bool) -
completed_at(AwareDatetime | None) -
notes(str)
Validators:
-
_validate_completed_consistency
OnboardingChecklist
pydantic-model
¶
Bases: BaseModel
Agent onboarding checklist tracking all steps.
Attributes:
| Name | Type | Description |
|---|---|---|
agent_id |
NotBlankStr
|
Agent being onboarded. |
steps |
tuple[OnboardingStepRecord, ...]
|
Individual step records. |
started_at |
AwareDatetime
|
When onboarding began. |
completed_at |
AwareDatetime | None
|
When all steps were completed. |
is_complete |
bool
|
Whether all steps are done (computed). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
agent_id(NotBlankStr) -
steps(tuple[OnboardingStepRecord, ...]) -
started_at(AwareDatetime) -
completed_at(AwareDatetime | None)
Validators:
-
_validate_completion_consistency
OffboardingRecord
pydantic-model
¶
Bases: BaseModel
Record of a completed offboarding process.
Attributes:
| Name | Type | Description |
|---|---|---|
agent_id |
NotBlankStr
|
Agent who was offboarded. |
agent_name |
NotBlankStr
|
Agent's display name. |
firing_request_id |
NotBlankStr
|
Associated firing request. |
tasks_reassigned |
tuple[NotBlankStr, ...]
|
IDs of reassigned tasks. |
memory_archive_id |
NotBlankStr | None
|
ID of the memory archive, if created. |
org_memories_promoted |
int
|
Number of memories promoted to org. |
team_notification_sent |
bool
|
Whether team was notified. |
started_at |
AwareDatetime
|
When offboarding started. |
completed_at |
AwareDatetime
|
When offboarding finished. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
agent_id(NotBlankStr) -
agent_name(NotBlankStr) -
firing_request_id(NotBlankStr) -
tasks_reassigned(tuple[NotBlankStr, ...]) -
memory_archive_id(NotBlankStr | None) -
org_memories_promoted(int) -
team_notification_sent(bool) -
started_at(AwareDatetime) -
completed_at(AwareDatetime)
Validators:
-
_validate_temporal_order
AgentLifecycleEvent
pydantic-model
¶
Bases: BaseModel
Record of an agent lifecycle event.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique event identifier. |
agent_id |
NotBlankStr
|
Agent the event relates to. |
agent_name |
NotBlankStr
|
Agent's display name. |
event_type |
LifecycleEventType
|
Type of lifecycle event. |
timestamp |
AwareDatetime
|
When the event occurred. |
initiated_by |
NotBlankStr
|
Who triggered the event. |
details |
str
|
Human-readable event details. |
metadata |
dict[str, str]
|
Additional structured metadata. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
agent_name(NotBlankStr) -
event_type(LifecycleEventType) -
timestamp(AwareDatetime) -
initiated_by(NotBlankStr) -
details(str) -
metadata(dict[str, str])
Registry¶
registry
¶
Agent registry service.
Hot-pluggable agent registry for tracking active agents, their identities, and lifecycle status transitions (D8.3).
AgentRegistryService
¶
Hot-pluggable agent registry.
Coroutine-safe via asyncio.Lock within a single event loop. Stores agent identities keyed by agent ID (string form of UUID).
Source code in src/synthorg/hr/registry.py
register
async
¶
Register a new agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identity
|
AgentIdentity
|
The agent identity to register. |
required |
Raises:
| Type | Description |
|---|---|
AgentAlreadyRegisteredError
|
If the agent is already registered. |
Source code in src/synthorg/hr/registry.py
unregister
async
¶
Remove an agent from the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
The agent identifier to remove. |
required |
Returns:
| Type | Description |
|---|---|
AgentIdentity
|
The removed agent identity. |
Raises:
| Type | Description |
|---|---|
AgentNotFoundError
|
If the agent is not found. |
Source code in src/synthorg/hr/registry.py
get
async
¶
Retrieve an agent identity by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
The agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
AgentIdentity | None
|
The agent identity, or None if not found. |
Source code in src/synthorg/hr/registry.py
get_by_name
async
¶
Retrieve an agent identity by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
NotBlankStr
|
The agent name to search for. |
required |
Returns:
| Type | Description |
|---|---|
AgentIdentity | None
|
The first matching agent, or None. |
Source code in src/synthorg/hr/registry.py
list_active
async
¶
List all agents with ACTIVE status.
Returns:
| Type | Description |
|---|---|
tuple[AgentIdentity, ...]
|
Tuple of active agent identities. |
Source code in src/synthorg/hr/registry.py
list_by_department
async
¶
List agents in a specific department.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
department
|
NotBlankStr
|
Department name to filter by. |
required |
Returns:
| Type | Description |
|---|---|
tuple[AgentIdentity, ...]
|
Tuple of matching agent identities. |
Source code in src/synthorg/hr/registry.py
update_status
async
¶
Update an agent's lifecycle status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
The agent identifier. |
required |
status
|
AgentStatus
|
New status. |
required |
Returns:
| Type | Description |
|---|---|
AgentIdentity
|
Updated agent identity. |
Raises:
| Type | Description |
|---|---|
AgentNotFoundError
|
If the agent is not found. |
Source code in src/synthorg/hr/registry.py
update_identity
async
¶
Update agent identity fields via model_copy(update=...).
Only fields in _UPDATABLE_FIELDS are accepted. Use
update_status for status changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
The agent identifier. |
required |
**updates
|
Any
|
Fields to update on the AgentIdentity. |
{}
|
Returns:
| Type | Description |
|---|---|
AgentIdentity
|
Updated agent identity. |
Raises:
| Type | Description |
|---|---|
AgentNotFoundError
|
If the agent is not found. |
ValueError
|
If any field is not in the allowlist. |
Source code in src/synthorg/hr/registry.py
Hiring Service¶
hiring_service
¶
Hiring service.
Orchestrates the hiring pipeline: request creation, candidate generation, approval submission, and agent instantiation.
HiringService
¶
HiringService(
*, registry, approval_store=None, onboarding_service=None, default_model_config=None
)
Orchestrates the hiring pipeline.
Manages the lifecycle of hiring requests from creation through candidate generation, approval, and agent instantiation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry
|
AgentRegistryService
|
Agent registry for registering new agents. |
required |
approval_store
|
ApprovalStore | None
|
Optional approval store for human approval. |
None
|
onboarding_service
|
OnboardingService | None
|
Optional onboarding service to start onboarding after instantiation. |
None
|
default_model_config
|
ModelConfig | None
|
Optional default model configuration for newly created agents. Falls back to generic defaults if not provided. |
None
|
Source code in src/synthorg/hr/hiring_service.py
create_request
async
¶
create_request(
*,
requested_by,
department,
role,
level,
required_skills=(),
reason,
budget_limit_monthly=None,
template_name=None,
)
Create a new hiring request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requested_by
|
NotBlankStr
|
Request initiator. |
required |
department
|
NotBlankStr
|
Target department. |
required |
role
|
NotBlankStr
|
Desired role. |
required |
level
|
str
|
Desired seniority level. |
required |
required_skills
|
tuple[NotBlankStr, ...]
|
Required skills. |
()
|
reason
|
NotBlankStr
|
Business justification. |
required |
budget_limit_monthly
|
float | None
|
Optional monthly budget limit. |
None
|
template_name
|
str | None
|
Template for candidate generation. |
None
|
Returns:
| Type | Description |
|---|---|
HiringRequest
|
The created hiring request. |
Source code in src/synthorg/hr/hiring_service.py
generate_candidate
async
¶
Generate a candidate card for a hiring request.
Builds a CandidateCard from role/level defaults. In the
future, this can be extended with template presets and LLM
customization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HiringRequest
|
The hiring request to generate a candidate for. |
required |
Returns:
| Type | Description |
|---|---|
HiringRequest
|
Updated request with the new candidate appended. |
Source code in src/synthorg/hr/hiring_service.py
submit_for_approval
async
¶
Submit a candidate for approval.
If no approval store is configured, auto-approves the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HiringRequest
|
The hiring request. |
required |
candidate_id
|
str
|
ID of the candidate to approve. |
required |
Returns:
| Type | Description |
|---|---|
HiringRequest
|
Updated request with approval status. |
Raises:
| Type | Description |
|---|---|
InvalidCandidateError
|
If the candidate ID is not found. |
Source code in src/synthorg/hr/hiring_service.py
instantiate_agent
async
¶
Instantiate an agent from an approved hiring request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HiringRequest
|
The approved hiring request. |
required |
Returns:
| Type | Description |
|---|---|
AgentIdentity
|
The newly created agent identity. |
Raises:
| Type | Description |
|---|---|
HiringApprovalRequiredError
|
If request is not approved. |
HiringRejectedError
|
If request was rejected. |
InvalidCandidateError
|
If no candidate is selected. |
HiringError
|
If instantiation fails. |
Source code in src/synthorg/hr/hiring_service.py
Onboarding Service¶
onboarding_service
¶
Onboarding service.
Manages agent onboarding checklists, step tracking, and automatic activation upon checklist completion.
OnboardingService
¶
Manages onboarding checklists and step tracking.
Creates checklists with all OnboardingStep values when
onboarding starts. When all steps are completed, automatically
transitions the agent to ACTIVE status via the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry
|
AgentRegistryService
|
Agent registry for status updates. |
required |
Source code in src/synthorg/hr/onboarding_service.py
start_onboarding
async
¶
Start onboarding for a newly hired agent.
Creates a checklist with all onboarding steps in PENDING state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
Agent to onboard. |
required |
Returns:
| Type | Description |
|---|---|
OnboardingChecklist
|
The created onboarding checklist. |
Raises:
| Type | Description |
|---|---|
OnboardingError
|
If a checklist already exists. |
Source code in src/synthorg/hr/onboarding_service.py
complete_step
async
¶
Mark an onboarding step as complete.
When all steps are completed, automatically transitions the agent to ACTIVE status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
Agent being onboarded. |
required |
step
|
OnboardingStep
|
The step to complete. |
required |
notes
|
str
|
Optional notes for the step. |
''
|
Returns:
| Type | Description |
|---|---|
OnboardingChecklist
|
Updated onboarding checklist. |
Raises:
| Type | Description |
|---|---|
OnboardingError
|
If no checklist exists for the agent. |
Source code in src/synthorg/hr/onboarding_service.py
get_checklist
async
¶
Retrieve the onboarding checklist for an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
Agent to look up. |
required |
Returns:
| Type | Description |
|---|---|
OnboardingChecklist | None
|
The checklist, or None if not found. |
Source code in src/synthorg/hr/onboarding_service.py
Offboarding Service¶
offboarding_service
¶
Offboarding service.
Orchestrates the firing/offboarding pipeline: task reassignment, memory archival, team notification, and agent termination.
OffboardingService
¶
OffboardingService(
*,
registry,
reassignment_strategy,
archival_strategy,
memory_backend=None,
archival_store=None,
org_memory_backend=None,
message_bus=None,
task_repository=None,
)
Orchestrates the firing/offboarding pipeline.
Pipeline steps
- Get active tasks and reassign via strategy.
- Archive memory via archival strategy.
- Notify team via message bus.
- Update agent status to TERMINATED and return record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry
|
AgentRegistryService
|
Agent registry for status updates. |
required |
reassignment_strategy
|
TaskReassignmentStrategy
|
Strategy for task reassignment. |
required |
archival_strategy
|
MemoryArchivalStrategy
|
Strategy for memory archival. |
required |
memory_backend
|
MemoryBackend | None
|
Optional hot memory store. |
None
|
archival_store
|
ArchivalStore | None
|
Optional cold archival storage. |
None
|
org_memory_backend
|
OrgMemoryBackend | None
|
Optional org memory for promotion. |
None
|
message_bus
|
MessageBus | None
|
Optional message bus for notifications. |
None
|
task_repository
|
TaskRepository | None
|
Optional task repository for queries. |
None
|
Source code in src/synthorg/hr/offboarding_service.py
offboard
async
¶
Execute the full offboarding pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
FiringRequest
|
The firing request to process. |
required |
Returns:
| Type | Description |
|---|---|
OffboardingRecord
|
Record of the completed offboarding. |
Raises:
| Type | Description |
|---|---|
OffboardingError
|
If task reassignment fails (fatal). |
AgentNotFoundError
|
If the agent is not in the registry (fatal). |
Note
Memory archival and team notification failures are logged but non-fatal -- offboarding continues.
Source code in src/synthorg/hr/offboarding_service.py
Enums¶
enums
¶
HR domain enumerations.
HiringRequestStatus
¶
Bases: StrEnum
Status of a hiring request through the approval pipeline.
FiringReason
¶
Bases: StrEnum
Reason for agent termination.
OnboardingStep
¶
Bases: StrEnum
Steps in the agent onboarding checklist.
LifecycleEventType
¶
Bases: StrEnum
Type of agent lifecycle event.
ActivityEventType
¶
Bases: StrEnum
Event types produced by the activity feed timeline.
Superset of LifecycleEventType plus operational event types
generated from task metrics, cost records, tool invocations,
and delegation records.
PromotionDirection
¶
Bases: StrEnum
Direction of a seniority level change.
TrendDirection
¶
Bases: StrEnum
Direction of a performance metric trend.
Errors¶
errors
¶
HR domain error hierarchy.
HRError
¶
Bases: Exception
Base error for all HR operations.
HiringApprovalRequiredError
¶
Bases: HiringError
Hiring request requires approval before instantiation.
HiringRejectedError
¶
Bases: HiringError
Hiring request was rejected.
InvalidCandidateError
¶
Bases: HiringError
Candidate card is invalid or does not exist on the request.
TaskReassignmentError
¶
Bases: OffboardingError
Failed to reassign tasks from a departing agent.
MemoryArchivalError
¶
Bases: OffboardingError
Failed to archive agent memories during offboarding.
AgentNotFoundError
¶
Bases: AgentRegistryError
Agent not found in the registry.
AgentAlreadyRegisteredError
¶
Bases: AgentRegistryError
Agent is already registered.
InsufficientDataError
¶
Bases: PerformanceError
Not enough data points for a meaningful computation.
PromotionCooldownError
¶
Bases: PromotionError
Promotion is blocked by the cooldown period.
PromotionApprovalRequiredError
¶
Bases: PromotionError
Promotion requires human approval before proceeding.
Performance¶
config
¶
Performance tracking configuration.
PerformanceConfig
pydantic-model
¶
Bases: BaseModel
Configuration for the performance tracking system.
Attributes:
| Name | Type | Description |
|---|---|---|
min_data_points |
int
|
Minimum data points for meaningful aggregation. |
windows |
tuple[NotBlankStr, ...]
|
Time window labels for rolling metrics. |
improving_threshold |
float
|
Slope threshold for improving trend. |
declining_threshold |
float
|
Slope threshold for declining trend. |
collaboration_weights |
dict[str, float] | None
|
Optional custom weights for collaboration scoring components. |
llm_sampling_rate |
float
|
Fraction of collaboration events sampled by LLM (0.01 = 1%). |
llm_sampling_model |
NotBlankStr | None
|
Model ID for LLM calibration sampling (None = disabled). |
calibration_retention_days |
int
|
Days to retain LLM calibration records. |
quality_judge_model |
NotBlankStr | None
|
Model ID for LLM quality judge (None = disabled). |
quality_judge_provider |
NotBlankStr | None
|
Provider name for LLM quality judge (None = auto from model ref). Requires quality_judge_model. |
quality_ci_weight |
float
|
Weight for CI signal in composite quality score (default 0.4). |
quality_llm_weight |
float
|
Weight for LLM judge in composite quality score (default 0.6). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
min_data_points(int) -
windows(tuple[NotBlankStr, ...]) -
improving_threshold(float) -
declining_threshold(float) -
collaboration_weights(dict[str, float] | None) -
llm_sampling_rate(float) -
llm_sampling_model(NotBlankStr | None) -
calibration_retention_days(int) -
quality_judge_model(NotBlankStr | None) -
quality_judge_provider(NotBlankStr | None) -
quality_ci_weight(float) -
quality_llm_weight(float)
Validators:
-
_validate_quality_judge_provider_requires_model -
_validate_threshold_ordering -
_validate_quality_weights_sum
windows
pydantic-field
¶
windows = (NotBlankStr('7d'), NotBlankStr('30d'), NotBlankStr('90d'))
Time window labels for rolling metrics
declining_threshold
pydantic-field
¶
Slope threshold for declining trend
collaboration_weights
pydantic-field
¶
Custom weights for collaboration scoring components
llm_sampling_rate
pydantic-field
¶
Fraction of collaboration events sampled by LLM (0.01 = 1%)
llm_sampling_model
pydantic-field
¶
Model ID for LLM calibration sampling (None = disabled)
calibration_retention_days
pydantic-field
¶
Days to retain LLM calibration records
quality_judge_model
pydantic-field
¶
Model ID for LLM quality judge (None = disabled)
quality_judge_provider
pydantic-field
¶
Provider name for LLM quality judge (None = auto from model ref)
quality_ci_weight
pydantic-field
¶
Weight for CI signal in composite quality score. Together with quality_llm_weight, must sum to 1.0.
quality_llm_weight
pydantic-field
¶
Weight for LLM judge in composite quality score. Together with quality_ci_weight, must sum to 1.0.
models
¶
Performance tracking domain models.
Frozen Pydantic models for task metrics, collaboration metrics, quality/collaboration scoring results, trend detection, and rolling-window aggregates.
TaskMetricRecord
pydantic-model
¶
Bases: BaseModel
Record of a single task completion for performance tracking.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique record identifier. |
agent_id |
NotBlankStr
|
Agent who completed the task. |
task_id |
NotBlankStr
|
Task identifier. |
task_type |
TaskType
|
Classification of the task. |
started_at |
AwareDatetime | None
|
When the task started (None if not tracked). |
completed_at |
AwareDatetime
|
When the task was completed. |
is_success |
bool
|
Whether the task completed successfully. |
duration_seconds |
float
|
Wall-clock execution time. |
cost_usd |
float
|
Cost of the task in USD (base currency). |
turns_used |
int
|
Number of LLM turns used. |
tokens_used |
int
|
Total tokens consumed. |
quality_score |
float | None
|
Quality score (0.0-10.0), None if not scored. |
complexity |
Complexity
|
Estimated task complexity. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
task_id(NotBlankStr) -
task_type(TaskType) -
started_at(AwareDatetime | None) -
completed_at(AwareDatetime) -
is_success(bool) -
duration_seconds(float) -
cost_usd(float) -
turns_used(int) -
tokens_used(int) -
quality_score(float | None) -
complexity(Complexity)
Validators:
-
_validate_temporal_ordering
CollaborationMetricRecord
pydantic-model
¶
Bases: BaseModel
Record of a collaboration behavior data point.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique record identifier. |
agent_id |
NotBlankStr
|
Agent being measured. |
recorded_at |
AwareDatetime
|
When the observation was recorded. |
delegation_success |
bool | None
|
Whether a delegation was successful. |
delegation_response_seconds |
float | None
|
Response time for a delegation. |
conflict_constructiveness |
float | None
|
How constructively conflict was handled. |
meeting_contribution |
float | None
|
Quality of meeting contribution. |
loop_triggered |
bool
|
Whether the agent triggered a delegation loop. |
handoff_completeness |
float | None
|
Completeness of task handoff (0.0-1.0). |
interaction_summary |
NotBlankStr | None
|
Text summary of the interaction for LLM calibration (None if not available). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
recorded_at(AwareDatetime) -
delegation_success(bool | None) -
delegation_response_seconds(float | None) -
conflict_constructiveness(float | None) -
meeting_contribution(float | None) -
loop_triggered(bool) -
handoff_completeness(float | None) -
interaction_summary(NotBlankStr | None)
delegation_response_seconds
pydantic-field
¶
Response time for a delegation
conflict_constructiveness
pydantic-field
¶
How constructively conflict was handled
loop_triggered
pydantic-field
¶
Whether the agent triggered a delegation loop
interaction_summary
pydantic-field
¶
Text summary of the interaction for LLM calibration
QualityScoreResult
pydantic-model
¶
Bases: BaseModel
Result of a quality scoring evaluation.
Attributes:
| Name | Type | Description |
|---|---|---|
score |
float
|
Overall quality score (0.0-10.0). |
strategy_name |
NotBlankStr
|
Name of the scoring strategy used. |
breakdown |
tuple[tuple[NotBlankStr, float], ...]
|
Score components as (name, value) pairs. |
confidence |
float
|
Confidence in the score (0.0-1.0). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
score(float) -
strategy_name(NotBlankStr) -
breakdown(tuple[tuple[NotBlankStr, float], ...]) -
confidence(float)
CollaborationScoreResult
pydantic-model
¶
Bases: BaseModel
Result of a collaboration scoring evaluation.
Attributes:
| Name | Type | Description |
|---|---|---|
score |
float
|
Overall collaboration score (0.0-10.0). |
strategy_name |
NotBlankStr
|
Name of the scoring strategy used. |
component_scores |
tuple[tuple[NotBlankStr, float], ...]
|
Per-component scores as (name, value) pairs. |
confidence |
float
|
Confidence in the score (0.0-1.0). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
score(float) -
strategy_name(NotBlankStr) -
component_scores(tuple[tuple[NotBlankStr, float], ...]) -
confidence(float) -
override_active(bool)
LlmCalibrationRecord
pydantic-model
¶
Bases: BaseModel
Record of an LLM calibration sample for collaboration scoring.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique record identifier. |
agent_id |
NotBlankStr
|
Agent being evaluated. |
sampled_at |
AwareDatetime
|
When the LLM evaluation occurred. |
interaction_record_id |
NotBlankStr
|
ID of the sampled CollaborationMetricRecord. |
llm_score |
float
|
LLM-assigned collaboration score (0.0-10.0). |
behavioral_score |
float
|
Behavioral strategy score at time of sampling. |
drift |
float
|
Absolute difference between LLM and behavioral scores (computed). |
rationale |
NotBlankStr
|
LLM's explanation for the score. |
model_used |
NotBlankStr
|
Which LLM model was used for evaluation. |
cost_usd |
float
|
Cost of the LLM call in USD (base currency). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
sampled_at(AwareDatetime) -
interaction_record_id(NotBlankStr) -
llm_score(float) -
behavioral_score(float) -
rationale(NotBlankStr) -
model_used(NotBlankStr) -
cost_usd(float)
interaction_record_id
pydantic-field
¶
ID of the sampled CollaborationMetricRecord
CollaborationOverride
pydantic-model
¶
Bases: _BaseOverride
Human-applied override for an agent's collaboration score.
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
score(float) -
reason(NotBlankStr) -
applied_by(NotBlankStr) -
applied_at(AwareDatetime) -
expires_at(AwareDatetime | None)
Validators:
-
_validate_expiration_ordering
QualityOverride
pydantic-model
¶
Bases: _BaseOverride
Human-applied override for an agent's quality score.
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
score(float) -
reason(NotBlankStr) -
applied_by(NotBlankStr) -
applied_at(AwareDatetime) -
expires_at(AwareDatetime | None)
Validators:
-
_validate_expiration_ordering
TrendResult
pydantic-model
¶
Bases: BaseModel
Result of a trend detection analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
metric_name |
NotBlankStr
|
Name of the metric being trended. |
window_size |
NotBlankStr
|
Time window label (e.g. '7d', '30d'). |
direction |
TrendDirection
|
Detected trend direction. |
slope |
float
|
Computed slope of the trend line. |
data_point_count |
int
|
Number of data points used. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
metric_name(NotBlankStr) -
window_size(NotBlankStr) -
direction(TrendDirection) -
slope(float) -
data_point_count(int)
WindowMetrics
pydantic-model
¶
Bases: BaseModel
Aggregate metrics for a rolling time window.
Attributes:
| Name | Type | Description |
|---|---|---|
window_size |
NotBlankStr
|
Time window label (e.g. '7d', '30d'). |
data_point_count |
int
|
Number of records in the window. |
tasks_completed |
int
|
Number of successful tasks. |
tasks_failed |
int
|
Number of failed tasks. |
avg_quality_score |
float | None
|
Average quality score, None if insufficient data. |
avg_cost_per_task |
float | None
|
Average cost per task, None if insufficient data. |
avg_completion_time_seconds |
float | None
|
Average time, None if insufficient data. |
avg_tokens_per_task |
float | None
|
Average tokens, None if insufficient data. |
success_rate |
float | None
|
Task success rate (0.0-1.0), None if no tasks. |
collaboration_score |
float | None
|
Collaboration score, None if not computed. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
window_size(NotBlankStr) -
data_point_count(int) -
tasks_completed(int) -
tasks_failed(int) -
avg_quality_score(float | None) -
avg_cost_per_task(float | None) -
avg_completion_time_seconds(float | None) -
avg_tokens_per_task(float | None) -
success_rate(float | None) -
collaboration_score(float | None)
Validators:
-
_validate_task_counts
AgentPerformanceSnapshot
pydantic-model
¶
Bases: BaseModel
Complete performance snapshot for an agent at a point in time.
Attributes:
| Name | Type | Description |
|---|---|---|
agent_id |
NotBlankStr
|
The agent being evaluated. |
computed_at |
AwareDatetime
|
When this snapshot was computed. |
windows |
tuple[WindowMetrics, ...]
|
Rolling window metrics. |
trends |
tuple[TrendResult, ...]
|
Detected trends per metric. |
overall_quality_score |
float | None
|
Aggregate quality score. |
overall_collaboration_score |
float | None
|
Aggregate collaboration score. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
agent_id(NotBlankStr) -
computed_at(AwareDatetime) -
windows(tuple[WindowMetrics, ...]) -
trends(tuple[TrendResult, ...]) -
overall_quality_score(float | None) -
overall_collaboration_score(float | None)
overall_collaboration_score
pydantic-field
¶
Aggregate collaboration score
tracker
¶
Performance tracker service.
Central service for recording and querying agent performance metrics. Delegates scoring, windowing, and trend detection to pluggable strategies.
PerformanceTracker
¶
PerformanceTracker(
*,
quality_strategy=None,
collaboration_strategy=None,
window_strategy=None,
trend_strategy=None,
config=None,
sampler=None,
override_store=None,
quality_override_store=None,
)
Central service for recording and querying agent performance metrics.
In-memory storage keyed by agent_id. Delegates scoring, windowing, and trend detection to injected strategy implementations.
When strategies are not provided, sensible defaults are constructed
(window and trend strategies use values from PerformanceConfig).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quality_strategy
|
QualityScoringStrategy | None
|
Strategy for scoring task quality. |
None
|
collaboration_strategy
|
CollaborationScoringStrategy | None
|
Strategy for scoring collaboration. |
None
|
window_strategy
|
MetricsWindowStrategy | None
|
Strategy for computing rolling windows. |
None
|
trend_strategy
|
TrendDetectionStrategy | None
|
Strategy for detecting trends. |
None
|
config
|
PerformanceConfig | None
|
Performance tracking configuration. |
None
|
sampler
|
LlmCalibrationSampler | None
|
LLM calibration sampler (None = disabled). |
None
|
override_store
|
CollaborationOverrideStore | None
|
Collaboration override store (None = disabled). |
None
|
quality_override_store
|
QualityOverrideStore | None
|
Quality override store (None = disabled). |
None
|
Source code in src/synthorg/hr/performance/tracker.py
quality_override_store
property
¶
Return the quality override store, if configured.
aclose
async
¶
Cancel and await all pending background tasks.
Should be called during application shutdown to prevent
RuntimeError: Task was destroyed but it is pending!
warnings.
Source code in src/synthorg/hr/performance/tracker.py
record_task_metric
async
¶
Record a task completion metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
TaskMetricRecord
|
The task metric record to store. |
required |
Returns:
| Type | Description |
|---|---|
TaskMetricRecord
|
The stored record. |
Source code in src/synthorg/hr/performance/tracker.py
score_task_quality
async
¶
Score task quality and update the record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent who completed the task. |
required |
task_id
|
NotBlankStr
|
Task identifier. |
required |
task_result
|
TaskMetricRecord
|
Recorded task metrics. |
required |
acceptance_criteria
|
tuple[AcceptanceCriterion, ...]
|
Criteria to evaluate against. |
()
|
Returns:
| Type | Description |
|---|---|
TaskMetricRecord
|
Updated record with quality score. |
Source code in src/synthorg/hr/performance/tracker.py
record_collaboration_event
async
¶
Record a collaboration behavior data point.
If an LLM sampler is configured and the record has an
interaction_summary, the sampler is invoked probabilistically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
CollaborationMetricRecord
|
Collaboration metric record to store. |
required |
Source code in src/synthorg/hr/performance/tracker.py
get_collaboration_score
async
¶
Compute collaboration score for an agent.
Returns the active human override if one exists; otherwise delegates to the collaboration scoring strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent to evaluate. |
required |
now
|
AwareDatetime | None
|
Reference time for override expiration check (defaults to current UTC time). |
None
|
Returns:
| Type | Description |
|---|---|
CollaborationScoreResult
|
Collaboration score result. |
Source code in src/synthorg/hr/performance/tracker.py
get_snapshot
async
¶
Compute a full performance snapshot for an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent to evaluate. |
required |
now
|
AwareDatetime | None
|
Reference time (defaults to current UTC time). |
None
|
Returns:
| Type | Description |
|---|---|
AgentPerformanceSnapshot
|
Complete performance snapshot with windows and trends. |
Source code in src/synthorg/hr/performance/tracker.py
get_task_metrics
¶
Query raw task metric records with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr | None
|
Filter by agent. |
None
|
since
|
AwareDatetime | None
|
Include records after this time. |
None
|
until
|
AwareDatetime | None
|
Include records before this time. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[TaskMetricRecord, ...]
|
Matching task metric records. |
Source code in src/synthorg/hr/performance/tracker.py
get_collaboration_metrics
¶
Query collaboration metric records with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr | None
|
Filter by agent. |
None
|
since
|
AwareDatetime | None
|
Include records after this time. |
None
|
until
|
AwareDatetime | None
|
Include records before this time. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[CollaborationMetricRecord, ...]
|
Matching collaboration metric records. |
Source code in src/synthorg/hr/performance/tracker.py
quality_protocol
¶
Quality scoring strategy protocol.
Defines the interface for pluggable quality scoring strategies that evaluate task completion quality (see Agents design page, D2).
QualityScoringStrategy
¶
Bases: Protocol
Strategy for scoring task completion quality.
Implementations evaluate task results against acceptance criteria and other quality signals to produce a normalized score.
score
async
¶
Score task completion quality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent who completed the task. |
required |
task_id
|
NotBlankStr
|
Task identifier. |
required |
task_result
|
TaskMetricRecord
|
Recorded task metrics. |
required |
acceptance_criteria
|
tuple[AcceptanceCriterion, ...]
|
Criteria to evaluate against. |
required |
Returns:
| Type | Description |
|---|---|
QualityScoreResult
|
Quality score result with breakdown and confidence. |
Source code in src/synthorg/hr/performance/quality_protocol.py
collaboration_protocol
¶
Collaboration scoring strategy protocol.
Defines the interface for pluggable collaboration scoring strategies that evaluate agent collaboration behavior (see Agents design page, D3).
CollaborationScoringStrategy
¶
Bases: Protocol
Strategy for scoring agent collaboration behavior.
Implementations evaluate behavioral telemetry records to produce a normalized collaboration score.
score
async
¶
Score agent collaboration behavior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent being evaluated. |
required |
records
|
tuple[CollaborationMetricRecord, ...]
|
Collaboration metric records to evaluate. |
required |
role_weights
|
dict[str, float] | None
|
Optional per-component weight overrides. |
None
|
Returns:
| Type | Description |
|---|---|
CollaborationScoreResult
|
Collaboration score result with component scores. |
Source code in src/synthorg/hr/performance/collaboration_protocol.py
trend_protocol
¶
Trend detection strategy protocol.
Defines the interface for pluggable trend detection strategies that analyze metric time series (see Agents design page, D12).
TrendDetectionStrategy
¶
Bases: Protocol
Strategy for detecting trends in metric time series.
Implementations analyze sequences of (timestamp, value) pairs to determine whether a metric is improving, stable, or declining.
detect
¶
Detect the trend direction in a metric time series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_name
|
NotBlankStr
|
Name of the metric being analyzed. |
required |
values
|
tuple[tuple[AwareDatetime, float], ...]
|
Time series data as (timestamp, value) pairs. |
required |
window_size
|
NotBlankStr
|
Time window label for context. |
required |
Returns:
| Type | Description |
|---|---|
TrendResult
|
Trend detection result with direction and slope. |
Source code in src/synthorg/hr/performance/trend_protocol.py
Promotion¶
config
¶
Promotion configuration models.
Defines PromotionConfig and sub-configs for controlling
promotion/demotion behavior.
PromotionCriteriaConfig
pydantic-model
¶
Bases: BaseModel
Configuration for promotion criteria evaluation.
Attributes:
| Name | Type | Description |
|---|---|---|
min_criteria_met |
int
|
Minimum number of criteria that must be met. |
required_criteria |
tuple[NotBlankStr, ...]
|
Criteria names that must always be met. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
min_criteria_met(int) -
required_criteria(tuple[NotBlankStr, ...])
PromotionApprovalConfig
pydantic-model
¶
Bases: BaseModel
Configuration for promotion approval decisions.
Attributes:
| Name | Type | Description |
|---|---|---|
human_approval_from_level |
SeniorityLevel
|
Seniority level from which human approval is required for promotion. |
auto_demote_cost_saving |
bool
|
Auto-apply cost-saving demotions. |
human_demote_authority |
bool
|
Require human approval for authority-reducing demotions. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
ModelMappingConfig
pydantic-model
¶
Bases: BaseModel
Configuration for model mapping on seniority changes.
Attributes:
| Name | Type | Description |
|---|---|---|
model_follows_seniority |
bool
|
Whether model changes with seniority. |
seniority_model_map |
Any
|
Explicit level-to-model overrides. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
model_follows_seniority(bool) -
seniority_model_map(Any)
Validators:
-
_validate_model_map_keys
PromotionConfig
pydantic-model
¶
Bases: BaseModel
Top-level promotion/demotion configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Whether the promotion subsystem is enabled. |
cooldown_hours |
int
|
Hours between consecutive promotions/demotions. |
criteria |
PromotionCriteriaConfig
|
Promotion criteria configuration. |
approval |
PromotionApprovalConfig
|
Promotion approval configuration. |
model_mapping |
ModelMappingConfig
|
Model mapping configuration. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
enabled(bool) -
cooldown_hours(int) -
criteria(PromotionCriteriaConfig) -
approval(PromotionApprovalConfig) -
model_mapping(ModelMappingConfig)
models
¶
Promotion domain models.
Frozen Pydantic models for promotion criteria results, evaluations, approval decisions, records, and requests.
CriterionResult
pydantic-model
¶
Bases: BaseModel
Result of a single promotion/demotion criterion evaluation.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
NotBlankStr
|
Criterion name. |
met |
bool
|
Whether the criterion was met. |
current_value |
float
|
Agent's current value for this criterion. |
threshold |
float
|
Required threshold value. |
weight |
float | None
|
Weight of this criterion (None if not weighted). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
name(NotBlankStr) -
met(bool) -
current_value(float) -
threshold(float) -
weight(float | None)
PromotionEvaluation
pydantic-model
¶
Bases: BaseModel
Result of evaluating an agent for promotion or demotion.
Attributes:
| Name | Type | Description |
|---|---|---|
agent_id |
NotBlankStr
|
Agent being evaluated. |
current_level |
SeniorityLevel
|
Current seniority level. |
target_level |
SeniorityLevel
|
Target seniority level. |
direction |
PromotionDirection
|
Whether this is a promotion or demotion. |
criteria_results |
tuple[CriterionResult, ...]
|
Individual criterion results. |
required_criteria_met |
bool
|
Whether all required criteria are met. |
eligible |
bool
|
Whether the agent is eligible for the change. |
evaluated_at |
AwareDatetime
|
When the evaluation was performed. |
strategy_name |
NotBlankStr
|
Strategy that performed the evaluation. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
agent_id(NotBlankStr) -
current_level(SeniorityLevel) -
target_level(SeniorityLevel) -
direction(PromotionDirection) -
criteria_results(tuple[CriterionResult, ...]) -
required_criteria_met(bool) -
eligible(bool) -
evaluated_at(AwareDatetime) -
strategy_name(NotBlankStr)
Validators:
-
_validate_direction_consistency
PromotionApprovalDecision
pydantic-model
¶
Bases: BaseModel
Decision on whether a promotion needs human approval.
Attributes:
| Name | Type | Description |
|---|---|---|
auto_approve |
bool
|
Whether the promotion can be auto-approved. |
reason |
NotBlankStr
|
Explanation for the decision. |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
auto_approve(bool) -
reason(NotBlankStr)
PromotionRecord
pydantic-model
¶
Bases: BaseModel
Record of a completed promotion or demotion.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique record identifier. |
agent_id |
NotBlankStr
|
Agent who was promoted/demoted. |
agent_name |
NotBlankStr
|
Agent display name. |
old_level |
SeniorityLevel
|
Previous seniority level. |
new_level |
SeniorityLevel
|
New seniority level. |
direction |
PromotionDirection
|
Whether this was a promotion or demotion. |
evaluation |
PromotionEvaluation
|
The evaluation that led to this change. |
approved_by |
NotBlankStr | None
|
Who approved the change ("auto" if auto-approved, "human" if human-approved via approval_id). |
approval_id |
NotBlankStr | None
|
Approval item ID if human-approved. |
effective_at |
AwareDatetime
|
When the change took effect. |
initiated_by |
NotBlankStr
|
Who initiated the promotion process. |
model_changed |
bool
|
Whether the model was changed. |
old_model_id |
NotBlankStr | None
|
Previous model ID (None if not changed). |
new_model_id |
NotBlankStr | None
|
New model ID (None if not changed). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
agent_name(NotBlankStr) -
old_level(SeniorityLevel) -
new_level(SeniorityLevel) -
direction(PromotionDirection) -
evaluation(PromotionEvaluation) -
approved_by(NotBlankStr | None) -
approval_id(NotBlankStr | None) -
effective_at(AwareDatetime) -
initiated_by(NotBlankStr) -
model_changed(bool) -
old_model_id(NotBlankStr | None) -
new_model_id(NotBlankStr | None)
Validators:
-
_validate_model_fields
PromotionRequest
pydantic-model
¶
Bases: BaseModel
A pending promotion or demotion request.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
NotBlankStr
|
Unique request identifier. |
agent_id |
NotBlankStr
|
Agent being promoted/demoted. |
agent_name |
NotBlankStr
|
Agent display name. |
current_level |
SeniorityLevel
|
Current seniority level. |
target_level |
SeniorityLevel
|
Target seniority level. |
direction |
PromotionDirection
|
Whether this is a promotion or demotion. |
evaluation |
PromotionEvaluation
|
The evaluation supporting this request. |
status |
ApprovalStatus
|
Current approval status. |
created_at |
AwareDatetime
|
When the request was created. |
approval_id |
NotBlankStr | None
|
Linked approval item ID (for human approval). |
Config:
frozen:Trueallow_inf_nan:False
Fields:
-
id(NotBlankStr) -
agent_id(NotBlankStr) -
agent_name(NotBlankStr) -
current_level(SeniorityLevel) -
target_level(SeniorityLevel) -
direction(PromotionDirection) -
evaluation(PromotionEvaluation) -
status(ApprovalStatus) -
created_at(AwareDatetime) -
approval_id(NotBlankStr | None)
service
¶
Promotion service orchestrator.
Central service for managing agent promotions and demotions, including criteria evaluation, approval decisions, model mapping, and trust integration.
PromotionService
¶
PromotionService(
*,
criteria_strategy,
approval_strategy,
model_mapping_strategy,
registry,
tracker,
config,
approval_store=None,
trust_service=None,
on_notification=None,
)
Orchestrates agent promotions and demotions.
Coordinates criteria evaluation, approval decisions, model mapping, registry updates, and optional trust re-evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
criteria_strategy
|
PromotionCriteriaStrategy
|
Strategy for evaluating promotion criteria. |
required |
approval_strategy
|
PromotionApprovalStrategy
|
Strategy for approval decisions. |
required |
model_mapping_strategy
|
ModelMappingStrategy
|
Strategy for model resolution. |
required |
registry
|
AgentRegistryService
|
Agent registry service. |
required |
tracker
|
PerformanceTracker
|
Performance tracker. |
required |
config
|
PromotionConfig
|
Promotion configuration. |
required |
approval_store
|
ApprovalStore | None
|
Optional approval store for human approval. |
None
|
trust_service
|
TrustService | None
|
Optional trust service for re-evaluation. |
None
|
on_notification
|
PromotionNotificationCallback | None
|
Optional callback to notify agents/teams of promotion or demotion events. Wired by the communication layer when available. |
None
|
Source code in src/synthorg/hr/promotion/service.py
evaluate_promotion
async
¶
Evaluate whether an agent qualifies for promotion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent to evaluate. |
required |
Returns:
| Type | Description |
|---|---|
PromotionEvaluation
|
Promotion evaluation result. |
Raises:
| Type | Description |
|---|---|
PromotionError
|
If the agent cannot be promoted. |
Source code in src/synthorg/hr/promotion/service.py
evaluate_demotion
async
¶
Evaluate whether an agent should be demoted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent to evaluate. |
required |
Returns:
| Type | Description |
|---|---|
PromotionEvaluation
|
Demotion evaluation result. |
Raises:
| Type | Description |
|---|---|
PromotionError
|
If the agent cannot be demoted. |
Source code in src/synthorg/hr/promotion/service.py
request_promotion
async
¶
Create a promotion/demotion request.
Checks cooldown, evaluates approval decision, and creates an approval item if human approval is needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent to promote/demote. |
required |
evaluation
|
PromotionEvaluation
|
The evaluation result. |
required |
initiated_by
|
NotBlankStr
|
Who initiated the request. |
_SYSTEM_INITIATOR
|
Returns:
| Type | Description |
|---|---|
PromotionRequest
|
Promotion request. |
Raises:
| Type | Description |
|---|---|
PromotionCooldownError
|
If in cooldown period. |
PromotionError
|
If agent not found. |
Source code in src/synthorg/hr/promotion/service.py
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 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
apply_promotion
async
¶
Apply a promotion/demotion from an approved request.
Updates the agent's seniority level, resolves model mapping, triggers trust re-evaluation, and records the lifecycle event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
PromotionRequest
|
Approved promotion request. |
required |
initiated_by
|
NotBlankStr
|
Who initiated the application. |
_SYSTEM_INITIATOR
|
Returns:
| Type | Description |
|---|---|
PromotionRecord
|
Promotion record. |
Raises:
| Type | Description |
|---|---|
PromotionApprovalRequiredError
|
If request is not approved. |
PromotionError
|
If agent not found. |
Source code in src/synthorg/hr/promotion/service.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
get_promotion_history
¶
Get promotion/demotion history for an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
tuple[PromotionRecord, ...]
|
Tuple of promotion records. |
Source code in src/synthorg/hr/promotion/service.py
is_in_cooldown
¶
Check whether an agent is in the promotion cooldown period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent identifier. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if in cooldown. |
Source code in src/synthorg/hr/promotion/service.py
model_mapping_protocol
¶
Model mapping strategy protocol.
Defines the pluggable interface for mapping seniority levels to LLM model identifiers.
ModelMappingStrategy
¶
Bases: Protocol
Protocol for mapping seniority to LLM models.
Implementations determine which model an agent should use after a seniority level change.
resolve_model
¶
Resolve the model for an agent at a new seniority level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_identity
|
AgentIdentity
|
The agent's current identity. |
required |
new_level
|
SeniorityLevel
|
The new seniority level. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
New model_id, or None if no change needed. |
Source code in src/synthorg/hr/promotion/model_mapping_protocol.py
criteria_protocol
¶
Promotion criteria strategy protocol.
Defines the pluggable interface for evaluating promotion/demotion criteria.
PromotionCriteriaStrategy
¶
Bases: Protocol
Protocol for promotion criteria evaluation.
Implementations define what criteria must be met for an agent to be promoted or demoted between seniority levels.
evaluate
async
¶
Evaluate whether an agent meets criteria for level change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
NotBlankStr
|
Agent to evaluate. |
required |
current_level
|
SeniorityLevel
|
Current seniority level. |
required |
target_level
|
SeniorityLevel
|
Target seniority level. |
required |
snapshot
|
AgentPerformanceSnapshot
|
Agent performance snapshot. |
required |
Returns:
| Type | Description |
|---|---|
PromotionEvaluation
|
Evaluation result with criteria details. |
Source code in src/synthorg/hr/promotion/criteria_protocol.py
approval_protocol
¶
Promotion approval strategy protocol.
Defines the pluggable interface for deciding whether promotions require human approval.
PromotionApprovalStrategy
¶
Bases: Protocol
Protocol for promotion approval decisions.
Implementations determine whether a promotion/demotion can be auto-approved or requires human intervention.
decide
async
¶
Decide whether a promotion needs human approval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation
|
PromotionEvaluation
|
The promotion evaluation result. |
required |
agent_identity
|
AgentIdentity
|
The agent's current identity. |
required |
Returns:
| Type | Description |
|---|---|
PromotionApprovalDecision
|
Approval decision. |