mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-17 18:25:42 +02:00
[eric] agents: drop spurious @staticmethod on invoke_agent (every InvokeAgent call 500'd)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Agent run entry points for AgentManager: launch a new top-level run and the staticmethod
|
||||
"""Agent run entry points for AgentManager: launch a new top-level run and the
|
||||
invoke_agent helper (fork-and-send a sub-agent). The no-SDK mock fallback lives in MockAgent.
|
||||
Split into a mixin to keep the manager file under the size ceiling; self.run_agent_loop /
|
||||
self.sessions resolve across the MRO exactly as before."""
|
||||
@@ -137,7 +137,6 @@ class AgentLaunch(AgentManagerProtocol):
|
||||
|
||||
return session
|
||||
|
||||
@staticmethod
|
||||
@typechecked
|
||||
async def invoke_agent(
|
||||
self,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
"""InvokeAgent (agent-to-agent) binding invariant.
|
||||
|
||||
The bug: invoke_agent carried a spurious @staticmethod on a def whose first
|
||||
parameter is self, so the instance never bound and EVERY call raised
|
||||
TypeError("missing 1 required positional argument: 'self'"), which
|
||||
/api/invoke-agent/run surfaced as a 500 to the calling agent.
|
||||
|
||||
The seal: call it exactly the way the route does (instance, all-keyword args)
|
||||
and pin that it reaches the method body: an unknown session must raise the
|
||||
body's ValueError, never a binding TypeError.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
import backend.apps.agents.manager.AgentLaunch as agent_launch_module
|
||||
from backend.apps.agents.agent_manager import agent_manager
|
||||
|
||||
|
||||
def test_invoke_agent_binds_as_instance_method(monkeypatch) -> None:
|
||||
monkeypatch.setattr(agent_launch_module, "load_session_data", lambda sid: None)
|
||||
|
||||
async def run() -> None:
|
||||
with pytest.raises(ValueError, match="not found"):
|
||||
await agent_manager.invoke_agent(
|
||||
source_session_id="no-such-session",
|
||||
message="what did you do?",
|
||||
)
|
||||
|
||||
asyncio.run(run())
|
||||
Reference in New Issue
Block a user