Echo own monster moves into local state#15
Merged
Conversation
The server deliberately skips broadcasting MonsterMoved back to the client that moved the monster, and the agent-client never applied its own MonsterMove commands locally, so every owned monster sat frozen in nearby_monsters at its spawn position while its real position wandered off with the AI. The LLM then attacked coordinates the monster left long ago, and the server's range gate silently dropped every swing. Apply each outgoing MonsterMove to nearby_monsters before sending it, which is exactly what the server's skip assumes the owner already does. Verified on prod: owned monsters moved 0/18 across 35s before, 27/27 across 90s after, with live idle→walk→run transitions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
|
Thanks for the fix and the excellent diagnosis — merged as-is, and it held up well in review. Heads-up on a follow-up (fb83211) that builds on it right after the merge:
|
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
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.
Monsters owned by the agent-client (ambient spawns it hosts AI for) stay frozen at their spawn position in the client's own
nearby_monstersmap, while their real server-side position wanders off with the AI. Two facts combine into this:MonsterMovedback to the client that moved the monster (skip_player_idin the monster-move visibility diff).MonsterMovecommands to local state —tick_allreturns commands, they get sent, and nothing writes the new position back.So the LLM is fed phantom coordinates for every monster this client spawned: it sees "scp939 1.4m away", the chase loop agrees it is already in range (same stale position) and never walks,
PlayerAttackgoes out, and the server's range gate silently drops it because the monster's real position is elsewhere — no event, no error, and the LLM retries forever. Operator NPCs (guards/merchants with combat behaviors) are affected the same way. Observed live: an agent standing in a spawn field swung at the same monster for 5+ minutes with zeroPlayerAttackedevents, while another (human) player killed those same monsters normally — their client receives the broadcasts.The fix mirrors what the server's skip assumes: the owner already knows where its monsters are — so apply each outgoing
MonsterMovetonearby_monsters(position, rotation, state) before sending it.Verified against prod: before, owned monsters moved 0/18 across samples 35s apart (all
idleat spawn coordinates, indefinitely); after, 27/27 moved across 90s (up to 47m, with live idle→walk→run state transitions).cargo test -p agent-client20/20, clippy clean for the change.Found while watching an agent through the spectator panel proposed in #13 — the map made the frozen-monster pattern obvious.
🤖 Generated with Claude Code