-
Notifications
You must be signed in to change notification settings - Fork 4
Run via agent #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
andyfr
wants to merge
9
commits into
master
Choose a base branch
from
run_via_agent
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Run via agent #15
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement external HTTP API for AI/ML agent control of OpenRA games. Features: - HTTP server on localhost:8080 with RESTful JSON API - Game state observation (units, buildings, resources, enemies) - Unit command execution (move, attack, stop, build) - Automated game start/stop/kill operations - Local player control without bot limitations Architecture: - GlobalAgentServer: Singleton HTTP server (world-level trait) - AgentInterface: Player-level trait for game state and orders - AgentHttpServer: HTTP request handler and endpoint routing - GameLauncher: Automated game lifecycle management - Module organized in OpenRA.Mods.CA/Traits/AgentAPI/ Configuration: - Disabled by default for security - Enable via command-line: Server.AgentAPI=true - Port configured in world.yaml (GlobalAgentServer only) - Removed duplicate Port field from AgentInterface Documentation: - Comprehensive API docs in docs/AGENT_API.md - Module README in OpenRA.Mods.CA/Traits/AgentAPI/README.md - Implementation notes in docs/tasks/automated-bot-control.md - Added to project README.md and CLAUDE.md Code quality: - Added comments policy to CLAUDE.md (explain WHY, not WHAT) - Cleaned up all comments in AgentAPI module per policy - Self-documenting code with minimal explanatory comments 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This adds an automated smoke test that verifies basic game functionality using the Agent API as a test interface. The test runs in CI to catch runtime issues that aren't detected by build/YAML/Lua checks. What the smoke test validates: - Game starts without crashing - Map loads successfully - Units spawn correctly - Commands can be issued and executed - Game loop runs without freezes or deadlocks The test uses Xvfb for headless execution in GitHub Actions and runs on the 'all-connected' map with a 5-minute timeout. Logs are uploaded as artifacts on failure for debugging. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Upgrade from v3 to v4 to fix the smoke test job failure. The v3 version was deprecated in April 2024 and GitHub Actions now blocks jobs that use it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The previous approach of using Launch.Map parameter didn't properly start a game - it just navigated to the map in the menu. This caused the Agent API to never become available since it only activates when a game is actually running. New approach: 1. Start game in main menu with Agent API enabled 2. Wait for API to become available 3. Use /api/game/start to programmatically start a game 4. Then proceed with smoke tests This matches the documented "Workflow 2: API-Started Game with Bots" from docs/AGENT_API.md. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced the smoke test with much better debugging to diagnose the game crash issue in CI: - Check if game dies immediately after startup (3s) - Show progress updates every 5 seconds - Display last 3 lines of game log during wait - Output full game log when crashes occur - Show exact timing of failures This will help identify whether the game: - Crashes during mod loading - Times out waiting for resources - Has OpenGL/rendering issues in CI - Simply needs more time to start 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The game takes longer to load in CI due to slower I/O and software rendering (llvmpipe). The mod was hanging at "Loading mod: modcontent" for 30+ seconds, which is normal for the CI environment. Changes: - Increase API_READY_WAIT from 30s to 120s - Increase MAX_WAIT_SECONDS from 60s to 120s - Fix script execute permissions The debug output shows the game is still running but just needs more time to load all the mod assets in the CI environment. This is expected behavior for headless/virtualized environments with software rendering. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The game was hanging at "Loading mod: modcontent" because the modcontent installer was waiting for user interaction to install missing content packages. Root cause: - The CA mod references optional content packages in ~/.config/openra/Content/ca/ - Locally these are installed, so the game loads normally - In CI they're missing, triggering modcontent's interactive installer dialog - The dialog waits for button clicks that never come in headless mode Solution: - Create an empty ~/.config/openra/Content/ca/ directory before starting the game - This prevents modcontent from detecting missing packages - The game can proceed to main menu without user interaction The mod's content packages are marked as optional (~ prefix in mod.yaml), so the game can run without them for basic smoke testing purposes. Note: Other CI jobs (linux, linux-mono, windows) don't have this issue because they only compile/validate code and never actually start the game. The smoke-test job is the first to run the game, hence the new requirement. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
After researching how OpenRA and other mods handle CI testing, I found that no one actually runs the full game in CI - they only do compilation and YAML validation. Our smoke test is unique in trying to start the game. Root cause identified: - The CA mod's ModContent section defines a "base" package with Required: true - This package has TestFiles that modcontent checks for: - ^SupportDir|Content/ca/speech.mix - ^SupportDir|Content/ca/russian.mix - ^SupportDir|Content/ca/sounds.mix - When these files don't exist, modcontent shows an interactive installer dialog - The dialog waits for user input that never comes in headless CI Solution: - Create empty touch files for the required TestFiles - This satisfies modcontent's existence checks - The game can proceed to main menu without blocking Research sources: - OpenRA main repo CI: Only runs make test (YAML validation) - OpenRA Mod SDK CI: Same approach, no game startup - OpenRA dedicated server: Uses Server.dll (headless) not Game.dll - Agent API needs Game.dll, so we must solve the modcontent issue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The /api/game/start endpoint returns JSON with whitespace formatting: "success": true, instead of: "success":true The grep pattern wasn't matching because it expected no whitespace. Changed to use [[:space:]]* to handle optional whitespace in JSON. This was causing the test to fail even though the API was working correctly and the game was starting successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.