Skip to content

feat: add automatic worker triggering on task creation#11

Merged
andyxhadji merged 2 commits into
mainfrom
moored-dinner
May 30, 2026
Merged

feat: add automatic worker triggering on task creation#11
andyxhadji merged 2 commits into
mainfrom
moored-dinner

Conversation

@andyxhadji
Copy link
Copy Markdown
Owner

Summary

Implements automatic triggering of the worker agent when the triage agent creates kata tasks, eliminating the need for manual invocation or cron polling. This enables true event-driven task processing.

Changes

Core Implementation

  • Config: Added WORKER_NODE_ID environment variable (default: nd-worker) to specify which worker agent to trigger
  • Triage Agent: Modified create_task and create_issue_task reasoners to call app.call(f"{config.worker_node_id}.claim_task") immediately after successful task creation
  • Error Handling: Graceful handling ensures task creation succeeds even if worker trigger fails (logs warning but continues)
  • Deduplication: Only triggers on successful task creation, not on duplicate tasks

Testing

  • Added comprehensive unit tests (tests/unit/test_task_trigger.py) with 4 test cases:
    • Verify MR task creation triggers worker
    • Verify issue task creation triggers worker
    • Ensure graceful handling of worker unavailability
    • Verify no trigger on duplicate tasks
  • All 148 unit tests pass

Documentation

  • Updated README.md with WORKER_NODE_ID configuration
  • Updated CLAUDE.md to reflect automatic triggering behavior

Benefits

  • No manual triggering - Workers automatically process tasks as they're created
  • More efficient - Direct trigger vs. periodic cron polling
  • Scalable - Multiple workers can compete for tasks (kata handles race conditions)
  • Resilient - Task creation succeeds even if worker is temporarily unavailable
  • Event-driven - True reactive architecture instead of polling-based

Technical Details

Flow:

1. Triage polls middleman for new comments/issues
2. Classifies as actionable
3. Creates kata task
4. → Immediately triggers worker.claim_task via app.call()
5. Worker claims and processes the task

Multiple Workers:
Each worker instance's claim_task will attempt to claim available tasks. Kata's assignment mechanism handles the race condition, ensuring only one worker claims each task.

Test Results

================================ 148 passed ================================

🤖 Generated with Claude Code

fh-ahadjigeorgiou and others added 2 commits May 30, 2026 10:34
Previously, the worker's claim_task reasoner required manual invocation or cron polling. This change makes the triage agent automatically trigger the worker via app.call() immediately after creating a kata task, enabling true event-driven task processing.

Changes:
- Add WORKER_NODE_ID config (default: nd-worker) to specify which worker to trigger
- Modify create_task and create_issue_task to call worker's claim_task after successful task creation
- Graceful error handling: task creation succeeds even if worker trigger fails
- Only triggers on successful creation (not on duplicates)
- Add comprehensive unit tests for trigger behavior

Benefits:
- No manual triggering needed
- More efficient than cron polling
- Multiple workers can compete for tasks (kata handles race conditions)
- Resilient to temporary worker unavailability

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removed unused import to pass ruff linting checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@andyxhadji andyxhadji merged commit c340d2b into main May 30, 2026
4 checks passed
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.

2 participants