This commit is contained in:
@@ -14,16 +14,19 @@ IO.puts("=" |> String.duplicate(60))
|
||||
try do
|
||||
TaskRegistry.start_link()
|
||||
rescue
|
||||
_ -> :ok # Already started
|
||||
# Already started
|
||||
_ -> :ok
|
||||
end
|
||||
|
||||
try do
|
||||
MCPServer.start_link()
|
||||
rescue
|
||||
_ -> :ok # Already started
|
||||
# Already started
|
||||
_ -> :ok
|
||||
end
|
||||
|
||||
Process.sleep(1000) # Give services time to start
|
||||
# Give services time to start
|
||||
Process.sleep(1000)
|
||||
|
||||
# Test 1: Register two agents
|
||||
IO.puts("\n1️⃣ Registering two test agents...")
|
||||
@@ -58,23 +61,27 @@ resp1 = MCPServer.handle_mcp_request(agent1_req)
|
||||
resp2 = MCPServer.handle_mcp_request(agent2_req)
|
||||
|
||||
# Extract agent IDs
|
||||
agent1_id = case resp1 do
|
||||
%{"result" => %{"content" => [%{"text" => text}]}} ->
|
||||
data = Jason.decode!(text)
|
||||
data["agent_id"]
|
||||
_ ->
|
||||
IO.puts("❌ Failed to register agent 1: #{inspect(resp1)}")
|
||||
System.halt(1)
|
||||
end
|
||||
agent1_id =
|
||||
case resp1 do
|
||||
%{"result" => %{"content" => [%{"text" => text}]}} ->
|
||||
data = Jason.decode!(text)
|
||||
data["agent_id"]
|
||||
|
||||
agent2_id = case resp2 do
|
||||
%{"result" => %{"content" => [%{"text" => text}]}} ->
|
||||
data = Jason.decode!(text)
|
||||
data["agent_id"]
|
||||
_ ->
|
||||
IO.puts("❌ Failed to register agent 2: #{inspect(resp2)}")
|
||||
System.halt(1)
|
||||
end
|
||||
_ ->
|
||||
IO.puts("❌ Failed to register agent 1: #{inspect(resp1)}")
|
||||
System.halt(1)
|
||||
end
|
||||
|
||||
agent2_id =
|
||||
case resp2 do
|
||||
%{"result" => %{"content" => [%{"text" => text}]}} ->
|
||||
data = Jason.decode!(text)
|
||||
data["agent_id"]
|
||||
|
||||
_ ->
|
||||
IO.puts("❌ Failed to register agent 2: #{inspect(resp2)}")
|
||||
System.halt(1)
|
||||
end
|
||||
|
||||
IO.puts("✅ Agent 1 (Alpha Wolf): #{agent1_id}")
|
||||
IO.puts("✅ Agent 2 (Beta Tiger): #{agent2_id}")
|
||||
@@ -219,7 +226,7 @@ history_req1 = %{
|
||||
history_resp1 = MCPServer.handle_mcp_request(history_req1)
|
||||
IO.puts("Agent 1 history: #{inspect(history_resp1)}")
|
||||
|
||||
IO.puts("\n" <> "=" |> String.duplicate(60))
|
||||
IO.puts(("\n" <> "=") |> String.duplicate(60))
|
||||
IO.puts("🎉 AGENT-SPECIFIC TASK POOLS TEST COMPLETE!")
|
||||
IO.puts("✅ Each agent now has their own task pool")
|
||||
IO.puts("✅ No more task chaos or cross-contamination")
|
||||
|
||||
@@ -202,6 +202,7 @@ defmodule AgentTaskPoolTest do
|
||||
%{"result" => %{"content" => [%{"text" => text}]}} ->
|
||||
data = Jason.decode!(text)
|
||||
data["agent_id"]
|
||||
|
||||
_ ->
|
||||
"unknown"
|
||||
end
|
||||
|
||||
@@ -30,24 +30,27 @@ Process.sleep(1000)
|
||||
IO.puts("\n2️⃣ Creating agent-specific tasks...")
|
||||
|
||||
# Tasks for Agent 1
|
||||
task1_agent1 = Task.new("Fix auth bug", "Debug authentication issue", %{
|
||||
priority: :high,
|
||||
assigned_agent: agent1.id,
|
||||
metadata: %{agent_created: true}
|
||||
})
|
||||
task1_agent1 =
|
||||
Task.new("Fix auth bug", "Debug authentication issue", %{
|
||||
priority: :high,
|
||||
assigned_agent: agent1.id,
|
||||
metadata: %{agent_created: true}
|
||||
})
|
||||
|
||||
task2_agent1 = Task.new("Add auth tests", "Write auth tests", %{
|
||||
priority: :normal,
|
||||
assigned_agent: agent1.id,
|
||||
metadata: %{agent_created: true}
|
||||
})
|
||||
task2_agent1 =
|
||||
Task.new("Add auth tests", "Write auth tests", %{
|
||||
priority: :normal,
|
||||
assigned_agent: agent1.id,
|
||||
metadata: %{agent_created: true}
|
||||
})
|
||||
|
||||
# Tasks for Agent 2
|
||||
task1_agent2 = Task.new("Write API docs", "Document endpoints", %{
|
||||
priority: :normal,
|
||||
assigned_agent: agent2.id,
|
||||
metadata: %{agent_created: true}
|
||||
})
|
||||
task1_agent2 =
|
||||
Task.new("Write API docs", "Document endpoints", %{
|
||||
priority: :normal,
|
||||
assigned_agent: agent2.id,
|
||||
metadata: %{agent_created: true}
|
||||
})
|
||||
|
||||
# Add tasks to respective inboxes
|
||||
Inbox.add_task(agent1.id, task1_agent1)
|
||||
@@ -76,7 +79,12 @@ IO.puts("\n4️⃣ Checking remaining tasks...")
|
||||
status1 = Inbox.get_status(agent1.id)
|
||||
status2 = Inbox.get_status(agent2.id)
|
||||
|
||||
IO.puts("Agent 1: #{status1.pending_count} pending, current: #{if status1.current_task, do: status1.current_task.title, else: "none"}")
|
||||
IO.puts("Agent 2: #{status2.pending_count} pending, current: #{if status2.current_task, do: status2.current_task.title, else: "none"}")
|
||||
IO.puts(
|
||||
"Agent 1: #{status1.pending_count} pending, current: #{if status1.current_task, do: status1.current_task.title, else: "none"}"
|
||||
)
|
||||
|
||||
IO.puts(
|
||||
"Agent 2: #{status2.pending_count} pending, current: #{if status2.current_task, do: status2.current_task.title, else: "none"}"
|
||||
)
|
||||
|
||||
IO.puts("\n🎉 SUCCESS! Agent-specific task pools working!")
|
||||
|
||||
@@ -90,14 +90,17 @@ defmodule SessionManagementTest do
|
||||
case Jason.decode(body) do
|
||||
{:ok, %{"result" => _result}} ->
|
||||
IO.puts(" ✅ Valid MCP response received")
|
||||
|
||||
{:ok, %{"error" => error}} ->
|
||||
IO.puts(" ⚠️ MCP error: #{inspect(error)}")
|
||||
|
||||
_ ->
|
||||
IO.puts(" ❌ Invalid response format")
|
||||
end
|
||||
|
||||
{:ok, %HTTPoison.Response{status_code: status_code, body: body}} ->
|
||||
IO.puts("❌ Request failed with status #{status_code}")
|
||||
|
||||
case Jason.decode(body) do
|
||||
{:ok, parsed} -> IO.puts(" Error: #{inspect(parsed)}")
|
||||
_ -> IO.puts(" Body: #{body}")
|
||||
|
||||
@@ -10,6 +10,7 @@ Process.sleep(1000)
|
||||
|
||||
# Test 1: Initialize call (system call, should work without agent_id)
|
||||
IO.puts("Testing initialize call...")
|
||||
|
||||
init_request = %{
|
||||
"jsonrpc" => "2.0",
|
||||
"id" => 1,
|
||||
@@ -31,6 +32,7 @@ IO.puts("Initialize response: #{inspect(init_response)}")
|
||||
|
||||
# Test 2: Tools/list call (system call, should work without agent_id)
|
||||
IO.puts("\nTesting tools/list call...")
|
||||
|
||||
tools_request = %{
|
||||
"jsonrpc" => "2.0",
|
||||
"id" => 2,
|
||||
@@ -42,6 +44,7 @@ IO.puts("Tools/list response: #{inspect(tools_response)}")
|
||||
|
||||
# Test 3: Register agent call (should work)
|
||||
IO.puts("\nTesting register_agent call...")
|
||||
|
||||
register_request = %{
|
||||
"jsonrpc" => "2.0",
|
||||
"id" => 3,
|
||||
@@ -59,7 +62,8 @@ register_response = GenServer.call(AgentCoordinator.MCPServer, {:mcp_request, re
|
||||
IO.puts("Register agent response: #{inspect(register_response)}")
|
||||
|
||||
# Test 4: Try a call that requires agent_id (should fail without agent_id)
|
||||
IO.puts("\nTesting call that requires agent_id (should fail)...")
|
||||
IO.puts("Testing call that requires agent_id (should fail)...")
|
||||
|
||||
task_request = %{
|
||||
"jsonrpc" => "2.0",
|
||||
"id" => 4,
|
||||
@@ -76,4 +80,4 @@ task_request = %{
|
||||
task_response = GenServer.call(AgentCoordinator.MCPServer, {:mcp_request, task_request})
|
||||
IO.puts("Task creation response: #{inspect(task_response)}")
|
||||
|
||||
IO.puts("\n✅ All tests completed!")"
|
||||
IO.puts("All tests completed!")
|
||||
|
||||
@@ -11,14 +11,17 @@ IO.puts("Testing VS Code tool integration...")
|
||||
|
||||
# Check if VS Code tools are available
|
||||
tools = AgentCoordinator.MCPServer.get_tools()
|
||||
vscode_tools = Enum.filter(tools, fn tool ->
|
||||
case Map.get(tool, "name") do
|
||||
"vscode_" <> _ -> true
|
||||
_ -> false
|
||||
end
|
||||
end)
|
||||
|
||||
vscode_tools =
|
||||
Enum.filter(tools, fn tool ->
|
||||
case Map.get(tool, "name") do
|
||||
"vscode_" <> _ -> true
|
||||
_ -> false
|
||||
end
|
||||
end)
|
||||
|
||||
IO.puts("Found #{length(vscode_tools)} VS Code tools:")
|
||||
|
||||
Enum.each(vscode_tools, fn tool ->
|
||||
IO.puts(" - #{tool["name"]}")
|
||||
end)
|
||||
@@ -27,4 +30,4 @@ if length(vscode_tools) > 0 do
|
||||
IO.puts("✅ VS Code tools are properly integrated!")
|
||||
else
|
||||
IO.puts("❌ VS Code tools are NOT integrated")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user