feat(tool): add bounded wait tool#24889
Draft
Marxist-Leninist wants to merge 1 commit intoanomalyco:devfrom
Draft
feat(tool): add bounded wait tool#24889Marxist-Leninist wants to merge 1 commit intoanomalyco:devfrom
Marxist-Leninist wants to merge 1 commit intoanomalyco:devfrom
Conversation
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.
Author
|
Updated the PR body to keep the template checklist complete while preserving the draft/CI caveat. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #24888
Type of change
What does this PR do?
Adds a built-in
waittool 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?
bun test test/tool/wait.test.ts --timeout 30000.git diff --check origin/dev..b928668d5bd6154eb7f20c78b83378b6398a5a3e.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