feat: add automatic worker triggering on task creation#11
Merged
Conversation
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>
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
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
WORKER_NODE_IDenvironment variable (default:nd-worker) to specify which worker agent to triggercreate_taskandcreate_issue_taskreasoners to callapp.call(f"{config.worker_node_id}.claim_task")immediately after successful task creationTesting
tests/unit/test_task_trigger.py) with 4 test cases:Documentation
README.mdwithWORKER_NODE_IDconfigurationCLAUDE.mdto reflect automatic triggering behaviorBenefits
Technical Details
Flow:
Multiple Workers:
Each worker instance's
claim_taskwill attempt to claim available tasks. Kata's assignment mechanism handles the race condition, ensuring only one worker claims each task.Test Results
🤖 Generated with Claude Code