Single-file fix
- Symptom. "Players see double mileage in the speedometer."
- Agent calls
read_file({ resource: "speed_hud", path: "client/main.lua" }). - Agent calls
write_file({ resource: "speed_hud", path: "client/main.lua", content: "<patched>" }). - Agent calls
restart_resource({ name: "speed_hud" }). - Agent calls
tail_console({ lines: 20 })to verify no errors on start.
You confirm in-game; done.
UI iteration
- Agent edits
web/src/App.vue. - Agent calls
run_shell({ resource: "my_res", command: "npm", args: ["run", "build"], cwd: "web", timeoutMs: 60000 }). - Agent calls
restart_resource({ name: "my_res" }). - You reopen the UI (F6 /
/myres). - Agent calls
screenshot_nui({ resource: "my_res" }). - Agent reads the PNG, describes what it sees, proposes the next tweak.
Average loop time on a dev box: ~5–10 seconds per change.
Multi-resource change
- Agent picks a name and runs
scaffold_fivem_resource_workflow(mandatory grill). - After your confirmation, agent:
create_resource,refresh_resources,run_shellfor any UI scaffolding, then a batch ofwrite_filecalls. ensure_resourcereturnsstateAfter === "started"and the post-start console lines.- If start failed, agent calls
tail_consoleto find the syntax error and offers a single-file fix before re-writing.
Live player workflow
- You:
/agent_test_optin. - Agent:
register_test_subject({ serverId: 1 }). - Agent:
get_player_state({ serverId: 1 })to see coords, ped, health. - Agent:
esx_call_player({ serverId: 1, method: "getInventory" })to see items. - Agent:
client_call_native({ serverId: 1, native: "SetEntityCoords", args: ["$ped", 200, -800, 30, false, false, false, true] })to test a teleport. - Agent:
client_call_native({ serverId: 1, native: "GetEntityCoords", args: ["$ped", true] })to verify the move.
What goes wrong + how the agent recovers
| Problem | Tool that catches it | Recovery path |
|---|---|---|
| Resource won't start | ensure_resource returns RESOURCE_FAILED_TO_START + log lines | tail_console, propose fix, ask before re-writing |
| Token leaked / suspicious activity | audit log JSONL | rotate token (rm dist/.agent_token && restart agent_api) |
Player griefed by a client_call_native | hard agent_api_client_blocked_natives | add native to blocklist, restart |
| Rate limit hit | tool returns RATE_LIMITED with retryAfterMs | back off, then continue |
| Multi-step write race | per-resource lock serialises | next call waits, no race |