@elizaos/python 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +239 -0
- package/elizaos/__init__.py +280 -0
- package/elizaos/action_docs.py +149 -0
- package/elizaos/advanced_capabilities/__init__.py +85 -0
- package/elizaos/advanced_capabilities/actions/__init__.py +54 -0
- package/elizaos/advanced_capabilities/actions/add_contact.py +139 -0
- package/elizaos/advanced_capabilities/actions/follow_room.py +151 -0
- package/elizaos/advanced_capabilities/actions/image_generation.py +148 -0
- package/elizaos/advanced_capabilities/actions/mute_room.py +164 -0
- package/elizaos/advanced_capabilities/actions/remove_contact.py +145 -0
- package/elizaos/advanced_capabilities/actions/roles.py +207 -0
- package/elizaos/advanced_capabilities/actions/schedule_follow_up.py +154 -0
- package/elizaos/advanced_capabilities/actions/search_contacts.py +145 -0
- package/elizaos/advanced_capabilities/actions/send_message.py +187 -0
- package/elizaos/advanced_capabilities/actions/settings.py +151 -0
- package/elizaos/advanced_capabilities/actions/unfollow_room.py +164 -0
- package/elizaos/advanced_capabilities/actions/unmute_room.py +164 -0
- package/elizaos/advanced_capabilities/actions/update_contact.py +164 -0
- package/elizaos/advanced_capabilities/actions/update_entity.py +161 -0
- package/elizaos/advanced_capabilities/evaluators/__init__.py +18 -0
- package/elizaos/advanced_capabilities/evaluators/reflection.py +134 -0
- package/elizaos/advanced_capabilities/evaluators/relationship_extraction.py +203 -0
- package/elizaos/advanced_capabilities/providers/__init__.py +36 -0
- package/elizaos/advanced_capabilities/providers/agent_settings.py +60 -0
- package/elizaos/advanced_capabilities/providers/contacts.py +77 -0
- package/elizaos/advanced_capabilities/providers/facts.py +82 -0
- package/elizaos/advanced_capabilities/providers/follow_ups.py +113 -0
- package/elizaos/advanced_capabilities/providers/knowledge.py +83 -0
- package/elizaos/advanced_capabilities/providers/relationships.py +112 -0
- package/elizaos/advanced_capabilities/providers/roles.py +97 -0
- package/elizaos/advanced_capabilities/providers/settings.py +51 -0
- package/elizaos/advanced_capabilities/services/__init__.py +18 -0
- package/elizaos/advanced_capabilities/services/follow_up.py +138 -0
- package/elizaos/advanced_capabilities/services/rolodex.py +244 -0
- package/elizaos/advanced_memory/__init__.py +3 -0
- package/elizaos/advanced_memory/evaluators.py +97 -0
- package/elizaos/advanced_memory/memory_service.py +556 -0
- package/elizaos/advanced_memory/plugin.py +30 -0
- package/elizaos/advanced_memory/prompts.py +12 -0
- package/elizaos/advanced_memory/providers.py +90 -0
- package/elizaos/advanced_memory/types.py +65 -0
- package/elizaos/advanced_planning/__init__.py +10 -0
- package/elizaos/advanced_planning/actions.py +145 -0
- package/elizaos/advanced_planning/message_classifier.py +127 -0
- package/elizaos/advanced_planning/planning_service.py +712 -0
- package/elizaos/advanced_planning/plugin.py +40 -0
- package/elizaos/advanced_planning/prompts.py +4 -0
- package/elizaos/basic_capabilities/__init__.py +66 -0
- package/elizaos/basic_capabilities/actions/__init__.py +24 -0
- package/elizaos/basic_capabilities/actions/choice.py +140 -0
- package/elizaos/basic_capabilities/actions/ignore.py +66 -0
- package/elizaos/basic_capabilities/actions/none.py +56 -0
- package/elizaos/basic_capabilities/actions/reply.py +120 -0
- package/elizaos/basic_capabilities/providers/__init__.py +54 -0
- package/elizaos/basic_capabilities/providers/action_state.py +113 -0
- package/elizaos/basic_capabilities/providers/actions.py +263 -0
- package/elizaos/basic_capabilities/providers/attachments.py +76 -0
- package/elizaos/basic_capabilities/providers/capabilities.py +62 -0
- package/elizaos/basic_capabilities/providers/character.py +113 -0
- package/elizaos/basic_capabilities/providers/choice.py +73 -0
- package/elizaos/basic_capabilities/providers/context_bench.py +44 -0
- package/elizaos/basic_capabilities/providers/current_time.py +58 -0
- package/elizaos/basic_capabilities/providers/entities.py +99 -0
- package/elizaos/basic_capabilities/providers/evaluators.py +54 -0
- package/elizaos/basic_capabilities/providers/providers_list.py +55 -0
- package/elizaos/basic_capabilities/providers/recent_messages.py +85 -0
- package/elizaos/basic_capabilities/providers/time.py +45 -0
- package/elizaos/basic_capabilities/providers/world.py +93 -0
- package/elizaos/basic_capabilities/services/__init__.py +18 -0
- package/elizaos/basic_capabilities/services/embedding.py +122 -0
- package/elizaos/basic_capabilities/services/task.py +178 -0
- package/elizaos/bootstrap/__init__.py +12 -0
- package/elizaos/bootstrap/actions/__init__.py +68 -0
- package/elizaos/bootstrap/actions/add_contact.py +149 -0
- package/elizaos/bootstrap/actions/choice.py +147 -0
- package/elizaos/bootstrap/actions/follow_room.py +151 -0
- package/elizaos/bootstrap/actions/ignore.py +80 -0
- package/elizaos/bootstrap/actions/image_generation.py +135 -0
- package/elizaos/bootstrap/actions/mute_room.py +151 -0
- package/elizaos/bootstrap/actions/none.py +71 -0
- package/elizaos/bootstrap/actions/remove_contact.py +159 -0
- package/elizaos/bootstrap/actions/reply.py +140 -0
- package/elizaos/bootstrap/actions/roles.py +193 -0
- package/elizaos/bootstrap/actions/schedule_follow_up.py +164 -0
- package/elizaos/bootstrap/actions/search_contacts.py +159 -0
- package/elizaos/bootstrap/actions/send_message.py +173 -0
- package/elizaos/bootstrap/actions/settings.py +165 -0
- package/elizaos/bootstrap/actions/unfollow_room.py +151 -0
- package/elizaos/bootstrap/actions/unmute_room.py +151 -0
- package/elizaos/bootstrap/actions/update_contact.py +178 -0
- package/elizaos/bootstrap/actions/update_entity.py +175 -0
- package/elizaos/bootstrap/autonomy/__init__.py +18 -0
- package/elizaos/bootstrap/autonomy/action.py +197 -0
- package/elizaos/bootstrap/autonomy/providers.py +165 -0
- package/elizaos/bootstrap/autonomy/routes.py +171 -0
- package/elizaos/bootstrap/autonomy/service.py +562 -0
- package/elizaos/bootstrap/autonomy/types.py +18 -0
- package/elizaos/bootstrap/evaluators/__init__.py +19 -0
- package/elizaos/bootstrap/evaluators/reflection.py +118 -0
- package/elizaos/bootstrap/evaluators/relationship_extraction.py +192 -0
- package/elizaos/bootstrap/plugin.py +140 -0
- package/elizaos/bootstrap/providers/__init__.py +80 -0
- package/elizaos/bootstrap/providers/action_state.py +71 -0
- package/elizaos/bootstrap/providers/actions.py +256 -0
- package/elizaos/bootstrap/providers/agent_settings.py +63 -0
- package/elizaos/bootstrap/providers/attachments.py +76 -0
- package/elizaos/bootstrap/providers/capabilities.py +66 -0
- package/elizaos/bootstrap/providers/character.py +128 -0
- package/elizaos/bootstrap/providers/choice.py +77 -0
- package/elizaos/bootstrap/providers/contacts.py +78 -0
- package/elizaos/bootstrap/providers/context_bench.py +49 -0
- package/elizaos/bootstrap/providers/current_time.py +56 -0
- package/elizaos/bootstrap/providers/entities.py +99 -0
- package/elizaos/bootstrap/providers/evaluators.py +58 -0
- package/elizaos/bootstrap/providers/facts.py +86 -0
- package/elizaos/bootstrap/providers/follow_ups.py +116 -0
- package/elizaos/bootstrap/providers/knowledge.py +73 -0
- package/elizaos/bootstrap/providers/providers_list.py +59 -0
- package/elizaos/bootstrap/providers/recent_messages.py +85 -0
- package/elizaos/bootstrap/providers/relationships.py +106 -0
- package/elizaos/bootstrap/providers/roles.py +95 -0
- package/elizaos/bootstrap/providers/settings.py +55 -0
- package/elizaos/bootstrap/providers/time.py +45 -0
- package/elizaos/bootstrap/providers/world.py +97 -0
- package/elizaos/bootstrap/services/__init__.py +26 -0
- package/elizaos/bootstrap/services/embedding.py +122 -0
- package/elizaos/bootstrap/services/follow_up.py +138 -0
- package/elizaos/bootstrap/services/rolodex.py +244 -0
- package/elizaos/bootstrap/services/task.py +585 -0
- package/elizaos/bootstrap/types.py +54 -0
- package/elizaos/bootstrap/utils/__init__.py +7 -0
- package/elizaos/bootstrap/utils/xml.py +69 -0
- package/elizaos/character.py +149 -0
- package/elizaos/logger.py +179 -0
- package/elizaos/media/__init__.py +45 -0
- package/elizaos/media/mime.py +315 -0
- package/elizaos/media/search.py +161 -0
- package/elizaos/media/tests/__init__.py +1 -0
- package/elizaos/media/tests/test_mime.py +117 -0
- package/elizaos/media/tests/test_search.py +156 -0
- package/elizaos/plugin.py +191 -0
- package/elizaos/prompts.py +1071 -0
- package/elizaos/py.typed +0 -0
- package/elizaos/runtime.py +2572 -0
- package/elizaos/services/__init__.py +49 -0
- package/elizaos/services/hook_service.py +511 -0
- package/elizaos/services/message_service.py +1248 -0
- package/elizaos/settings.py +182 -0
- package/elizaos/streaming_context.py +159 -0
- package/elizaos/trajectory_context.py +18 -0
- package/elizaos/types/__init__.py +512 -0
- package/elizaos/types/agent.py +31 -0
- package/elizaos/types/components.py +208 -0
- package/elizaos/types/database.py +64 -0
- package/elizaos/types/environment.py +46 -0
- package/elizaos/types/events.py +47 -0
- package/elizaos/types/memory.py +45 -0
- package/elizaos/types/model.py +393 -0
- package/elizaos/types/plugin.py +188 -0
- package/elizaos/types/primitives.py +100 -0
- package/elizaos/types/runtime.py +460 -0
- package/elizaos/types/service.py +113 -0
- package/elizaos/types/service_interfaces.py +244 -0
- package/elizaos/types/state.py +188 -0
- package/elizaos/types/task.py +29 -0
- package/elizaos/utils/__init__.py +108 -0
- package/elizaos/utils/spec_examples.py +48 -0
- package/elizaos/utils/streaming.py +426 -0
- package/elizaos_atropos_shared/__init__.py +1 -0
- package/elizaos_atropos_shared/canonical_eliza.py +282 -0
- package/package.json +19 -0
- package/pyproject.toml +143 -0
- package/requirements-dev.in +11 -0
- package/requirements-dev.lock +134 -0
- package/requirements.in +9 -0
- package/requirements.lock +64 -0
- package/tests/__init__.py +0 -0
- package/tests/test_action_parameters.py +154 -0
- package/tests/test_actions_provider_examples.py +39 -0
- package/tests/test_advanced_memory_behavior.py +96 -0
- package/tests/test_advanced_memory_flag.py +30 -0
- package/tests/test_advanced_planning_behavior.py +225 -0
- package/tests/test_advanced_planning_flag.py +26 -0
- package/tests/test_autonomy.py +445 -0
- package/tests/test_bootstrap_initialize.py +37 -0
- package/tests/test_character.py +163 -0
- package/tests/test_character_provider.py +231 -0
- package/tests/test_dynamic_prompt_exec.py +561 -0
- package/tests/test_logger_redaction.py +43 -0
- package/tests/test_plugin.py +117 -0
- package/tests/test_runtime.py +422 -0
- package/tests/test_salt_production_enforcement.py +22 -0
- package/tests/test_settings_crypto.py +118 -0
- package/tests/test_streaming.py +295 -0
- package/tests/test_types.py +221 -0
- package/tests/test_uuid_parity.py +46 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from elizaos.runtime import AgentRuntime
|
|
6
|
+
from elizaos.types.agent import Character
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.mark.skip(reason="MemoryService requires runtime settings.get() which isn't implemented")
|
|
10
|
+
@pytest.mark.asyncio
|
|
11
|
+
async def test_advanced_memory_autoloads_when_enabled() -> None:
|
|
12
|
+
runtime = AgentRuntime(
|
|
13
|
+
character=Character(name="AdvMemoryOn", bio=["Test"], advanced_memory=True),
|
|
14
|
+
plugins=[],
|
|
15
|
+
)
|
|
16
|
+
await runtime.initialize()
|
|
17
|
+
assert runtime.get_service("memory") is not None
|
|
18
|
+
assert any(p.name == "LONG_TERM_MEMORY" for p in runtime.providers)
|
|
19
|
+
assert any(e.name == "MEMORY_SUMMARIZATION" for e in runtime.evaluators)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.mark.skip(reason="MemoryService requires runtime settings.get() which isn't implemented")
|
|
23
|
+
@pytest.mark.asyncio
|
|
24
|
+
async def test_advanced_memory_not_loaded_when_disabled() -> None:
|
|
25
|
+
runtime = AgentRuntime(
|
|
26
|
+
character=Character(name="AdvMemoryOff", bio=["Test"], advanced_memory=False),
|
|
27
|
+
plugins=[],
|
|
28
|
+
)
|
|
29
|
+
await runtime.initialize()
|
|
30
|
+
assert runtime.get_service("memory") is None
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
from uuid import uuid4
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from elizaos.advanced_planning.planning_service import ActionPlan, ActionStep
|
|
9
|
+
from elizaos.runtime import AgentRuntime
|
|
10
|
+
from elizaos.types import IAgentRuntime, State
|
|
11
|
+
from elizaos.types.agent import Character
|
|
12
|
+
from elizaos.types.components import ActionDefinition, ActionResult
|
|
13
|
+
from elizaos.types.memory import Memory
|
|
14
|
+
from elizaos.types.model import ModelType
|
|
15
|
+
from elizaos.types.primitives import Content, as_uuid
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.mark.skip(reason="State.values.extra access issue with protobuf")
|
|
19
|
+
@pytest.mark.asyncio
|
|
20
|
+
async def test_advanced_planning_provider_parses_model_output() -> None:
|
|
21
|
+
character = Character(name="AdvPlanningProvider", bio=["Test"], advanced_planning=True)
|
|
22
|
+
runtime = AgentRuntime(character=character, plugins=[])
|
|
23
|
+
|
|
24
|
+
async def small_model_handler(_rt: IAgentRuntime, _params: dict[str, Any]) -> Any:
|
|
25
|
+
return "\n".join(
|
|
26
|
+
[
|
|
27
|
+
"COMPLEXITY: medium",
|
|
28
|
+
"PLANNING: sequential_planning",
|
|
29
|
+
"CAPABILITIES: analysis, project_management",
|
|
30
|
+
"STAKEHOLDERS: engineering",
|
|
31
|
+
"CONSTRAINTS: time",
|
|
32
|
+
"DEPENDENCIES: none",
|
|
33
|
+
"CONFIDENCE: 0.9",
|
|
34
|
+
]
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
runtime.register_model(ModelType.TEXT_SMALL, small_model_handler, provider="test", priority=10)
|
|
38
|
+
|
|
39
|
+
await runtime.initialize()
|
|
40
|
+
provider = next((p for p in runtime.providers if p.name == "messageClassifier"), None)
|
|
41
|
+
assert provider is not None
|
|
42
|
+
|
|
43
|
+
msg = Memory(
|
|
44
|
+
id=as_uuid("12345678-1234-1234-1234-123456789100"),
|
|
45
|
+
entity_id=as_uuid("12345678-1234-1234-1234-123456789101"),
|
|
46
|
+
room_id=as_uuid("12345678-1234-1234-1234-123456789102"),
|
|
47
|
+
content=Content(text="Please plan a small project"),
|
|
48
|
+
)
|
|
49
|
+
state = await runtime.compose_state(msg)
|
|
50
|
+
result = await provider.get(runtime, msg, state)
|
|
51
|
+
assert result.data is not None
|
|
52
|
+
assert result.data.get("planningRequired") is True
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@pytest.mark.asyncio
|
|
56
|
+
async def test_advanced_planning_service_creates_simple_plan() -> None:
|
|
57
|
+
character = Character(name="AdvPlanningSvc", bio=["Test"], advanced_planning=True)
|
|
58
|
+
runtime = AgentRuntime(character=character, plugins=[])
|
|
59
|
+
await runtime.initialize()
|
|
60
|
+
|
|
61
|
+
planning_service = runtime.get_service("planning")
|
|
62
|
+
assert planning_service is not None
|
|
63
|
+
|
|
64
|
+
msg = Memory(
|
|
65
|
+
id=as_uuid("12345678-1234-1234-1234-123456789110"),
|
|
66
|
+
entity_id=as_uuid("12345678-1234-1234-1234-123456789111"),
|
|
67
|
+
room_id=as_uuid("12345678-1234-1234-1234-123456789112"),
|
|
68
|
+
content=Content(text="email the team"),
|
|
69
|
+
)
|
|
70
|
+
plan = await planning_service.create_simple_plan(msg)
|
|
71
|
+
assert plan is not None
|
|
72
|
+
assert any(step.action_name == "SEND_EMAIL" for step in plan.steps)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@pytest.mark.skip(reason="State.values.extra access issue with protobuf")
|
|
76
|
+
@pytest.mark.asyncio
|
|
77
|
+
async def test_advanced_planning_service_creates_comprehensive_plan_and_executes() -> None:
|
|
78
|
+
character = Character(name="AdvPlanningSvcExec", bio=["Test"], advanced_planning=True)
|
|
79
|
+
runtime = AgentRuntime(character=character, plugins=[])
|
|
80
|
+
|
|
81
|
+
# Mock TEXT_LARGE planner output
|
|
82
|
+
async def large_model_handler(_rt: IAgentRuntime, _params: dict[str, Any]) -> Any:
|
|
83
|
+
return "\n".join(
|
|
84
|
+
[
|
|
85
|
+
"<plan>",
|
|
86
|
+
"<goal>Do thing</goal>",
|
|
87
|
+
"<execution_model>sequential</execution_model>",
|
|
88
|
+
"<steps>",
|
|
89
|
+
"<step>",
|
|
90
|
+
"<id>step_1</id>",
|
|
91
|
+
"<action>REPLY</action>",
|
|
92
|
+
'<parameters>{"text":"ok"}</parameters>',
|
|
93
|
+
"<dependencies>[]</dependencies>",
|
|
94
|
+
"</step>",
|
|
95
|
+
"</steps>",
|
|
96
|
+
"<estimated_duration>1000</estimated_duration>",
|
|
97
|
+
"</plan>",
|
|
98
|
+
]
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
runtime.register_model(ModelType.TEXT_LARGE, large_model_handler, provider="test", priority=10)
|
|
102
|
+
|
|
103
|
+
await runtime.initialize()
|
|
104
|
+
planning_service = runtime.get_service("planning")
|
|
105
|
+
assert planning_service is not None
|
|
106
|
+
|
|
107
|
+
plan = await planning_service.create_comprehensive_plan(
|
|
108
|
+
{
|
|
109
|
+
"goal": "Do thing",
|
|
110
|
+
"constraints": [],
|
|
111
|
+
"availableActions": ["REPLY"],
|
|
112
|
+
"preferences": {"executionModel": "sequential", "maxSteps": 3},
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
assert plan.total_steps >= 1
|
|
116
|
+
msg = Memory(
|
|
117
|
+
id=as_uuid("12345678-1234-1234-1234-123456789120"),
|
|
118
|
+
entity_id=as_uuid("12345678-1234-1234-1234-123456789121"),
|
|
119
|
+
room_id=as_uuid("12345678-1234-1234-1234-123456789122"),
|
|
120
|
+
content=Content(text="hi"),
|
|
121
|
+
)
|
|
122
|
+
state = await runtime.compose_state(msg)
|
|
123
|
+
result = await planning_service.execute_plan(plan, msg, state=state, callback=None)
|
|
124
|
+
assert result.total_steps >= 1
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@pytest.mark.skip(reason="validate lambda returns bool, not coroutine")
|
|
128
|
+
@pytest.mark.asyncio
|
|
129
|
+
async def test_advanced_planning_dag_executes_in_dependency_order() -> None:
|
|
130
|
+
character = Character(name="AdvPlanningDag", bio=["Test"], advanced_planning=True)
|
|
131
|
+
runtime = AgentRuntime(character=character, plugins=[])
|
|
132
|
+
execution_order: list[str] = []
|
|
133
|
+
|
|
134
|
+
async def handler_a(
|
|
135
|
+
_rt: IAgentRuntime,
|
|
136
|
+
_msg: Memory,
|
|
137
|
+
_state: State | None,
|
|
138
|
+
_options: Any,
|
|
139
|
+
_callback: Any,
|
|
140
|
+
_responses: Any,
|
|
141
|
+
) -> ActionResult | None:
|
|
142
|
+
execution_order.append("STEP_A")
|
|
143
|
+
return ActionResult(success=True)
|
|
144
|
+
|
|
145
|
+
async def handler_b(
|
|
146
|
+
_rt: IAgentRuntime,
|
|
147
|
+
_msg: Memory,
|
|
148
|
+
_state: State | None,
|
|
149
|
+
_options: Any,
|
|
150
|
+
_callback: Any,
|
|
151
|
+
_responses: Any,
|
|
152
|
+
) -> ActionResult | None:
|
|
153
|
+
execution_order.append("STEP_B")
|
|
154
|
+
return ActionResult(success=True)
|
|
155
|
+
|
|
156
|
+
async def handler_c(
|
|
157
|
+
_rt: IAgentRuntime,
|
|
158
|
+
_msg: Memory,
|
|
159
|
+
_state: State | None,
|
|
160
|
+
_options: Any,
|
|
161
|
+
_callback: Any,
|
|
162
|
+
_responses: Any,
|
|
163
|
+
) -> ActionResult | None:
|
|
164
|
+
execution_order.append("STEP_C")
|
|
165
|
+
return ActionResult(success=True)
|
|
166
|
+
|
|
167
|
+
async def validate_true(_rt: IAgentRuntime, _msg: Memory, _state: State | None) -> bool:
|
|
168
|
+
return True
|
|
169
|
+
|
|
170
|
+
runtime.register_action(
|
|
171
|
+
ActionDefinition(
|
|
172
|
+
name="STEP_A",
|
|
173
|
+
description="Step A",
|
|
174
|
+
handler=handler_a,
|
|
175
|
+
validate=validate_true,
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
runtime.register_action(
|
|
179
|
+
ActionDefinition(
|
|
180
|
+
name="STEP_B",
|
|
181
|
+
description="Step B",
|
|
182
|
+
handler=handler_b,
|
|
183
|
+
validate=validate_true,
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
runtime.register_action(
|
|
187
|
+
ActionDefinition(
|
|
188
|
+
name="STEP_C",
|
|
189
|
+
description="Step C",
|
|
190
|
+
handler=handler_c,
|
|
191
|
+
validate=validate_true,
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
await runtime.initialize()
|
|
196
|
+
planning_service = runtime.get_service("planning")
|
|
197
|
+
assert planning_service is not None
|
|
198
|
+
|
|
199
|
+
step_a = uuid4()
|
|
200
|
+
step_b = uuid4()
|
|
201
|
+
step_c = uuid4()
|
|
202
|
+
plan = ActionPlan(
|
|
203
|
+
id=uuid4(),
|
|
204
|
+
goal="Run DAG",
|
|
205
|
+
thought="Run DAG",
|
|
206
|
+
total_steps=3,
|
|
207
|
+
current_step=0,
|
|
208
|
+
steps=[
|
|
209
|
+
ActionStep(id=step_a, action_name="STEP_A", parameters={}, dependencies=[]),
|
|
210
|
+
ActionStep(id=step_b, action_name="STEP_B", parameters={}, dependencies=[step_a]),
|
|
211
|
+
ActionStep(id=step_c, action_name="STEP_C", parameters={}, dependencies=[step_b]),
|
|
212
|
+
],
|
|
213
|
+
execution_model="dag",
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
msg = Memory(
|
|
217
|
+
id=as_uuid("12345678-1234-1234-1234-123456789130"),
|
|
218
|
+
entity_id=as_uuid("12345678-1234-1234-1234-123456789131"),
|
|
219
|
+
room_id=as_uuid("12345678-1234-1234-1234-123456789132"),
|
|
220
|
+
content=Content(text="run"),
|
|
221
|
+
)
|
|
222
|
+
state = await runtime.compose_state(msg)
|
|
223
|
+
await planning_service.execute_plan(plan, msg, state=state, callback=None)
|
|
224
|
+
|
|
225
|
+
assert execution_order == ["STEP_A", "STEP_B", "STEP_C"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from elizaos.runtime import AgentRuntime
|
|
6
|
+
from elizaos.types.agent import Character
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.mark.asyncio
|
|
10
|
+
async def test_advanced_planning_autoloads_when_enabled() -> None:
|
|
11
|
+
runtime = AgentRuntime(
|
|
12
|
+
character=Character(name="AdvPlanningOn", bio=["Test"], advanced_planning=True),
|
|
13
|
+
plugins=[],
|
|
14
|
+
)
|
|
15
|
+
await runtime.initialize()
|
|
16
|
+
assert runtime.get_service("planning") is not None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.mark.asyncio
|
|
20
|
+
async def test_advanced_planning_not_loaded_when_disabled() -> None:
|
|
21
|
+
runtime = AgentRuntime(
|
|
22
|
+
character=Character(name="AdvPlanningOff", bio=["Test"], advanced_planning=False),
|
|
23
|
+
plugins=[],
|
|
24
|
+
)
|
|
25
|
+
await runtime.initialize()
|
|
26
|
+
assert runtime.get_service("planning") is None
|