Skip to content

fix(agent): drop expired-credential voice sockets with TOKEN_EXPIRED/4001 - #305

Closed
prisis wants to merge 2 commits into
alphafrom
advisor/277-agent-approval-durability
Closed

prisis wants to merge 2 commits into
alphafrom
advisor/277-agent-approval-durability

Conversation

@prisis

@prisis prisis commented Aug 2, 2026

Copy link
Copy Markdown
Member

Branched before #288/#289 landed, so it needs a rebase onto current alpha before merge.

Commits

  • fix(agent): drop expired-credential voice sockets with TOKEN_EXPIRED/4001
  • fix(agent): memoize the dynamic tool-approval gate in its own durable step

Files this branch still changes relative to alpha

packages/agent/__tests__/agent-loop.test.ts
packages/agent/__tests__/voice-do.test.ts
packages/agent/src/agent-loop.ts
packages/agent/src/index.ts
packages/agent/src/types.ts
packages/agent/src/voice-do.ts

prisis added 2 commits August 1, 2026 16:22
…4001

The voice-session DO captured the caller's identity at WebSocket upgrade
and replayed it into every turn's dispatch runner for the socket's whole
life, but never read the x-lunora-identity-exp header the runtime already
forwards on that same upgrade. A voice socket was effectively an
unexpiring credential: revoking or expiring a user's session did not
terminate an open voice socket, so every thread write it made kept being
attributed to (and authorized as) that user indefinitely.

Mirror the sibling ShardDO's existing pattern: stamp the parsed expiry
(epoch ms) onto the hibernation attachment at upgrade, and check it at
the single message entry point before dispatching a control frame or
buffering audio. An expired socket gets the same TOKEN_EXPIRED error
frame and 4001 close code ShardDO already sends, so a client handling
one handles both. Absent or malformed headers keep today's behavior
(never auto-expire) — additive only.
… step

The needsApproval gate was awaited outside any durable step, so on every
workflow replay (a retried step, a resumed hibernation, an approval wake)
the user's callback re-ran — including any run()/setState() it triggered
through the tool context it was handed. Worse, a gate whose answer depends
on getState() could flip false to true between the original pass and a
replay, routing the replay into an approval wait no client would ever
resolve and hanging the instance until the workflow timeout.

Wrap only the dynamic (function) gate in its own durable step
(tool:approval-gate:<call.id>, distinct from the tool's own step so
@lunora/workflow's by-name memoization can't confuse the two) so it
resolves exactly once per call. The boolean/undefined forms stay outside
any step since replay re-derives them identically for free. The gate now
receives a read-only AgentApprovalContext (no setState) instead of the
full tool context, formalizing the existing rule that a gate must not
mutate state.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@prisis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 336a8221-935a-413e-b29d-21513c805c29

📥 Commits

Reviewing files that changed from the base of the PR and between 6a4dd72 and 69d1f59.

⛔ Files ignored due to path filters (2)
  • packages/agent/__tests__/agent-loop.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
  • packages/agent/__tests__/voice-do.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
📒 Files selected for processing (4)
  • packages/agent/src/agent-loop.ts
  • packages/agent/src/index.ts
  • packages/agent/src/types.ts
  • packages/agent/src/voice-do.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@netlify

netlify Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for lunorash failed.

Name Link
🔨 Latest commit 69d1f59
🔍 Latest deploy log https://app.netlify.com/projects/lunorash/deploys/6a6f0b621df15f000869df7e

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for confirming the Contributor License Agreement! 🙏

@prisis

prisis commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Closing: this PR was opened in error by an automated run, outside the scope of its task.

No work is lost — the branch is retained on origin and this PR can be reopened at any time.

Context: this branch predates the merges of #288 and #289, so much of its content is already on alpha, and it would need a rebase before being reviewable. Reopening deliberately, after a rebase, is preferable to leaving it open in this state.

@prisis prisis closed this Aug 2, 2026
@prisis
prisis deleted the advisor/277-agent-approval-durability branch August 2, 2026 09:57
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using our GitHub Discussions tab for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant