Models¶
Agent State¶
polymathera.colony.agents.models.AgentState
¶
Bases: str, Enum
Agent lifecycle states.
Agent Metadata¶
polymathera.colony.agents.models.AgentMetadata
¶
Bases: BaseModel
Metadata for agents.
from_data(*, caller=None, **kwargs)
classmethod
¶
Construct an :class:AgentMetadata from a payload sourced
from outside the typed Python boundary — most commonly a JSON
dict the LLM emitted at the REPL and spread via **.
Why this exists separately from AgentMetadata(**kwargs):
- The constructor's
:meth:
_reject_silently_dropped_context_kwargsvalidator loudly rejects anytenant_id/colony_id/session_id/run_idat the top level so typed Python code can't accidentally pass them (they're read-only @properties delegating tosyscontext— the constructor would silently drop them otherwise, which masked real bugs). - LLM-driven callers don't get that contract. The REPL
serialises whatever the planner emits, and the planner
will happily include
tenant_idthinking it's a field. Failing the spawn with a pydanticValueErroron every such call is a worse failure mode than silently stripping the keys — the syscontext default_factory captures the parent's context, so the LLM's intent ("inherit tenant identity from the spawn site") is what actually happens anyway.
This helper bridges the two: strip the context keys with a WARN log naming the caller, then forward the cleaned payload through the typed constructor (which still enforces every other invariant).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
caller
|
str | None
|
Free-form identifier (e.g. capability + action, spawn-site agent_id) included in the WARN log so the operator can locate the source of sloppy payloads. Falls back to "unspecified" when omitted. |
None
|
**kwargs
|
Any
|
The dict payload (typically a |
{}
|
Returns:
| Type | Description |
|---|---|
AgentMetadata
|
A typed :class: |
AgentMetadata
|
|
AgentMetadata
|
|
AgentMetadata
|
default_factory captures the active execution context), |
AgentMetadata
|
NOT from the kwargs — even if the LLM passed them. |
Source code in src/polymathera/colony/agents/models.py
2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 | |
Action Types¶
polymathera.colony.agents.models.ActionType
¶
Bases: str, Enum
Types of actions agents can perform.