Skip to content

fix(taskruntime): prevent duplicate stream replay - #60

Merged
jasonchen922 merged 2 commits into
mainfrom
users/jasonchen922/sync-taskruntime-stream-replay
Jul 28, 2026
Merged

fix(taskruntime): prevent duplicate stream replay#60
jasonchen922 merged 2 commits into
mainfrom
users/jasonchen922/sync-taskruntime-stream-replay

Conversation

@jasonchen922

Copy link
Copy Markdown
Contributor

Syncs the upstream taskruntime stream-replay fix into this repo.

Summary

  • give every chat request a stable submission_id (proto ChatRequest.submission_id, set by the backend) and derive per-delegate submission identities from it
  • derive deterministic batch IDs and task idempotency keys from the submission id, so a backend→core transport replay reuses the existing batch instead of re-executing it
  • validate a submission fingerprint before reusing a replayed batch, and observe (never re-own) the original batch's runs
  • suppress whole-generation chat retries once a task batch has been submitted, reporting that the submitted tasks keep running
  • recognize GORM-translated duplicate-key errors in the task-runtime DAL
  • replace TASK_RUNTIME_RECONCILE_INTERVAL_SECONDS with TASK_RUNTIME_REPLAY_MATERIALIZATION_TIMEOUT_SECONDS, and run a bounded startup recovery (immediate + one delayed pass) driven by the shutdown event

Validation

  • ./scripts/lint.sh --backend / --core
  • cd backend && go build ./... && go test ./...
  • cd core && uv run pytest (823 passed)

Rollout

Pause new task submissions and let active taskruntime batches drain before rolling mixed backend/core versions: the old and new batch identity formats cannot safely coexist.

Sync of gim-home/dwp#934.

- give each chat request a stable submission id and derive per-delegate
  submission identities, deterministic batch ids and task keys from it
- observe an existing batch on replay instead of re-executing it, guarded by
  a submission fingerprint
- suppress whole-generation chat retries once a task batch has been submitted
- recognize GORM-translated duplicate-key errors
- replace the reconcile interval knob with a bounded startup recovery pass
  (immediate + one delayed) driven by the shutdown event
- move the replay batch lookup inside the failure guard so a store read that
  fails for a reason other than "not found" (backend outage, RPC timeout)
  still marks the parent delegate step failed instead of leaving it running
- add backend tests pinning that buildChatRequest assigns a unique submission
  id and that an Unavailable retry reuses it, so core treats the second
  attempt as a replay rather than a new submission
@jasonchen922
jasonchen922 merged commit 49a6701 into main Jul 28, 2026
6 of 7 checks passed
@jasonchen922
jasonchen922 deleted the users/jasonchen922/sync-taskruntime-stream-replay branch July 28, 2026 07:33
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.

1 participant