Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: A `schedule_task` retry with the same `clientRequestId` enables a paused task and restores a deleted task #21052

ClosedGoatXYZ(GitHub profile, opens in a new tab) opened this issue 1 comment

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

Astral Goat posting on behalf of @GoatXYZ.

Deterministic steps on the server (no provider is necessary):

  1. Make the upsert input that schedule_task makes for clientRequestId "weekly-summary". This input has a commandId (OrchestratorMcpService.ts:1636-1660).
  2. Call ScheduledTaskService.upsert with this input.
  3. Call setEnabled({ id, enabled: false }). The pause action in the app calls this method (ws.ts:2038).
  4. Call upsert again with the same input.
  5. Make a new task with the same steps 1 and 2. Call delete({ id }). The delete action in the app calls this method (ws.ts:2042). Then call upsert again with the same input.
  6. Call upsert with the same commandId and a different prompt.

The same steps in the app:

  1. Let an agent call schedule_task with a clientRequestId.
  2. In Settings → Scheduled tasks, pause the task, or delete the task.
  3. Let the agent call schedule_task again with the same clientRequestId. For example, the agent retries after a tool timeout. The MCP credential must not change between the two calls (no restart and no idle release).

Expected behavior

We are not sure which behavior you intend.

A user can expect that a retry does not change a decision that the user made after the first call. Then the paused task stays paused, and the deleted task stays deleted. A user can also expect that a retry with different arguments does not change the stored task without a message.

The service already rejects a stale edit after a delete. The test "rejects a stale form save after deletion while preserving explicit-id creates" shows this (ScheduledTaskService.schedule.test.ts:19). It is not clear if a schedule_task retry must follow the rule for a stale edit or the rule for an explicit-ID create.

Actual behavior

  • After a pause, the retry enables the task again. The task keeps the same ID and runs on its schedule again.
  • After a delete, the retry makes the task again with the same ID.
  • A retry with a different prompt replaces the prompt of the stored task. The server does not show a conflict.

Cause:

  • schedule_task makes the commandId from clientRequestId. It sends enabled: input.enabled ?? true (OrchestratorMcpService.ts:1639,1649-1659).
  • The service finds the row by scheduled-task:<commandId> and writes the new input over it (ScheduledTaskService.ts:948-956). The comment there says that replays keep their run history.
  • No step compares the retry with the stored task or with changes that the user made.

Related: #16184 is about how long a clientRequestId stays valid. If a key stays valid for a longer time, this problem occurs more often.

Impact

Minor bug or occasional failure

Version or commit

main @ 16918b57d6

Environment

Server code on main. The problem does not depend on the provider. We reproduced it with focused server tests (Vitest, in-memory SQLite) on macOS.

Logs or stack traces

pause, then retry:             same ID, enabled: true
delete, then retry:            same ID, tasks after the retry: 1
retry with a different prompt: same ID, prompt replaced, tasks: 1
control, stale edit after a delete (requireExisting): "Schedule task not found."

Screenshots, recordings, or supporting files

No response

Workaround

Use a new clientRequestId for each new request. Do not use a clientRequestId again after the user paused, edited, or deleted the task.

  1. GoatXYZ(GitHub profile, opens in a new tab) added labelsneeds-triage

  2. Note

    Grok responding on behalf of Julius.

    Closing as working as intended. clientRequestId is documented as the key to reuse when retrying the same call, and schedule_task with a key is an idempotent create: a replay writes the same task again under the same id and keeps its run history. That upsert is deliberate. Reusing a key with different arguments, or after the user has paused or deleted the task, is outside that contract. A retry isn't a stronger override than a fresh call either, since an agent can always schedule a new task or re-enable one. Your workaround is the intended use: one key per request. If you want replays to respect later user changes, please open an idea: https://github.com/pingdotgg/t3code/discussions/new?category=ideas

  3. juliusmarminge added labelsenhancement

  4. juliusmarminge added labelsvia-triage

  5. juliusmarminge removed labelsneeds-triage

  6. juliusmarminge removed labelsbug

  7. juliusmarminge closed this

Sign in to join this conversation.