feat: implement task pause/resume functionality#357
Open
soumojit-D48 wants to merge 1 commit intoGetBindu:mainfrom
Open
feat: implement task pause/resume functionality#357soumojit-D48 wants to merge 1 commit intoGetBindu:mainfrom
soumojit-D48 wants to merge 1 commit intoGetBindu:mainfrom
Conversation
Author
|
hi @raahulrahl, Can You check this PR and Let me know if its helpful or not, Thanks!! |
Member
|
Hey! @soumojit-D48 I tried testing the pause/resume feature locally. When I send a request with It looks like the worker and scheduler base were updated, but I couldn’t find where Am I missing something in the setup, or do those handlers still need to be added? |
pkonal23
added a commit
to pkonal23/Bindu
that referenced
this pull request
Apr 16, 2026
## Summary Implements the Task Pause/Resume feature that was marked as incomplete in PR GetBindu#357. The implementation adds proper state management for pausing and resuming long-running tasks. ## What Changed ### 1. Error Types (types.py) - Added TaskNotPausableError (-32007) - Added TaskNotResumableError (-32008) ### 2. Request/Response Types (types.py) - Added PauseTaskRequest/PauseTaskResponse - Added ResumeTaskRequest/ResumeTaskResponse - CRITICAL: Added these to A2ARequest/A2AResponse discriminated unions ### 3. Settings (settings.py) - Added tasks/pause and tasks/resume to method_handlers - Added "suspended" and "resumed" to non_terminal_states ### 4. TaskManager (task_manager.py) - Added pause_task() and resume_task() router methods ### 5. TaskHandlers (task_handlers.py) - Implemented pause_task() with state validation (only "working" state) - Implemented resume_task() with state validation (only "suspended" state) ### 6. Worker Handlers (workers/base.py) - Implemented _handle_pause() - updates state to "suspended" - Implemented _handle_resume() - updates state to "resumed" and re-queues task ## Testing Created test script (test_pause_resume.py) and slow echo agent (examples/beginner/slow_echo_agent.py) for testing. ### Critical Finding for Testing The agent handler MUST use asyncio.sleep() instead of time.sleep(): - time.sleep() BLOCKS the event loop, preventing pause/resume - asyncio.sleep() YIELDS control, allowing pause/resume to work All 4 test cases pass: ✅ Pause working task → suspended ✅ Pause completed task → TaskNotPausableError ✅ Resume suspended task → resumed (re-queued) ✅ Resume working task → TaskNotResumableError ## Validation Rules - Pause: only allowed in "working" state - Resume: only allowed in "suspended" state ## API Usage // Pause a task {"method": "tasks/pause", "params": {"taskId": "uuid"}} // Resume a task {"method": "tasks/resume", "params": {"taskId": "uuid"}} ## Files Modified - bindu/common/protocol/types.py - bindu/settings.py - bindu/server/task_manager.py - bindu/server/handlers/task_handlers.py - bindu/server/workers/base.py ## Related Issues - Closes GetBindu#383 (the original bug report about unimplemented pause/resume) - Related to GetBindu#356 (feature request) and GetBindu#357 (attempted implementation) Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev>
pkonal23
added a commit
to pkonal23/Bindu
that referenced
this pull request
Apr 16, 2026
## Summary Implements the Task Pause/Resume feature that was marked as incomplete in PR GetBindu#357. The implementation adds proper state management for pausing and resuming long-running tasks. ## What Changed ### 1. Error Types (types.py) - Added TaskNotPausableError (-32007) - Added TaskNotResumableError (-32008) ### 2. Request/Response Types (types.py) - Added PauseTaskRequest/PauseTaskResponse - Added ResumeTaskRequest/ResumeTaskResponse - CRITICAL: Added these to A2ARequest/A2AResponse discriminated unions ### 3. Settings (settings.py) - Added tasks/pause and tasks/resume to method_handlers - Added "suspended" and "resumed" to non_terminal_states ### 4. TaskManager (task_manager.py) - Added pause_task() and resume_task() router methods ### 5. TaskHandlers (task_handlers.py) - Implemented pause_task() with state validation (only "working" state) - Implemented resume_task() with state validation (only "suspended" state) ### 6. Worker Handlers (workers/base.py) - Implemented _handle_pause() - updates state to "suspended" - Implemented _handle_resume() - updates state to "resumed" and re-queues task ## Testing Created test script (test_pause_resume.py) and slow echo agent (examples/beginner/slow_echo_agent.py) for testing. ### Critical Finding for Testing The agent handler MUST use asyncio.sleep() instead of time.sleep(): - time.sleep() BLOCKS the event loop, preventing pause/resume - asyncio.sleep() YIELDS control, allowing pause/resume to work All 4 test cases pass: ✅ Pause working task → suspended ✅ Pause completed task → TaskNotPausableError ✅ Resume suspended task → resumed (re-queued) ✅ Resume working task → TaskNotResumableError ## Validation Rules - Pause: only allowed in "working" state - Resume: only allowed in "suspended" state ## API Usage // Pause a task {"method": "tasks/pause", "params": {"taskId": "uuid"}} // Resume a task {"method": "tasks/resume", "params": {"taskId": "uuid"}} ## Files Modified - bindu/common/protocol/types.py - bindu/settings.py - bindu/server/task_manager.py - bindu/server/handlers/task_handlers.py - bindu/server/workers/base.py ## Related Issues - Closes GetBindu#383 (the original bug report about unimplemented pause/resume) - Related to GetBindu#356 (feature request) and GetBindu#357 (attempted implementation) Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev>
pkonal23
added a commit
to pkonal23/Bindu
that referenced
this pull request
Apr 16, 2026
## Summary Implements the Task Pause/Resume feature that was marked as incomplete in PR GetBindu#357. The implementation adds proper state management for pausing and resuming long-running tasks. ## What Changed ### 1. Error Types (types.py) - Added TaskNotPausableError (-32007) - Added TaskNotResumableError (-32008) ### 2. Request/Response Types (types.py) - Added PauseTaskRequest/PauseTaskResponse - Added ResumeTaskRequest/ResumeTaskResponse - CRITICAL: Added these to A2ARequest/A2AResponse discriminated unions ### 3. Settings (settings.py) - Added tasks/pause and tasks/resume to method_handlers - Added "suspended" and "resumed" to non_terminal_states ### 4. TaskManager (task_manager.py) - Added pause_task() and resume_task() router methods ### 5. TaskHandlers (task_handlers.py) - Implemented pause_task() with state validation (only "working" state) - Implemented resume_task() with state validation (only "suspended" state) ### 6. Worker Handlers (workers/base.py) - Implemented _handle_pause() - updates state to "suspended" - Implemented _handle_resume() - updates state to "resumed" and re-queues task ## Testing Created test script (test_pause_resume.py) and slow echo agent (examples/beginner/slow_echo_agent.py) for testing. ### Critical Finding for Testing The agent handler MUST use asyncio.sleep() instead of time.sleep(): - time.sleep() BLOCKS the event loop, preventing pause/resume - asyncio.sleep() YIELDS control, allowing pause/resume to work All 4 test cases pass: ✅ Pause working task → suspended ✅ Pause completed task → TaskNotPausableError ✅ Resume suspended task → resumed (re-queued) ✅ Resume working task → TaskNotResumableError ## Validation Rules - Pause: only allowed in "working" state - Resume: only allowed in "suspended" state ## API Usage // Pause a task {"method": "tasks/pause", "params": {"taskId": "uuid"}} // Resume a task {"method": "tasks/resume", "params": {"taskId": "uuid"}} ## Files Modified - bindu/common/protocol/types.py - bindu/settings.py - bindu/server/task_manager.py - bindu/server/handlers/task_handlers.py - bindu/server/workers/base.py ## Related Issues - Closes GetBindu#383 (the original bug report about unimplemented pause/resume) - Related to GetBindu#356 (feature request) and GetBindu#357 (attempted implementation) Co-Authored-By: Claude Opus 4.6 <noreply@openclaude.dev>
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
Change Type (select all that apply)
Scope (select all touched areas)
Linked Issue/PR
User-Visible / Behavior Changes
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/AVerification
Environment
Steps to Test
Expected Behavior
Actual Behavior
Evidence (attach at least one)
Human Verification (required)
What you personally verified (not just CI):
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
Risks and Mitigations
Checklist
uv run pytest)uv run pre-commit run --all-files)