Skip to content

feat(tool): add bounded wait tool#24889

Draft
Marxist-Leninist wants to merge 1 commit intoanomalyco:devfrom
Marxist-Leninist:upstream/feat/wait-tool
Draft

feat(tool): add bounded wait tool#24889
Marxist-Leninist wants to merge 1 commit intoanomalyco:devfrom
Marxist-Leninist:upstream/feat/wait-tool

Conversation

@Marxist-Leninist
Copy link
Copy Markdown

@Marxist-Leninist Marxist-Leninist commented Apr 29, 2026

Issue for this PR

Closes #24888

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a built-in wait tool for bounded asynchronous waits inside the current assistant turn.

The tool supports a fixed delay plus several early-return conditions: file readiness, URL readiness, process exit, and a regex pattern appearing in a log file. It reports progress through tool metadata so the UI can show what the agent is waiting on, and it respects the abort signal so the user can cancel the wait.

This avoids asking users to manually come back later for common long-running workflows such as downloads, dev-server startup, background build/test jobs, and short rate-limit cooldowns.

How did you verify your code works?

  • Focused wait-tool tests were run when the branch was prepared: bun test test/tool/wait.test.ts --timeout 30000.
  • git diff --check origin/dev..b928668d5bd6154eb7f20c78b83378b6398a5a3e.
  • Changed files scrubbed for private fork strings/secrets with git grep.

This is still a draft PR so project CI remains the authority before it is marked ready.

Screenshots / recordings

No screenshot. The TUI display renders the wait tool as a compact Waiting... tool part with mode-specific progress text.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Adds a new `wait` builtin tool the agent can use to pause the current
turn for a bounded duration without spawning a bash slot or asking the
user to nudge it back. Five mutually-exclusive modes share a `seconds`
cap (1s..1h) and a required `reason` string shown in the UI:

* Fixed delay — sleep `seconds`, then continue. Use for cooldowns.
* until_file — poll a path; return when its size has been stable for
  `stable_ms` (default 10s, settable to 0). Optional `min_size_bytes`
  guard. Live progress in the title ("driver.exe 423.4 MB / 800.0 MB").
* until_url — HEAD then GET, return on `until_url_status` (default 200).
* until_pid_exit — return when a PID is gone.
* until_text — tail a file, return on regex match (`until_text_pattern`,
  optional `text_pattern_flags` and `text_tail_bytes`).

Optional knobs in every mode: `poll_interval_ms` (100..60000),
`cancel_if_file` (soft cancel sentinel — different from user abort,
completes the tool normally so the chat stays alive).

Also wires the tool through the registry, agent permission list, and
the TUI ToolPart switch so it renders as "Waiting..." with a contextual
suffix (label, basename, pattern, status, pid) instead of the generic
spinner.

This is upstream-portable code lifted from a private fork; the public
PR description here is what reviewers should see.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 29, 2026
@Marxist-Leninist
Copy link
Copy Markdown
Author

Updated the PR body to keep the template checklist complete while preserving the draft/CI caveat.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: add a bounded wait tool for asynchronous work

1 participant