Skip to content

Create Awaitable Proxy#1058

Open
toubatbrian wants to merge 2 commits intomainfrom
brian/awaitable-proxy
Open

Create Awaitable Proxy#1058
toubatbrian wants to merge 2 commits intomainfrom
brian/awaitable-proxy

Conversation

@toubatbrian
Copy link
Contributor

Create a utility that wraps a class constructor so that instances are both fully functional (all original properties/methods) and awaitable via a user-provided handler.

This mirrors Python's __await__ protocol. In JS, await works on any "thenable" (object with a .then() method), so the returned constructor produces instances with a transparent .then that delegates to the handler.

The returned class is safe to extends — subclass prototype chains are preserved via Reflect.construct with newTarget forwarding.

This class is intended to be used for AgentTask and SpeechHandle so developer can easily do await directly on the object instead of calling await new AgentTask().run() and await new SpeechHandle().waitForPlayout() (tho both method will remain backward competible)

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

🦋 Changeset detected

Latest commit: 3729bb9

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

This PR includes changesets to release 20 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam 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-neuphonic Patch
@livekit/agents-plugin-openai 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-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

@toubatbrian toubatbrian requested a review from a team February 18, 2026 00:41
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6b219f14a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
return promise.then.bind(promise);
}
return Reflect.get(obj, prop, receiver);

Choose a reason for hiding this comment

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

P1 Badge Preserve target receiver when exposing instance members

The get trap returns non-then members via Reflect.get(obj, prop, receiver), so method/getter calls execute with this bound to the proxy instead of the real instance. For classes that use ECMAScript private fields (#field), this triggers runtime brand-check failures (Cannot read private member ...) as soon as a proxied method/getter is invoked, which breaks the “fully functional” guarantee of makeAwaitable and can crash any awaitable wrapper around such classes.

Useful? React with 👍 / 👎.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

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