diff --git a/app/plugins/builtins/automation/agent_routes.py b/app/plugins/builtins/automation/agent_routes.py index 2f90c1c..fef713a 100644 --- a/app/plugins/builtins/automation/agent_routes.py +++ b/app/plugins/builtins/automation/agent_routes.py @@ -166,14 +166,14 @@ async def list_tools( ) registry = get_tool_registry() - tools = registry.list_tools() + tools = registry.list_for_api() return { "items": [ { - "id": t.get("id", t.get("name", "")), + "id": t.get("name", ""), "name": t.get("name", ""), "description": t.get("description", ""), - "plugin": t.get("plugin", ""), + "plugin": t.get("plugin_name", ""), } for t in tools ], diff --git a/tests/test_m6_miniapp_hosts.py b/tests/test_m6_miniapp_hosts.py index 66b616e..31f4f6f 100644 --- a/tests/test_m6_miniapp_hosts.py +++ b/tests/test_m6_miniapp_hosts.py @@ -169,3 +169,17 @@ class TestAgentLoopContext: src = inspect.getsource(agent_loop) assert '"agent_name"' in src, "tool_context must include agent_name" + + +def test_agents_tools_route_uses_list_for_api(): + """M6 verification blocker fixed: /api/v1/agents/tools used to call + registry.list_tools() (nonexistent — 500 on production, pre-existing). + The route must use list_for_api() with the correct field mapping. + """ + import inspect + + from app.plugins.builtins.automation.agent_routes import list_tools + + src = inspect.getsource(list_tools) + assert "list_for_api()" in src, "route must use list_for_api()" + assert "list_tools()" not in src.replace("list_for_api()", "")