Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 57 additions & 6 deletions .claude/project-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ c:\Projects\Agent Arena\
- ✅ Core classes verified: SimulationManager, Agent, EventBus, ToolRegistry
- ✅ IPC system implemented (Godot ↔ Python via HTTP/FastAPI)
- ✅ Benchmark scenes created (foraging, crafting_chain, team_capture)
- ⏳ Next: Set up Python environment and agent runtime
- ⏳ Next: Integrate LLM backends with agent decision-making
- ✅ Tool execution system connected (Agent → ToolRegistry → IPC → Python)

### Active Work Items
- 🔄 **Andrew**: LLM backend integration with agent decision-making
- 🔄 **Justin** (Issue #15): Build out benchmark scenes with game content
- ✅ **Justin** (Issue #16): Connect tool execution system in Godot - **COMPLETE**

## Development Commands

Expand Down Expand Up @@ -196,15 +200,62 @@ python run_ipc_server.py --host 127.0.0.1 --port 5000 --workers 4 --debug

### IPCClient (Node)
- HTTP client for Godot ↔ Python communication
- Methods: `connect_to_server()`, `send_tick_request()`, `get_tick_response()`, `has_response()`
- Methods: `connect_to_server()`, `send_tick_request()`, `get_tick_response()`, `has_response()`, `execute_tool_sync()`
- Properties: `server_url`
- Signals: `response_received`, `connection_failed`

## Tool Execution System

The tool execution system enables agents to perform actions in the simulation by calling Python tool functions.

### Architecture
```
Agent.call_tool() → ToolRegistry.execute_tool() → IPCClient.execute_tool_sync() →
Python IPC Server (/tools/execute) → ToolDispatcher.execute_tool() → Tool Function
```

### Available Tools
- **Movement**: `move_to`, `navigate_to`, `stop_movement`, `rotate_to_face`
- **Inventory**: `pickup_item`, `drop_item`, `use_item`, `get_inventory`, `craft_item`
- **World Query**: (defined in `python/tools/world_query.py`)

### Usage Example (GDScript)
```gdscript
# Setup
var agent = Agent.new()
var tool_registry = ToolRegistry.new()
var ipc_client = IPCClient.new()

tool_registry.set_ipc_client(ipc_client)
agent.set_tool_registry(tool_registry)

# Execute tool
var result = agent.call_tool("move_to", {
"target_position": [10.0, 0.0, 5.0],
"speed": 1.5
})

if result["success"]:
print("Tool executed successfully: ", result["result"])
else:
print("Tool failed: ", result["error"])
```

### Testing
- Test scenes: `scenes/tests/test_tool_execution_simple.tscn` (recommended), `scenes/tests/test_tool_execution.tscn`
- Test scripts: `scripts/tests/test_tool_execution_simple.gd`, `scripts/tests/test_tool_execution.gd`
- Test README: `scenes/tests/README.md`
- Documentation: `TESTING_TOOL_EXECUTION.md`, `TOOL_TESTING_FIXED.md`

## Known Issues
- Benchmark scenes are empty placeholders (need to create actual game worlds)
- Python environment needs initial setup (venv + pip install)
- LLM backends not yet connected to agent decision-making
- Tool execution in Godot currently returns stub responses

## Recent Issues
- Issue #15: Build out benchmark scenes with game content (assigned to Justin) - In Progress
- Issue #16: Connect tool execution system in Godot (assigned to Justin) - ✅ **COMPLETE**
- See: `TESTING_TOOL_EXECUTION.md`, `TOOL_TESTING_FIXED.md` for details
- Test scenes: `scenes/tests/` (use `test_tool_execution_simple.tscn` for quick verification)
- LLM backend integration (assigned to Andrew) - In Progress

## References
- Godot docs: https://docs.godotengine.org/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ build/
*.swo
*~
.DS_Store
promptPad.md

# Logs and databases
*.log
Expand Down
55 changes: 55 additions & 0 deletions START_IPC_SERVER.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@echo off
REM Agent Arena - IPC Server Startup Script
REM This script starts the Python IPC server for Godot-Python communication

echo ========================================
echo Agent Arena - Starting IPC Server
echo ========================================
echo.

cd /d "%~dp0\python"

REM Check if venv exists
if not exist "venv\" (
echo ERROR: Python virtual environment not found!
echo Please run: python -m venv venv
echo Then install dependencies: venv\Scripts\pip install -r requirements.txt
pause
exit /b 1
)

REM Activate venv
echo Activating Python virtual environment...
call venv\Scripts\activate.bat

REM Check if required packages are installed
python -c "import fastapi, uvicorn" 2>nul
if errorlevel 1 (
echo.
echo ERROR: Required packages not installed!
echo Installing dependencies...
pip install fastapi uvicorn
if errorlevel 1 (
echo.
echo Failed to install dependencies.
pause
exit /b 1
)
)

echo.
echo Starting IPC Server...
echo Server will be available at: http://127.0.0.1:5000
echo.
echo Press Ctrl+C to stop the server
echo ========================================
echo.

python run_ipc_server.py

REM If server exits, pause so user can see error
if errorlevel 1 (
echo.
echo Server exited with error!
pause
)
140 changes: 0 additions & 140 deletions TROUBLESHOOTING_IPC.md

This file was deleted.

15 changes: 15 additions & 0 deletions godot/include/agent_arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Agent : public godot::Node3D {
godot::Dictionary short_term_memory;
godot::Array action_history;
bool is_active;
ToolRegistry* tool_registry;

protected:
static void _bind_methods();
Expand All @@ -131,6 +132,10 @@ class Agent : public godot::Node3D {
// Tool interface
godot::Dictionary call_tool(const godot::String& tool_name, const godot::Dictionary& params);

// Tool registry management
void set_tool_registry(ToolRegistry* registry);
ToolRegistry* get_tool_registry() const { return tool_registry; }

// Getters/Setters
godot::String get_agent_id() const { return agent_id; }
void set_agent_id(const godot::String& id) { agent_id = id; }
Expand All @@ -144,6 +149,7 @@ class ToolRegistry : public godot::Node {

private:
godot::Dictionary registered_tools;
IPCClient* ipc_client;

protected:
static void _bind_methods();
Expand All @@ -152,11 +158,17 @@ class ToolRegistry : public godot::Node {
ToolRegistry();
~ToolRegistry();

void _ready() override;

void register_tool(const godot::String& name, const godot::Dictionary& schema);
void unregister_tool(const godot::String& name);
godot::Dictionary get_tool_schema(const godot::String& name);
godot::Array get_all_tool_names();
godot::Dictionary execute_tool(const godot::String& name, const godot::Dictionary& params);

// IPC Client management
void set_ipc_client(IPCClient* client);
IPCClient* get_ipc_client() const { return ipc_client; }
};

/**
Expand Down Expand Up @@ -195,6 +207,9 @@ class IPCClient : public godot::Node {
godot::Dictionary get_tick_response();
bool has_response() const { return response_received; }

// Tool execution
godot::Dictionary execute_tool_sync(const godot::String& tool_name, const godot::Dictionary& params, const godot::String& agent_id = "", uint64_t tick = 0);

// Getters/Setters
godot::String get_server_url() const { return server_url; }
void set_server_url(const godot::String& url);
Expand Down
Loading