Skip to main content

Agent Movement API

Documentation for the movement completion tracking API added to HyperscapeService.

Overview

The HyperscapeService now provides movement completion tracking, allowing actions to wait for movement to finish before proceeding. This is critical for multi-step actions like banking (walk to bank → deposit items).

API Reference

waitForMovementComplete(timeoutMs?: number): Promise<void>

Wait for the current movement to complete. Resolves immediately if not moving. Parameters:
  • timeoutMs (optional): Maximum time to wait in milliseconds (default: 15000)
Returns: Promise that resolves when movement completes or timeout expires Example:

isMoving: boolean

Read-only property indicating if the character is currently moving. Example:

Implementation Details

Movement State Tracking

The service tracks movement state using two internal properties:
  • _isMoving: Boolean flag set when executeMove() is called
  • _movementResolve: Promise resolver called when tileMovementEnd packet received

Packet Flow

  1. Movement Start:
  2. Server Processing:
    • Server validates movement
    • Sends tileMovementStart packet
    • Sends entityTileUpdate packets during movement
    • Sends tileMovementEnd packet when complete
  3. Movement Complete:

Timeout Handling

If movement doesn’t complete within the timeout period:
  • Promise resolves anyway (doesn’t reject)
  • _isMoving flag is cleared
  • Prevents actions from hanging indefinitely

Use Cases

Banking Actions

Banking requires the character to be at the bank before depositing:

Resource Gathering

Approach a resource before gathering:

Combat Positioning

Move into attack range before attacking:

Action Lock Integration

The movement API integrates with the action lock system to prevent LLM ticks during movement:

Fast-Tick Mode

After movement completes, the autonomous behavior manager enters “fast-tick mode” for 2 seconds:
  • Normal tick interval: 10 seconds
  • Fast-tick interval: 2 seconds
  • Triggered by: Movement completion, goal changes
This allows quick follow-up actions without waiting for the full tick interval.

Migration Guide

Before (Broken)

After (Fixed)

This API was added as part of the agent stability improvements (PR #945):
  • Action locks: Skip LLM ticks during movement
  • Fast-tick mode: 2s interval after movement/goal changes
  • Short-circuit LLM: Obvious decisions bypass LLM
  • Banking protocol: Proper sequence with movement awaiting
See docs/agent-stability-improvements.md for full details.

See Also