Skip to main content
Glama

java_wait_for

Read-only

Wait for a Java window to appear or an element's text to equal or change from a value, returning whether the condition was met, elapsed time, and observed state.

Instructions

Wait for something to happen, instead of asking too early and being told no.

Three conditions, chosen by what you pass:

  • window_title="A Dialog" — wait until a Java window with that title (fnmatch, so "*Progress*" works) exists. Use it after an action that opens one.

  • handle=..., text_equals="Saved" — wait until that element's text is this.

  • handle=... alone — wait until its text changes from what it reads when the wait starts, and report both values.

A timeout is a result, not an error. The reply says the condition was not met and what was seen instead, because "not yet" is information an agent can act on — it can wait longer, look somewhere else, or take a snapshot — while an error reads as a failed call. pyjab's own waits raise; this one reports, and the difference is deliberate for a tool a model is driving.

The waiting happens here rather than inside pyjab, and that is also deliberate: the bridge has exactly one owning thread, so a wait that ran on it would block every other call for its whole duration. This polls between calls instead, which also means a client can cancel it.

Args: session_id: From java_attach_window. window_title: Title (fnmatch) of a window to wait for. handle: An element whose text to watch. text_equals: The text to wait for, with a handle. timeout: Give up after this many seconds. poll_interval: Seconds between checks. A window wait re-lists the Java windows on every poll; on an install below the pin that listing is the pyjab-inspect subprocess rather than a bridge call, so raise this.

Returns: Whether the condition was met, how long it took, and what was seen.

Errors: is_error only for an unknown session or handle, or for no condition at all. A timeout is reported in the reply, not as an error.

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": {
      "session_id": "<session_id>"
    },
    "name": "java_wait_for"
  }
}

Input Schema

NameRequiredDescriptionDefault
handleNo
timeoutNo
session_idYes
text_equalsNo
window_titleNo
poll_intervalNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only supply readOnlyHint and openWorldHint; the description goes far beyond them, disclosing that timeouts are reported results not errors, that polling avoids blocking the single-owner bridge thread, that the wait is client-cancellable, and that window listing may spawn a pyjab-inspect subprocess on older installs. It also enumerates the exact error conditions (unknown session or handle, no condition supplied).

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 well — the three condition modes come first, before any design rationale. The middle paragraphs on delibarate design trade-offs are informative but amount to justification prose that could be trimmed without losing agent-relevant guidance.

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

Completeness4/5

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

For a blocking tool with six params, an output schema, and a subtle timeout-vs-error contract, this covers behavior, errors, and return shape thoroughly. Minor gap: polling cadence limits or maximum practical timeout values are not bounded, though poll_interval guidance partly compensates.

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries the full burden, and its Args block defines every one of the six parameters: session_id's origin, window_title's fnmatch semantics with an example, handle/text_equals pairing, timeout units, and non-obvious poll_interval guidance tied to the subprocess cost. This is meaning the bare schema cannot supply.

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?

States a specific verb ('wait for') and enumerates the three selectable conditions — window title exists, element text equals, element text changes — each keyed to concrete argument shapes. This clearly separates it from one-shot readers like java_get_text or java_snapshot, which return current state rather than blocking for a transition.

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

Usage Guidelines5/5

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

Gives explicit when-to-use guidance per condition ('Use it after an action that opens one'), and explains what the agent can do instead when the condition is unmet (wait longer, look elsewhere, take a snapshot). The relationship to siblings is implied correctly without needing names.

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