Skip to main content
Glama

wait_fn

Wait until a specified JavaScript expression evaluates to true, with an optional timeout and session targeting to synchronize browser automation steps.

Instructions

Wait until a JS expression returns truthy.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exprYesJS expression.
leaseNoOptional lease token to present if the target session is leased (0.7.0). Threaded per-call; never read from the server's env.
sessionNoOptional session name to target (omit for the shared 'default'). On a daemon shared with other agents, pass a UNIQUE name for stateful multi-step work (go→click→fill) so you don't collide on 'default'.
timeout_msNoTimeout in ms.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.4/5.0
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It only states the polling condition, but does not specify timeout behavior (e.g., whether it throws, returns false, or blocks indefinitely), return value, or side effects. This is a critical gap for a blocking operation like a wait.

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

Conciseness5/5

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

The description is a single, direct sentence with no filler or redundancy. It is front-loaded with the core action and condition, and every word contributes to meaning. This is appropriately concise for the tool's simplicity.

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

Completeness2/5

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

With no output schema and no annotations, the description fails to explain return values, timeout semantics, or the session interaction implied by the session parameter. For a tool that can block for up to 30 seconds, missing timeout behavior and return type makes it incomplete for correct invocation.

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

Parameters4/5

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

Schema coverage is 100% for parameters, giving a baseline of 3. The description adds the critical clarification that the expression must 'return truthy', which is not explicit in the schema's 'JS expression' description. This additional semantic depth elevates the score above baseline.

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

Purpose5/5

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

The description 'Wait until a JS expression returns truthy' states a clear verb (wait), resource (JS expression), and condition (returns truthy). It distinguishes itself from sibling wait tools like wait_selector and wait_url by focusing specifically on an arbitrary JS expression, making its purpose unambiguous.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus sibling waits (e.g., wait_selector, wait_url, wait_load). There is no mention of custom conditions or exclusions, leaving the agent to infer that this is for JS expressions, but no explicit when/when-not guidance is given.

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