feat(exec): best-of-N fan-out runs; completion notifications - #241
Merged
Conversation
Two adoptions from Orca (stablyai's ADE for parallel agent fleets),
mapped onto hawk exec.
Best-of-N fan-out (hawk exec --fanout N):
- Runs the same prompt in N (2-5) sequentially-executed isolated git
worktrees, each a fully independent attempt with its own branch
(hawk-exec/<ts>-fanout<i>-<rand>) and session.
- Worktrees are deliberately KEPT after the run so the human can diff
branches and merge the winner; the report prints per-attempt status,
tokens, duration, response tail, compare command (git diff
main...<branch>), and cleanup commands.
- Stream events are captured rather than printed so attempts do not
interleave; attempts default to full autonomy in fanout mode and honor
--auto/--model/--max-turns/--ephemeral as usual. --session-id is
rejected with fanout (attempts are independent by design).
- Structured output via existing --json/--output-format flags.
Completion notifications (internal/notify):
- Best-effort multi-channel sender: generic webhook
(HAWK_NOTIFY_WEBHOOK_URL, POST {event,title,body,ok,...}) and Telegram
Bot API (HAWK_NOTIFY_TELEGRAM_TOKEN/_CHAT_ID). Unconfigured -> silent
no-op; delivery errors never fail the run.
- Fired once per exec/fanout completion (success or failure) - Orca's
'know when your agent finishes' without scraping terminal output.
Verification: notify suite green (6 tests incl. webhook payload contract,
error surfacing, truncation); cmd suite passes; golangci-lint 0 issues
(noctx fixed via NewRequestWithContext); gofmt clean; go build ./... clean.
hawk's emoji audit (internal/testaudit) enforces that dingbat runes route through internal/ui/icons. Replace the literal check/cross marks in the fanout report and notification renderer with icons.Check()/icons.Close(); tests assert against the same helpers so they hold in ASCII-fallback environments.
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.
Summary
Two adoptions from Orca (stablyai's ADE for parallel agent fleets, 51.5k★), mapped onto
hawk exec.1. Best-of-N fan-out —
hawk exec --fanout NOrca's killer pattern: run the same prompt N times, each in its own isolated worktree, compare, merge the winner. Hawk's mission mode decomposes prompts into different features — this is the complementary same-task sampling pattern, verified absent until now.
--fanout 2..5(bounded): sequential attempts (os.Chdir is process-global), each with fresh branchhawk-exec/<ts>-fanout<i>-<rand>+ independent sessiongit diff main...<branch>compare hints, and per-worktree cleanup commands--auto/--model/--max-turns/--ephemeral;--session-idrejected with fanout (attempts independent by design)--json/--output-formatfor structured reports2. Completion notifications —
internal/notifyBest-effort multi-channel sender adopting Orca's "know when your agent finishes":
HAWK_NOTIFY_WEBHOOK_URL) → POST{event:"agent_completion", title, body, ok, branch, finished_at}HAWK_NOTIFY_TELEGRAM_TOKEN/_CHAT_ID)Testing