Skip to content

Conversation

@randomm
Copy link
Owner

@randomm randomm commented Feb 12, 2026

Summary

Adds sync mode to the task tool, allowing synchronous task execution that returns results directly instead of using the event bus.

Changes

  • Added sync: boolean parameter to task tool (default: false)
  • Sync mode executes task synchronously and returns result directly
  • Both modes share timeout (10min), task slots (max 5), and abort signals
  • Updated task.txt documentation with execution modes section
  • Updated .fork-features/manifest.json with sync criticalCode markers
  • Added tests for sync parameter validation

Security Fixes (from adversarial review)

  • Added timeout enforcement to sync mode (Promise.race with 10min timeout)
  • Added abort signal checks to prevent race conditions
  • Moved event unsubscriber to finally block to prevent memory leaks
  • Proper slot release in all code paths (success/error/abort)

Testing

  • All existing tests pass (1074 tests)
  • Typecheck passes (0 errors)
  • New test: packages/opencode/test/tool/task.test.ts

Fixes #182

@randomm
Copy link
Owner Author

randomm commented Feb 12, 2026

Critical Documentation Issues Found in task.txt

I'm requesting changes to fix several problems in the documentation file:

Issues in task.txt

  1. Line 21: Contains Chinese characters "并发" mixed with English:

    "Launch multiple agents并发 agents whenever possible"
    
  2. Line 34: Conflicting/contradictory description:

    - `sync`: (Optional, default: `false`) Run task synchronously and wait for result. Default: true) returns status "started" and result is delivered later;
    

    This says both "default: false" and "Default: true)" which is contradictory.

  3. Lines 46-48: Garbled/syntax errors in JSON examples:

    - `{ task_id, status: "completed", result: "..." }` - Task completed successfully, text return is returned.
    - `{ task_id: "started", "failed", message: "Task \`timeout...}\` `awaited: "Task timed out: \`new Error(new: TimeoutExceeded())`)
      *   \`}`
    
  4. Lines 53-57: Duplicate content - these lines repeat lines 22-26 from earlier in the file.

Test Coverage Concern

The test only validates the Zod schema but does not test:

  • Sync execution flow
  • Timeout behavior
  • Error handling in both modes
  • Abort handling in sync mode
  • Slot release verification
  • Event unsubscription

Consider adding more comprehensive tests for the sync mode implementation.

@randomm randomm merged commit f760729 into dev Feb 12, 2026
1 check passed
@randomm randomm deleted the feature/182-sync-mode-task-tool branch February 12, 2026 07:59
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.

feat: add sync mode to task tool (blocking execution alongside async default)

1 participant