Agent¶
polymathera.colony.agents.base.Agent
¶
Bases: BaseModel
Base agent class representing an autonomous computational entity.
All agents have: - Unique ID and type - Lifecycle state - Optional page binding - Access to system services (VCM, LLM, blackboard)
Control flow should be driven by a reasoning LLM given sufficient context, not hardcoded. Agents adapt behavior based on current context.
Attributes:
| Name | Type | Description |
|---|---|---|
agent_id |
str
|
Unique identifier |
agent_type |
str
|
Type of agent ("specialized", "general", "service", "supervisor") |
state |
AgentState
|
Current lifecycle state |
bound_pages |
list[str]
|
Page IDs this agent is bound to (empty for unbound agents) |
created_at |
float
|
Creation timestamp |
metadata |
AgentMetadata
|
Arbitrary metadata |
state = Field(default=(AgentState.INITIALIZED))
class-attribute
instance-attribute
¶
agent_id
instance-attribute
¶
metadata = Field(default_factory=AgentMetadata)
class-attribute
instance-attribute
¶
run_step()
async
¶
Execute one step of agent logic.
This is the core method that defines agent behavior. Override in subclasses to implement specific agent logic.
This method should be idempotent and handle its own errors.
This method is @hookable, so capabilities can register BEFORE hooks to prepare for the step, AFTER hooks to post-process the step, AROUND hooks to wrap the step execution entirely, and to handle errors during execution.
NOTE: We use the repeated run_step approach instead of a single
long-running run method to facilitate easier suspension and state
management. This is necessary for distributed agents that may be
suspended and resumed across different replicas.
Source code in src/polymathera/colony/agents/base.py
2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 | |
stop(reason='completed')
async
¶
Stop agent execution.
This method is @hookable, so capabilities can register BEFORE hooks to flush memories, AFTER hooks for cleanup, etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason
|
str
|
Why the agent is stopping. Stored in |
'completed'
|
Source code in src/polymathera/colony/agents/base.py
get_blackboard(scope_id=None, backend_type='redis', enable_events=True)
async
¶
Get blackboard for reading/writing shared state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope_id
|
str | None
|
Scope identifier (defaults to |
None
|
backend_type
|
str
|
Backend type for the blackboard (e.g., "redis") |
'redis'
|
enable_events
|
bool
|
Whether to enable events on the blackboard |
True
|
Returns:
| Type | Description |
|---|---|
EnhancedBlackboard
|
Blackboard instance |