Skip to content

fix: allow retrying failed voice compute turns - #13

Merged
jerelvelarde merged 2 commits into
CopilotKit:mainfrom
charan-rathore:fix-voice-compute-retry
Oct 5, 2026
Merged

jerelvelarde merged 2 commits into
CopilotKit:mainfrom
charan-rathore:fix-voice-compute-retry

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

What this fixes

The voice compute cache kept a promise even when it rejected. A failed compute stayed in the cache for good, so it used up one of the six turns allowed per call, and retrying with the same toolCallId failed again every time.

Changes

  • Remove the failed promise from the cache when it rejects, and rethrow the original error.
  • Concurrent calls with the same key still share one in-flight promise.
  • Successful results are still cached, and the six-turn cap is unchanged.

Tests

Two regression tests (a failed compute can be retried, and the failure is not left in the cache). They fail on the base commit. I also added a test that guards the success cache and the six-turn cap. The tests use no external API.

Results below are from the person who prepared the change; I did not rerun them. Full suite: 34 files, 159 tests pass. Lint, typecheck, format check and production build pass (the build prints a chunk size warning that was already there). No dependency or lockfile changes.

@NathanTarbert NathanTarbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @charan-rathore. Clearing only the failed entry is a nice small change. Calls that are in flight still share one promise and successful results stay cached, and the comment makes the intent easy to follow.

One thing worth weighing. job.calls is also what the six-turn cap counts, so removing failed entries means failed turns stop counting toward it. With a provider that keeps failing, a call can now start as many turns as the model asks for, not six. Each one can still use up to 90 seconds of model time and run tools before it fails. The test "does not count failed compute calls toward the six-turn limit" shows this is deliberate. I just wanted to name the cost. If the goal is mainly to let the same tool call retry, one option is to keep counting every attempt toward the cap while still allowing a retry under the same id. Happy to go with whichever the maintainers prefer.

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@charan-rathore

Copy link
Copy Markdown
Contributor Author

Thanks, good catch. Pushed 642afcd: the cap now counts attempts instead of the size of the call map. A failed turn is still removed from the map so the same tool ID can retry, but every attempt, including a retry of the same ID, counts toward the six. I replaced the old "does not count failed calls" test with two that fail on the previous commit: six failed IDs hit the cap on the seventh, and six retries of one ID do too.

Ran: full vitest (160 passed), tsc, prettier on the two files. Not run: eslint beyond those files.

Prepared with AI assistance; Charan Rathore is directing and responsible for this PR.

@NathanTarbert

Copy link
Copy Markdown
Collaborator

Thanks @charan-rathore, that's exactly the shape I had in mind. A failed id can retry, and every attempt still counts toward the six. The two tests for six failed ids and six retries of one id pin down both halves nicely.

Looks good to me.

@jerelvelarde jerelvelarde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Useful voice tool retry fix: failed computations can be retried, successful results remain cached, and all attempts still consume the bounded six-attempt budget. Checked concurrent failure deduplication, successful retry caching, cancellation, and rejection after call termination. No actionable security or correctness findings. Individual full checks pass; combined tree passes 233 tests, type checking, lint, formatting, and production build. Live provider calls were not exercised.

@jerelvelarde
jerelvelarde merged commit 6b67b74 into CopilotKit:main Oct 5, 2026
1 check passed
@charan-rathore
charan-rathore deleted the fix-voice-compute-retry branch October 5, 2026 19:59
asasemahmed added a commit to asasemahmed/FullDots that referenced this pull request Oct 11, 2026
A failed compute request during a call can be retried instead of being stuck, and failed attempts still count toward the per-call turn cap.

Ported from CopilotKit/OpenDots#13 (upstream commit 6b67b74).
churivibhav added a commit to churivibhav/OpenDots that referenced this pull request Oct 13, 2026
Brings in CopilotKit/OpenDots main (625452e): dark mode, per-Dot MCP
connections with owner approval, page deletion, the current time in
Dot prompts, time-limit errors, and about 25 smaller fixes.

Conflicts resolved toward this fork's design where the two differ:
- dot-agent keeps OpenCode delegation, background tasks and the spoken
  reply instructions alongside upstream's connection tools and
  telemetry; the turn time limit stays turnTimeoutMs so OpenCode work
  still fits, and now produces upstream's time-limit error.
- voice keeps browser speech recognition and Piper TTS instead of
  upstream's Realtime/WebRTC call. Of upstream's voice fixes, CopilotKit#13
  (retry a failed compute turn, failures count toward the cap) and CopilotKit#39
  (survive up to two failed control polls) are ported; CopilotKit#26's
  peer-connection grace period has no equivalent and its tests are
  dropped. The control-poll tests are adapted to the cascaded hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
superops-team pushed a commit to superops-team/OpenMPA that referenced this pull request Oct 29, 2026
* fix: allow retrying failed voice compute turns

* fix: count failed voice compute attempts toward the turn cap

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>

---------

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
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.

3 participants