Skip to content

Self-improving AI Employees for everyone

fix(temporal): run Skill tool calls on the agent's own queue

trohitgda982dbea9ea
diff --git a/server/services/temporal/agent_activities.py b/server/services/temporal/agent_activities.py
index e7af1766..10897404 100644
--- a/server/services/temporal/agent_activities.py
+++ b/server/services/temporal/agent_activities.py
@@ -65,16 +65,21 @@ _SEED_TRANSCRIPT_MAX_BYTES = 1_000_000
def _tool_activity_policy(cls: Any) -> Dict[str, Any]:
- """Freeze declaration values in history rather than consult code on replay."""
+ """Freeze declaration values in history rather than consult code on replay.
+
+ A tool with no plugin class (the Skill tool) keeps the base timeouts and
+ retries but records no queue: its ``agent.*`` activity runs on the
+ agent's own queue, where it is registered, not on a plugin pool queue.
+ """
from services.plugin.base import BaseNode
- cls = cls or BaseNode
- retry = cls.retry_policy
- heartbeat = cls.heartbeat_timeout
+ declared = cls or BaseNode
+ retry = declared.retry_policy
+ heartbeat = declared.heartbeat_timeout
return {
- "start_to_close_seconds": cls.start_to_close_timeout.total_seconds(),
+ "start_to_close_seconds": declared.start_to_close_timeout.total_seconds(),
"heartbeat_seconds": heartbeat.total_seconds() if heartbeat else None,
- "task_queue": cls.task_queue,
+ "task_queue": cls.task_queue if cls else None,
"retry_policy": {
"initial_interval_seconds": retry.initial_interval.total_seconds(),
"backoff_coefficient": retry.backoff_coefficient,
diff --git a/server/tests/temporal/test_skill_tool_routing.py b/server/tests/temporal/test_skill_tool_routing.py
new file mode 100644
index 00000000..29f23b69
--- /dev/null
+++ b/server/tests/temporal/test_skill_tool_routing.py
@@ -0,0 +1,28 @@
+"""The Skill tool's activity runs where it is registered.
+
+``agent.skill.invoke`` is a framework activity on the agent's own queue
+(``collect_agent_activities``). The Skill tool has no plugin class, so its
+frozen policy once recorded BaseNode's pool queue, ``machina-default``, whose
+worker registers only plugin activities: every Skill call of a deployed run
+failed with NotFoundError on all its attempts.
+"""
+
+import nodes # noqa: F401 -- populate plugin registry
+from services.node_registry import get_node_class
+from services.temporal.agent_activities import _tool_activity_policy, collect_agent_activities
+from services.temporal.agent_workflow import _frozen_tool_activity_options
+
+DEPLOYED = {"execution_control_version": 1, "temporal_worker_pool_enabled": True}
+
+
+def test_the_skill_tool_runs_on_the_agents_own_queue():
+ options = _frozen_tool_activity_options(_tool_activity_policy(None), DEPLOYED)
+ # No queue: Temporal schedules it on the workflow's own queue.
+ assert options["task_queue"] is None
+ names = {getattr(fn, "__temporal_activity_definition").name for fn in collect_agent_activities()}
+ assert "agent.skill.invoke" in names
+
+
+def test_a_plugin_tool_keeps_its_declared_queue():
+ cls = get_node_class("taskManager")
+ assert _frozen_tool_activity_options(_tool_activity_policy(cls), DEPLOYED)["task_queue"] == cls.task_queue