Fix: Add --async flag to 'work notify send' for autonomous agent workflows (#1362)#1499
Conversation
Comprehensive investigation of GitHub adapter only fetching first 100 issues. Root Cause: api-client.ts listIssues() method lacks pagination loop, returns only first page of GitHub API results (max 100 per page). Evidence: For tbrandenburg/work repo with 1,295 issues, only 100 are accessible via 'work list'. Older issues like #852, #674, #664 cannot be discovered but can be fetched individually with 'work get'. Solution: Add pagination loop with maxPages safety limit (default 20 pages = 2,000 issues). Uses page counter approach, stops when page returns <100 results. Affected Files: - src/adapters/github/api-client.ts:41-55 - Add pagination loop - src/adapters/github/index.ts:186-206 - Pass maxPages parameter - tests/unit/adapters/github/api-client.test.ts - Add pagination tests Pattern: Follows existing error handling pattern from getIssue() method. Decision: Simple page counter over Octokit iterator for clarity. Severity: HIGH - 92% of issues inaccessible in large repos. Complexity: MEDIUM - 2 files, moderate integration risk. Artifact: .claude/PRPs/issues/issue-1361.md
…flows (#1362) The 'work notify send' command always blocks waiting for agent completion (with 5-minute default timeout), then kills the process. This prevents autonomous agent workflows where agents should work independently for hours/days after receiving notifications. Changes: - Added --async flag to 'work notify send' CLI command - Updated engine to handle async mode (fire-and-forget) - Extended TargetHandler interface to accept options parameter - Implemented async mode in ACP handler (skip await, keep process alive) - Updated bash and telegram handlers to accept options parameter - Added tests for async mode behavior - Updated example script to use --async flag Fixes #1362
- Add error catch handler to prevent unhandled promise rejections - Only cleanup process on error if NOT in async mode - Ensures async processes can continue working after initialization errors
🔍 Automated Code ReviewSummaryThe implementation successfully addresses the root cause (blocking await + process cleanup preventing autonomous workflows) and follows the established architecture. Two critical bugs were identified during review and have been fixed in commit Findings✅ Strengths
|
📝 Note on CI Test FailureDuring CI runs, you may see a failure in Investigation Summary
Root CauseTest ordering dependency - likely due to:
TrackingCreated issue #1550 to track and fix the flaky test. This is a test infrastructure issue, not a bug in the async notification feature. The async notification implementation is solid and all related tests pass. |
Summary
The
work notify sendcommand always blocks waiting for agent completion (with 5-minute default timeout), then kills the process. This prevents autonomous agent workflows where agents should work independently for hours/days after receiving notifications. The feature is documented in README.md for cron-based agent orchestration but not implemented.Root Cause
The ACP handler synchronously waits for AI response (lines 83-88 in acp-handler.ts) and kills the process after response. This is incompatible with fire-and-forget agent orchestration pattern where agents should work autonomously after receiving notifications.
Changes
src/cli/commands/notify/send.ts--asyncflag and passed to enginesrc/core/engine.tssrc/core/notification-service.tssrc/core/target-handlers/acp-handler.tssrc/core/target-handlers/bash-handler.tssrc/core/target-handlers/telegram-handler.tstests/unit/core/notification-service.test.tsTesting
Validation
Issue
Fixes #1362
📋 Implementation Details
Implementation followed artifact:
.claude/PRPs/issues/issue-1362.mdKey Design Decisions:
--asyncis opt-inDeviations from plan:
voidoperator for floating promise to satisfy ESLint rulesAutomated implementation from investigation artifact