Skip to main content
Glama

Wait for a Lua condition

wait_for
Read-only

Wait for a Lua condition to become true in a chosen realm, polling each frame or at a set interval until it succeeds or times out. Returns status, elapsed time, polls, and last value.

Instructions

Waits until a Lua condition is true. condition is an expression ("IsValid(Entity(57))") or a block with return ("local d = Entity(57) return IsValid(d) and d:GetInternalVariable('m_eDoorState') == 2"), compiled once and evaluated in realm every frame (or every interval_s); true = anything but nil/false. Each evaluation may run 1 s at most. Result: {satisfied: true, elapsed_s, polls, value (the last value)}. Errors: timeout (details: polls, last_value), realm_lost (the realm was destroyed or recreated, e.g. a map change, during the wait), realm_unavailable, lua_syntax_error, lua_error. Reports progress; can run as an MCP task.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "condition": "<condition>"
    },
    "name": "wait_for"
  }
}

Input Schema

NameRequiredDescriptionDefault
realmNoEvaluation realm (default server).
instanceNoOptional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance.
conditionYesLua expression or block with return, e.g. 'IsValid(Entity(1)) and Entity(1):Alive()'.
timeout_sNoMax wait in seconds (default 10).
interval_sNoSeconds between evaluations (default 0 = every frame).

Output Schema

NameRequiredDescriptionDefault
nextNo
noteNo
pollsYes
valueNo
warningNo
elapsed_sYes
next_callNo
satisfiedYes
answered_byNo
truncated_noteNo
version_warningNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.7

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well past the readOnlyHint/openWorldHint annotations: it discloses that the condition is compiled once, evaluated every frame or every interval_s, that each evaluation may run up to 1 s, and it enumerates concrete failure modes (timeout with polls/last_value, realm_lost on map change, lua_syntax_error, lua_error). That is genuinely useful operational context. Minor gap: no explicit statement of resource cost or guidance on choosing interval_s to avoid frame-time impact.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core verb phrase, then progressively more detail; every clause (compilation, cadence, 1 s cap, result shape, error list) carries information. It is dense and parenthetical-heavy, which slightly hurts scannability, but there is little outright waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a blocking, condition-evaluating tool with a full schema and an output schema, the description supplies the evaluation model, timeout/interval semantics, return shape, and the full error taxonomy. An agent has what it needs to call it correctly and to interpret failures.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents all five parameters; baseline is 3. The description adds real semantic value for `condition` (true = anything but nil/false, block-with-return form, compilation behavior) and clarifies interval default behavior, but realm/instance/timeout_s get no elaboration beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Waits until a Lua condition is true,' then disambiguates the mechanism (expression or block, compiled once, evaluated per frame in a named realm). That mechanism makes it distinguishable in practice from console/events/frame waiting siblings, though no sibling is named explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the mechanism rather than stated: you use it when you need to block on a Lua predicate, and the realm/interval parameters reveal the context. There is no explicit when-to-use/when-not sentence and no routing to alternatives such as console_wait, events_wait, or wait_frames.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.