Skip to content

chore: use ThrowsPromise helper across agent package - #1249

Merged
lukasIO merged 14 commits into
mainfrom
lukas/throws-promise
Apr 15, 2026
Merged

chore: use ThrowsPromise helper across agent package#1249
lukasIO merged 14 commits into
mainfrom
lukas/throws-promise

Conversation

@lukasIO

@lukasIO lukasIO commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Description

Changes Made

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: A small video demo showing changes works as expected and did not break any existing functionality using Agent Playground (if applicable)

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes)

Additional Notes


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

@changeset-bot

changeset-bot Bot commented Apr 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 994d83a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lukasIO
lukasIO marked this pull request as ready for review April 14, 2026 12:28
@lukasIO lukasIO changed the title Use ThrowsPromise helper across agent package chore: use ThrowsPromise helper across agent package Apr 14, 2026
@lukasIO
lukasIO requested a review from toubatbrian April 14, 2026 12:29
devin-ai-integration[bot]

This comment was marked as resolved.

lukasIO and others added 5 commits April 14, 2026 14:49
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 12 additional findings in Devin Review.

Open in Devin Review

Comment thread agents/src/utils.ts
Comment thread agents/src/utils.ts
Comment on lines +128 to +129
export class Future<T = void, E extends Error = Error> {
#await: ThrowsPromise<T, E>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having error typed Future is really nice!

Comment thread agents/src/worker.ts
this.#session!.on('open', resolve);
this.#session!.on('error', (error) => reject(error));
this.#session!.on('close', (code) => reject(`WebSocket returned ${code}`));
this.#session!.on('close', (code) => reject(new Error(`WebSocket returned ${code}`)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: maybe asError?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the asError helper is primarily meant to turn unknown catch values into an error at best effort. Constructing the error here is fine, I think

@toubatbrian toubatbrian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG overall!

@lukasIO
lukasIO merged commit 42acf87 into main Apr 15, 2026
9 checks passed
@lukasIO
lukasIO deleted the lukas/throws-promise branch April 15, 2026 06:59
@github-actions github-actions Bot mentioned this pull request Apr 15, 2026
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.

2 participants