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
2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 | |
stop()
async
¶
Stop agent execution.
This method is @hookable, so capabilities can register BEFORE hooks to flush memories, AFTER hooks for cleanup, etc.
Override in subclasses to perform cleanup logic.
Source code in src/polymathera/colony/agents/base.py
get_blackboard(scope='shared', scope_id=None, backend_type='redis', enable_events=True)
async
¶
Get blackboard for reading/writing shared state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
str
|
Blackboard scope ( |
'shared'
|
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 |