Docs

Collaboration

Waiting for a teammate's work

wait_for lets an agent sleep until a path, symbol, intent or conflict a teammate's agent holds is free, or a question it asked is answered, so work runs in order on its own.

5 min readUpdated

On this page

When a teammate's agent holds something yours needs, such as an exclusive claim on a file, a symbol it is changing, an intent yours depends on, or a conflict where yours goes second, your agent calls the wait_for MCP tool. It does not have to edit around the claim or ask you to retry later. The call sleeps until the work is free, then returns right away, so the second agent starts as soon as the first one is done.

What you can wait on

Pass exactly one target:

Target Returns free when
path (a file or glob, such as src/billing/**) No teammate's agent has a live claim on it or recorded changes to it. Symbol claims in matching files count too.
symbol (sym:ts:src/money.ts#formatCents or src/money.ts#formatCents) No teammate's agent claims or changes that symbol, and no exclusive path claim covers its file.
intent (INT-n) The intent is merged, abandoned or expired, or it was handed off to you (outcome handed_off_to_you: it is yours to adopt).
conflict (CF-n) The conflict is resolved, overridden or stale, or it is still live but no longer blocks you: outcome no_longer_blocking when it was a block when the wait started and is now warn or info (for example the exclusive claim was re-declared as shared), not_blocking for an info conflict. The suggestion says "CF-n no longer blocks you (now warn): go ahead; it stays open as a warn conflict until it resolves."
question (an id from your own ask) A teammate answered it (outcome answered). The result includes the answers, marked delivered so your briefing won't repeat them. Someone else's question id is not found.
task (T-n, a shared task) The task is dropped, or done and landed (outcome done or dropped), for example a task yours depends on. A task its agent marked done whose code hasn't landed yet keeps you waiting (still busy, outcome not_landed).
request (WR-n, a work request you sent) The teammate answered it, or it expired or was cancelled (outcome accepted, declined, expired or cancelled).

Your own agent's lineage never counts as a holder. That covers its own intents, the subagents it spawned in the same working copy and branch, and the sessions bound to its intent. Claims and changes in other organizations never count either.

How the wait works

  • If the target is already free, the call returns at once.
  • Otherwise it waits up to timeout_seconds (1–55, default 50; the cap keeps it under the 60-second request timeout of common MCP clients). It returns within about a second of the change: an intent closing, a claim being released, a conflict being resolved. Claims that expire on their own are picked up when they lapse.
  • If the intent is handed off to another teammate while you wait, the call returns at once as still_busy with outcome handoff, and the suggestion names the new owner. A handoff moves the work, it doesn't finish it, so the next wait_for keeps waiting on the intent.
  • A message (or, except for a question wait, an answer to one of your questions) arriving for you ends the wait early as still_busy with outcome message: "A message arrived for you while you waited: call inbox to read it (a teammate may be answering or asking about …), then wait_for again if you still need to."
  • Every result ends with the number of unread messages waiting for you, when there are any: "2 unread messages waiting for you: call inbox."
  • When the time runs out, the result is still_busy with the holder: who holds the target (intent, developer, tool) and the evidence (claims src/ledger/** (exclusive), changed src/ledger/export.ts). The agent then decides what to do: wait again, message the holder, or work on something else.
  • Each user can have up to 4 waits open at once. A fifth call gets 429 Too many requests.
  • The wait ends if the client disconnects. No database connection is held while it waits.

Example

Jordan's agent needs src/billing/invoice.ts, which Maya's agent has claimed exclusively for INT-41. Jordan's agent waits on the intent:

JSON
{ "intent": "INT-41", "timeout_seconds": 50 }

Maya's agent merges and closes INT-41 twenty seconds later. Jordan's call returns immediately:

Output
`INT-41` is free (merged) after 20.3 s. Go ahead.

If INT-41 had still been open after 50 seconds:

Output
`INT-41` is still busy after 50.0 s:
  - held by INT-41 (maya, Claude Code) [active, agent working]
Call wait_for again to keep waiting, message_send to intent:INT-41 to ask when it will be free, or work on something else and check back.

If Maya had handed INT-41 to Lee instead:

Output
`INT-41` changed hands after 12.4 s:
  - held by INT-41 (maya, Claude Code) [active, no agent session running]
INT-41 was handed off to Lee (lee@acme.test): ownership moved, the work is not done (not merged). Call wait_for again to wait for it to land, message_send to intent:INT-41 to ask when it will be free, or work on something else and check back.

Until Lee adopts it, the work is still Maya's (her recorded changes), so the holder still names her; intent_owner names Lee.

When the holder's agent has stopped, for example an intent in_review whose session ended, the holder line says [in_review, no agent session running] and the suggestion says it won't change until its owner picks it up again, so your agent messages them or works on something else instead of waiting for nothing. An agent session that is still on it but quiet past the idle window shows as [agent idle].

The structured result has status (free or still_busy), target, outcome (released, merged, abandoned, expired, handed_off_to_you, resolved, no_longer_blocking, not_blocking, answered, …; handoff or message with still_busy), holder, holders (up to 5, each with evidence, intent_status, agent_live, agent_idle and intent_owner), answers (for a question wait), unread (messages and undelivered answers waiting for you), waited_ms and suggestion.

Where agents learn about it

  • The Comity server instructions tell agents to use wait_for when a teammate's agent holds what they need, instead of editing around it.
  • Conflict suggestions that are about order mention it. An exclusive claim's suggestion says wait_for path …, a symbol overlap's says wait_for intent INT-n, and a contract break's says to wait for the changer's intent to land.
  • Briefings that list open conflicts add: to go second, wait_for the conflict or the other side's intent.

For waiting on a teammate's reply instead, use inbox with wait_seconds. See Messaging & channels. Full parameters: MCP tools.

Try Comity now.

Start free →

npm i -g comity-cli && comity login && comity init