feat(anam): forward output video dimensions via SessionOptions#5935
Open
Smidge wants to merge 2 commits into
Open
feat(anam): forward output video dimensions via SessionOptions#5935Smidge wants to merge 2 commits into
Smidge wants to merge 2 commits into
Conversation
Add an optional anam.SessionOptions(video_width, video_height) that the plugin forwards into Anam's session-token request as sessionOptions.videoWidth/videoHeight. The avatar video then publishes at the Anam-resolved output size. Pixels only (no portrait/landscape strings), both-or-neither, validated server-side by Anam as the single source of truth: unsupported pairs return HTTP 400, already surfaced by the plugin as APIStatusError, with no silent downgrade. Mirrors the livekit-plugins-avatario VideoInfo dataclass. Backward compatible: session_options is optional; when omitted the request is identical to today and Anam applies the avatar model's default output.
6dbba86 to
ffbcd53
Compare
longcw
reviewed
Jun 5, 2026
Comment on lines
+105
to
+110
| if session_options.video_width is not None: | ||
| video_options["videoWidth"] = session_options.video_width | ||
| if session_options.video_height is not None: | ||
| video_options["videoHeight"] = session_options.video_height | ||
| if video_options: | ||
| payload["sessionOptions"] = video_options |
Contributor
There was a problem hiding this comment.
this doesn't match the comment above "Send both or neither"?
Author
There was a problem hiding this comment.
Good catch, you're right. It builds video_options from whichever field is non-None, so a lone video_width/video_height still goes out as exactly the half pair the comment says Anam rejects.
Fixing it to send both or neither, and to fail fast locally on a half pair rather than round-tripping a 400:
if session_options is not None and (
session_options.video_width is not None
or session_options.video_height is not None
):
if session_options.video_width is None or session_options.video_height is None:
raise ValueError(
"video_width and video_height must be set together (both or neither)"
)
payload["sessionOptions"] = {
"videoWidth": session_options.video_width,
"videoHeight": session_options.video_height,
}Thanks for the review!
Author
There was a problem hiding this comment.
Fixed in 73adbbc — sessionOptions now only goes out when both dimensions are present, and raises a ValueError on a lone width/height so it fails fast locally instead of round-tripping a 400.
The previous guard built sessionOptions from whichever of video_width / video_height was set, so a lone value was forwarded as a half pair, which the Anam API rejects with a 400. Only send the pair when both are present, and raise a ValueError on a half pair so it fails fast locally instead of round-tripping. Addresses review feedback from @longcw.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5954
What
Adds an optional
anam.SessionOptions(video_width, video_height)that the Anam avatar plugin forwards into Anam's session-token request assessionOptions.videoWidth/videoHeight. The avatar video then publishes at the Anam-resolved output size.Why
Anam's public session-token API now accepts explicit pixel output dimensions. This lets Agents users choose the avatar's output size without any provider-specific dimensions API.
Design
APIStatusErrorwith Anam's descriptive message. No silent downgrade.livekit-plugins-avatario(VideoInfo(video_width, video_height)). I named itSessionOptionsto match Anam's ownsessionOptionsAPI field and leave room for future session-level options — happy to switch to a nestedAvatarSession.VideoInfoif you'd prefer consistency with Avatario.session_optionsis optional (NOT_GIVEN); when omitted the request body is identical to today and Anam applies the avatar model's default. No behaviour change for existing users.Scope
5 files —
types.py(newSessionOptionsdataclass),avatar.py+api.py(thread through + emit camelCase),__init__.py(export), and the anam example. No new dependencies; no change to the LiveKit token /start_engine_session/wait_remote_trackflow.ruff format+ruff checkclean. Leftversion.py/changelog to the release bot per CONTRIBUTING.Happy to add unit tests for the payload construction in whatever harness you prefer.