Skip to content

feat(delegate-task): ⚙️ make sync subagent timeout configurable via syncPollTimeoutMs#2173

Open
Lynricsy wants to merge 1 commit intocode-yeongyu:devfrom
Lynricsy:feat/sync-poll-timeout-config
Open

feat(delegate-task): ⚙️ make sync subagent timeout configurable via syncPollTimeoutMs#2173
Lynricsy wants to merge 1 commit intocode-yeongyu:devfrom
Lynricsy:feat/sync-poll-timeout-config

Conversation

@Lynricsy
Copy link
Contributor

@Lynricsy Lynricsy commented Feb 27, 2026

Summary

The hardcoded 10-minute MAX_POLL_TIME_MS in sync subagent polling is now configurable via background_task.syncPollTimeoutMs in user/project config.

Changes

  • Config schema: Added syncPollTimeoutMs (optional, min 60000ms) to BackgroundTaskConfigSchema
  • Config threading: pluginConfig.background_task.syncPollTimeoutMsDelegateTaskToolOptionsExecutorContextpollSyncSession()
  • 3 polling paths updated: sync-task.ts, sync-continuation.ts, unstable-agent-task.ts — all use timeoutMs ?? DEFAULT_SYNC_POLL_TIMEOUT_MS
  • New constant: DEFAULT_SYNC_POLL_TIMEOUT_MS = 600_000 (backward-compatible default)
  • Tests: 8 new tests (4 schema validation + 4 config threading behavior)

Usage

// .opencode/oh-my-opencode.jsonc
{
  "background_task": {
    "syncPollTimeoutMs": 300000  // 5 minutes instead of default 10
  }
}

Files Changed (14)

File Change
src/config/schema/background-task.ts syncPollTimeoutMs Zod field
src/tools/delegate-task/timing.ts DEFAULT_SYNC_POLL_TIMEOUT_MS constant
src/tools/delegate-task/types.ts DelegateTaskToolOptions.syncPollTimeoutMs
src/tools/delegate-task/executor-types.ts ExecutorContext.syncPollTimeoutMs
src/tools/delegate-task/sync-session-poller.ts timeoutMs? parameter
src/tools/delegate-task/sync-task.ts Config threading
src/tools/delegate-task/sync-continuation.ts Config threading
src/tools/delegate-task/unstable-agent-task.ts Config threading
src/plugin/tool-registry.ts pluginConfig → options
assets/oh-my-opencode.schema.json Auto-generated
src/config/schema/background-task.test.ts New — 4 schema tests
src/tools/delegate-task/sync-poll-timeout.test.ts New — 4 behavior tests
src/tools/delegate-task/sync-session-poller.test.ts Updated timeout test
src/tools/delegate-task/sync-task-deps.ts DI type update

Design Decisions

  • Config in background_task section (consistent with existing messageStalenessTimeoutMs)
  • Only main timeout exposed (not poll intervals or stability checks)
  • Pattern: timeoutMs ?? DEFAULT_SYNC_POLL_TIMEOUT_MS (same as messageStalenessTimeoutMs pattern)
  • Minimum 60 seconds enforced by Zod schema

Summary by cubic

Makes the sync subagent polling timeout configurable via background_task.syncPollTimeoutMs, so teams can adjust the default 10-minute limit across sync flows. Default remains 600,000 ms; minimum is 60,000 ms.

  • New Features
    • Added background_task.syncPollTimeoutMs (optional, min 60s) to config schema.
    • Threaded the config through tool options and executor context into pollSyncSession.
    • Applied the timeout in sync task, sync continuation, and unstable agent paths; falls back to DEFAULT_SYNC_POLL_TIMEOUT_MS.
    • Introduced DEFAULT_SYNC_POLL_TIMEOUT_MS and added tests for schema and timeout behavior.

Written for commit d09cf56. Summary will update on new commits.

…yncPollTimeoutMs

Allow users to set `background_task.syncPollTimeoutMs` in config to override
the default 10-minute sync subagent timeout. Affects sync task, sync continuation,
and unstable agent task paths. Minimum value: 60000ms (1 minute).

Co-authored-by: Wine Fox <fox@ling.plus>
Copilot AI review requested due to automatic review settings February 27, 2026 08:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the hardcoded 10-minute sync subagent polling timeout configurable via the syncPollTimeoutMs field in the background_task configuration section. The change follows the existing pattern established by other timeout configurations like messageStalenessTimeoutMs.

Changes:

  • Added syncPollTimeoutMs configuration field to BackgroundTaskConfigSchema with 60-second minimum
  • Introduced DEFAULT_SYNC_POLL_TIMEOUT_MS constant (600,000ms = 10 minutes) for backward compatibility
  • Threaded the configuration through the delegate-task tool chain: plugin config → tool options → executor context → polling functions
  • Updated all three synchronous polling code paths to use the configurable timeout with the default fallback pattern

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/config/schema/background-task.ts Added syncPollTimeoutMs field to schema with 60-second minimum
src/config/schema/background-task.test.ts Added 4 validation tests for the new schema field
src/tools/delegate-task/timing.ts Added DEFAULT_SYNC_POLL_TIMEOUT_MS constant (600,000ms)
src/tools/delegate-task/types.ts Added syncPollTimeoutMs optional property to DelegateTaskToolOptions
src/tools/delegate-task/executor-types.ts Added syncPollTimeoutMs optional property to ExecutorContext
src/plugin/tool-registry.ts Threaded pluginConfig.background_task.syncPollTimeoutMs to delegate-task options
src/tools/delegate-task/sync-session-poller.ts Updated pollSyncSession to accept optional timeoutMs parameter and use fallback pattern
src/tools/delegate-task/sync-task.ts Passed syncPollTimeoutMs from executor context to pollSyncSession
src/tools/delegate-task/sync-continuation.ts Passed syncPollTimeoutMs from executor context to pollSyncSession
src/tools/delegate-task/unstable-agent-task.ts Replaced hardcoded MAX_POLL_TIME_MS with configurable timeout using fallback pattern
src/tools/delegate-task/sync-session-poller.test.ts Updated timeout test to pass explicit 0 value
src/tools/delegate-task/sync-poll-timeout.test.ts Added 4 behavior tests verifying timeout threading and fallback logic
src/tools/delegate-task/tools.test.ts Enhanced mock client to support multiple polling calls for variant preservation test
assets/oh-my-opencode.schema.json Auto-generated JSON schema update

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -8,6 +8,7 @@ export const BackgroundTaskConfigSchema = z.object({
staleTimeoutMs: z.number().min(60000).optional(),
/** Timeout for tasks that never received any progress update, falling back to startedAt (default: 600000 = 10 minutes, minimum: 60000 = 1 minute) */
messageStalenessTimeoutMs: z.number().min(60000).optional(),
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing JSDoc comment for the syncPollTimeoutMs field. The other timeout fields in this schema (lines 7-10) include descriptive JSDoc comments explaining their purpose, default values, and minimums. For consistency and documentation completeness, this field should have a similar comment explaining that it controls the timeout for synchronous subagent polling operations.

Suggested change
messageStalenessTimeoutMs: z.number().min(60000).optional(),
messageStalenessTimeoutMs: z.number().min(60000).optional(),
/** Timeout in milliseconds for synchronous subagent polling operations (minimum: 60000 = 1 minute) */
Copilot uses AI. Check for mistakes.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 14 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: The PR safely makes a hardcoded 10-minute timeout configurable with backward-compatible defaults, includes validation, and adds comprehensive tests without changing existing behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants