moeru-ai/airi · warning · Error
Expectation failed: Expected distance <= ${maxDist}, got ${d
Error message
Expectation failed: Expected distance <= ${maxDist}, got ${distance} What it means
The final failing branch of globalThis.expectNear: a distance WAS computed (either from endPos vs target, or from distanceToTargetAfter) but it exceeds maxDist (default 2). The throw message reports both the threshold and the measured distance. This is the genuine proximity-failure case, distinct from the missing-telemetry cases.
Source
Thrown at integrations/minecraft/src/cognitive/conscious/js-planner.ts:1299
}
const dx = endPos.x - target.x
const dy = endPos.y - target.y
const dz = endPos.z - target.z
distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
}
else if (typeof globalThis.lastAction?.result?.distanceToTargetAfter === 'number') {
distance = globalThis.lastAction.result.distanceToTargetAfter
}
if (distance === null) {
throw new Error('Expectation failed: expectNear() requires target argument or last action distanceToTargetAfter telemetry')
}
if (distance <= maxDist)
return true
throw new Error(
'Expectation failed: ' + __plannerExpectationDetail(message, 'Expected distance <= ' + maxDist + ', got ' + distance),
)
}
globalThis.use = (toolName, params = {}) => {
if (typeof toolName !== 'string' || toolName.length === 0)
throw new Error('use(toolName, params) requires a non-empty string toolName')
const invocationArgs = params && typeof params === 'object' && !Array.isArray(params) ? [params] : [{}]
const runtimeResult = __plannerCallBridge('tool', [toolName, invocationArgs])
globalThis.lastAction = runtimeResult
globalThis.lastRun.actions.push(runtimeResult)
return runtimeResult
}
globalThis.skip = () => globalThis.use('skip', {})
for (const toolName of __plannerActionNames) {View on GitHub (pinned to 27111382b4)
Solutions
- Increase maxDist to match the movement action's realistic stopping radius.
- Issue a follow-up moveTo to close the remaining gap before asserting.
- Use a movement action whose goal radius is tighter than the expectNear tolerance.
- Re-read the target position immediately before moving in case it moved.
Example fix
// before
// await use('moveTo', { x: 10, y: 64, z: -5 })
// expectNear({ x: 10, y: 64, z: -5 }, 1) // throws: got 1.8
//
// after
// await use('moveTo', { x: 10, y: 64, z: -5 })
// expectNear({ x: 10, y: 64, z: -5 }, 2.5) Defensive patterns
Strategy: validation
Validate before calling
// Before asserting, check the computed distance against your tolerance:
// const end = globalThis.lastAction?.result?.endPos
// if (end) {
// const d = Math.hypot(end.x - target.x, end.y - target.y, end.z - target.z)
// if (d > maxDist) await use('moveTo', target) // close the gap first
// }
// expectNear(target, maxDist) Prevention
- Set maxDist at least as large as the movement action's goal radius.
- Issue a follow-up moveTo to close residual distance before expectNear.
- Re-read the target coordinates immediately before moving (it may have moved).
- Account for knockback/obstacles by tolerating a larger radius.
When it happens
Trigger: A movement action completed but the bot ended farther than maxDist from the target; pathfinder stopped short due to an obstacle; the bot was pushed/knocked back after arriving; maxDist set too tight for the action's stopping radius; goal rangeGoal larger than the expectNear tolerance.
Common situations: pathfinder GoalNear range larger than expectNear maxDist; terrain/liquid blocking the last block; bot attacked and knocked away; target is itself moving; coordinates stale relative to the live world.
Related errors
- Expectation failed: expectNear(target) requires last action
- Expectation failed: expectNear() requires target argument or
- Expectation failed: Condition evaluated to false
- Expectation failed: Expected movedDistance >= ${threshold},
- Your last reply was natural language, not JavaScript, so not
AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12).
Data as JSON: /api/errors/c7d938b57e368d90.
Report an issue: GitHub.