Repository navigation
feat: add spatialreal_avatar_python avatar extension - #2387
YuehengHan wants to merge 36 commits into
Conversation
|
|
Thanks for the review. All four findings are addressed in the commits pushed after e6e59a1 (fdc5f8b, 72f5960, 3f78a4f, d08fa42, 2f6eeb6); 133 tests pass in 1. Request-end signals overtaking queued audio. Fixed in fdc5f8b. 2. Frame inside the gate surviving a flush. Fixed in 72f5960. The pacer carries a cancellation generation through 3. Send after the gate counted as sent while disconnected. Fixed in 3f78a4f and 2f6eeb6. 4. Permanent token-authentication failures retried forever. Fixed in d08fa42. |
|
Package skeleton for the SpatialReal avatar extension: manifest with the
top-level + params property shape, pcm_frame in, tts_audio_end/finalize data
in, flush cmd in/out and error data out; property.json defaults with env
references; pyproject and requirements pinning spatialreal 0.2.3,
agora-token-builder and audioop-lts on 3.13.
The extension class is a stub whose hooks log at debug and whose on_cmd
answers OK; dispatch and the session wiring come in later commits.
Tests: tests/conftest.py holds pure fixtures (FakeClock) and nothing from
TEN; tests/runtime/ carries the heygen-style FakeApp conftest and the
hello_world basic test behind pytest.importorskip("ten_runtime"), so
`pytest tests/` on a laptop runs the pure tests and skips the runtime ones.
…se in params The TEN server injects the channel into the node property; every other setting, including the Agora keys, lives in the params object as ten_ai_base vendor extensions do. ten_ai_base is declared as the 0.7 range; the resolved version must export ModuleType.AVATAR (checked at install time).
build_agora_token applies the D3 rule the session client re-runs on every connect: an explicit agora_token is used verbatim, otherwise an App Certificate signs a publisher token for the channel and uid (24 h by default), otherwise the App ID itself is the token. No App ID and no token is a ValueError the glue reports as a config error. The tests parse the minted token back and check the publisher privileges and their expiry; byte equality is not possible because the builder salts every token. pyproject.toml gains the pytest options that let `pytest tests/` run from this directory on a laptop without the TEN runtime: the pure modules import from here, and collection stops at tests/ so the package __init__ (which imports ten_runtime) is never loaded.
Pure audio module for the avatar extension (design D5): a streaming int16 mono Resampler over audioop.ratecv that keeps filter state across the chunks of one request and resets at close/flush, drops a trailing odd byte instead of raising, and passes same-rate audio through; a silence() generator in whole samples at the session rate for the pacer's padding, and duration_ms() for the virtual playhead. Tests cover pass-through, the odd-byte and empty-buffer guards, the 16k->24k length ratio, state continuity across 10x20 ms chunks versus a single 200 ms conversion, reset, silence sample counts and the fractional-sample rejection.
Pure pacer module for the avatar extension (design D5, D6). It owns the request boundaries: the first audio after idle opens a request, and the first of tts_audio_end (reasons 1, 3, unknown; 2 only when no flush has been processed since the last end signal), finalize, the padding bound or the stall backstop closes it with send_audio(b"", end=True). Closing is idempotent and reports whether this call closed, so the glue logs each end signal once. A virtual playhead, ahead_ms = sent_ms - (now - first_send), drives the padding: each tick sends enough 100 ms silence chunks (whole samples at the session rate) to lift the playhead back to the 600 ms floor, with a microsecond tolerance so float drift on the floor never pads a spurious chunk. Three seconds of contiguous padding closes the request; 15 s after the real audio drained is the outer backstop. A new request waits while the predecessor's playhead is less than 2000 ms past drained. The wait races the injected sleep against an abort event, so flush cancels it, closes the open request locally without end=True, calls interrupt and waives the gate for the next request. on_session_reset forgets the playhead after a reconnect. Tests drive the clock and ticks by hand with a fake sink: open and send, padding below the floor, none above it, pad max and stall closing once, the tts_audio_end reason table, finalize then tts_audio_end sending one end=True, the gate wait and early-wake re-check, flush during the gate wait (interrupt first, then the new request), whole-sample padding at 22050 Hz, session reset and the run loop.
…on loads The TEN Python addon loader imports the extension as the package ten_packages.extension.spatialreal_avatar_python with only the app root on sys.path; the extension directory itself is never there. pacer.py's `from audio import ...` therefore raised ModuleNotFoundError the moment the package imported it, and pylint flagged it as E0401. Use `from .audio import` like every other extension. The laptop tests masked this through pytest's `pythonpath = ["."]`. Drop it; tests/conftest.py now registers a stub `spatialreal_avatar_python` package whose __path__ is the extension directory, so the tests import the pure modules by package name without running the real __init__ (which needs ten_runtime). The test files import through that package name.
…olicy SessionClient keeps one spatialreal session up for the extension's lifetime and owns reconnection (design D7). Every connect mints a fresh session token (expire_at now + 1 h) and a fresh Agora token through the D3 rule. classify_start_error and classify_runtime_error map the SDK's exceptions to a decision: 4001/4010 fatal, 4003 slow schedule (30, 60, 120, 300 s, ten attempts, then fatal), 4503 and transport failures fast schedule (1, 2, 4, 8, 15, 30 s), token HTTP 400 a config error, a 4010 server-error frame report-only. on_close without a preceding error, ValueError from send_audio and transport_frames also reconnect on the fast schedule; an idle timer reconnects silently after egress_idle_reconnect_ms when no request is open. Reports (D8 codes 1001 / -1 / -1012) go to the glue as ErrorReport; an outage reports 1001 once. SDK callbacks are marshalled with call_soon_threadsafe and bound to the session generation that registered them, so an on_close that lands after our own teardown cannot start a second connect. Tests drive the client against a fake session factory under virtual time and cover every decision branch, the slow and fast schedules, the stale on_close case, the idle timer, token re-minting per connect and stop during backoff.
…e code
classify_start_error and classify_runtime_error deferred to the SDK's
AvatarSDKError.retryable when close_code was None, and the SDK only
answers True for connectionFailed/connectionClosed/upstreamError. A
failed inference call relayed as ServerError{code: 0} (session still
up), a frame that did not parse (protocolError) and a protocolError from
the handshake therefore classified as STOP and tore the session down for
good. Design D7 says a missing close code takes the fast schedule in
both places; check close_code is None first and let retryable handle the
coded cases. Tests cover serverError(server_code="0") and protocolError
with no close code in both classifiers.
Drop the two `except asyncio.CancelledError: raise` branches: on
Python 3.8+ CancelledError is a BaseException that the following
`except Exception` never catches, so they were dead code and pylint
flagged them as W0706 (TEN CI fails on any warning). Remove the two
broad-exception-caught disables along with them; TEN's .pylintrc already
disables that check globally.
…d error reporting Resolve the two top-level properties (channel and the params object) in a pure config module: agora_channel overrides channel, agora_uid parses from a string or an int and must be non-zero, sample_rate must be one of the accepted session rates, agora_appid is required unless agora_token is set, and an empty channel gets the hint about the TEN server injecting it. Integer knobs given as null or an empty string fall back to the package defaults. The extension loads the config, logs it once with secrets masked, and wires the session client, the pacer and a per-rate resampler together: audio frames are queued (bounded to 10 s of playout) until the session is up, tts_audio_end and finalize close the request through the pacer, flush drops queued audio, cancels the gate wait, interrupts and continues downstream. Every report becomes a ModuleError on data error with module avatar, the -1012 / -1 / 1001 codes, vendor_info spatialreal plus the close code or exception class, and a vendor_metadata block without URLs, keys or empty values. Nothing raises out of a hook; a config failure leaves the extension idle. The runtime test asserts the error shape for empty params; it runs only under the TEN runtime.
README per the design: media shape (audio plus SEI animation, no video), the configuration table with the session-rate note, a complete avatar node with "channel": "" and its three edges, test and lint commands, and the limits. voice-assistant-advanced gets a voice_assistant_spatialreal graph built by the basic voice assistant builder with the SpatialReal avatar node, the matching path dependency in its manifest, and SPATIALREAL_* keys in .env.example next to the Agora keys. property.json carries only the new graph. The committed file has drifted from rebuild_property.py (hellos prompt wording, compact "names" arrays), so a plain rerun would also rewrite unrelated graphs; the new graph is the script's output appended to the committed file, every other byte unchanged.
Verified in ghcr.io/ten-framework/ten_agent_build:0.7.14 (Python 3.10.12, black 25.12.0, pylint 3.3.9): tman resolves ten_runtime_python 0.11.75 and ten_ai_base 0.7.63, which exports ModuleType.AVATAR and ModuleErrorVendorInfo, so the manifest keeps ten_ai_base 0.7. The CI image ships pytest without pytest-asyncio (and another extension pins pytest 8.3.4), where pytest 8 skips coroutine tests and pytest 9 fails them. tests/conftest.py now runs each coroutine test on a fresh event loop when the plugin is absent, so the 39 async tests run everywhere; pytest-asyncio still owns them where it is installed. Drop the redundant `except CancelledError: raise` in the audio sender (pylint W0706): CancelledError derives from BaseException and already passes the `except Exception` handler.
…ams arrived as a dict
With every required key empty, an empty `params` dict and a dict of empty strings produce the
same first message ("params.spatialreal_api_key is required"), so the runtime test could not
tell whether the `params` object reached `resolve_config` at all. Give the fixture non-empty
test literals for the SpatialReal keys, the channel and the Agora app id, and `agora_uid: "abc"`:
validation now fails on `agora_uid`, which only happens when `params` was read as a dict.
…ror report names `SessionClient` reports before it clears `connection_id`, but `_on_report` only spawns `_send_error`, which read `self.client.connection_id` when the task ran, by which time it was already "". Every mid-session error therefore shipped `metadata.session_id = ""`. `_send_error` now takes `session_id`, defaulting to the client's current connection id for the config and start-up errors, and `_on_report` passes `report.session_id`. No committed test reaches this: extension.py imports ten_runtime, so the pure suite cannot load it, and the runtime harness has no connected session to drop. Checked by hand with stubbed TEN modules: a report carrying "conn-42" arrives on data `error` as `session_id` "conn-42" after the client's own id was cleared; the default still reads the live id.
…vedConfig in one step `ResolvedConfig` and `SessionSettings` have the same 13 fields; `_start_session` copied them one by one and `redacted()` listed them again with its own idea of which were secret. It now does `SessionSettings(**asdict(cfg))`, and `redacted()` and `redacted_params()` share one `_masked` helper driven by `SECRET_KEYS`, with a one-entry map for the field whose name differs from its property key (`api_key` -> `spatialreal_api_key`). Output is unchanged, key order included. A pure test pins the field lists of the two dataclasses to each other so a field added to one and not the other fails the suite instead of silently dropping a setting.
…session reset `on_session_reset()` forgot the playhead (`ahead_ms` becomes -inf) but left the sender's gate wait sleeping on the old remaining time, so after a reconnect the first chunk of the next request could sit for up to `ahead_ms + gate_ms` for a tail that no longer exists. The reset now also sets the gate-abort event; `_wait_for_gate` re-reads the playhead on wake and returns at once. Covered by a test with a hanging sleep: the audio queued at the gate is sent as soon as the reset lands, with no second sleep.
… queued audio `tts_audio_end` and `finalize` closed the pacer's request the moment they arrived, while the request's PCM could still be queued for the sender task: behind, waiting for the session, or waiting at the previous request's gate. The `end=True` then either overtook its own audio or was discarded because the request had not opened yet, and the frames that followed reopened a request or merged into the next turn. The end signals are now `End` markers in the same queue as the frames, applied by the sender only after every frame queued before them has gone out. `flush` still acts at once: it clears the queue, markers included, since everything queued belongs to the cancelled turn. The queue bound drops the oldest frames only, never a marker. The sender loop (queue, session wait, resampling, pacer calls, request-state notes) moves out of `extension.py` into the pure `sender.py` so it runs under pytest without `ten_runtime`. The new tests drive the real pacer with a sleep the test releases: a complete second request plus its end queued while the first request's gate is active goes out as audio, audio, end; an end queued before the session is up waits for its audio; a flush drops frames and markers; a late reason 2 reaches the pacer and is ignored after a flush.
…it waits at the gate The sender compared the flush generation before it entered the pacer, so a frame already inside `_wait_for_gate()` survived a flush: `Pacer.flush()` woke the gate and waived the delay, and the cancelled frame was sent right after the interrupt, restarting the old speech. The pacer now carries its own cancellation generation through the gate. `flush()` bumps it; a wait that started under an older value returns without opening a request or sending, and `push_audio()` reports it as `PushResult.CANCELLED` (`PushResult.SENT` otherwise). The sender drops a cancelled frame. The waiver the flush set stays for the next turn's first chunk, as before. `on_session_reset()` does not cancel: a frame woken by a reconnect still goes out. `test_flush_bypasses_gate_and_interrupts` asserted the old frame was sent; it now asserts it is not, and that the next turn's first chunk opens a request at once after the interrupt. A sender test covers the same path end to end.
…ession refused The sender checked the session before `push_audio()`, which can wait seconds at the gate. A session that dropped meanwhile reset the pacer and woke the gate; the send then reached `SessionClient.send_audio()`, which returned False, but the pacer counted the chunk as sent and the PCM was lost. `PacerSink.send_audio` now declares its bool result and the pacer reads it: a refused send is `PushResult.NOT_SENT`, nothing is counted, and a request opened for that chunk is forgotten (`_forget_request`, shared with `on_session_reset`). A refused padding chunk is not counted either. The sender treats `NOT_SENT` as "still owed": it keeps the converted frame, waits for the session event again and retries on the replacement session, unless a flush lands first, which drops it as before. Tests: a pacer test for the refused send and refused padding; sender tests over a fake client that drops during the gate wait, asserting the pending PCM lands in the replacement session with no second gate wait, and that a flush while the frame is held drops it.
… HTTP 401 or 403
`classify_start_error` sent every `SessionTokenError` other than HTTP 400 down the fast-retry
branch, so an invalid or revoked API key was reported once as non-fatal `1001` and retried
forever. The fatal 4010 handling never applied: with no session token there is no handshake to
be refused.
HTTP 401 and 403 from the token exchange are now terminal: `Decision.STOP`, code `-1`, one
fatal report, no further attempt. 400 stays a configuration error and everything else (5xx,
network) keeps the fast schedule. The SDK (spatialreal 0.2.3) sets `http_status` on every
non-200 token response, so that field is the classifier's input. The vendor code for a token
error that carries an HTTP status is now that status as a string ("400", "401", "403", "503"),
alongside the WebSocket close codes; the class name remains for errors without one.
Tests: classification cases for 401, 403, 502 and the updated 400/503 vendor codes; a
reconnect-loop test per refused status asserting a single fatal report and no retry over an
hour; a 5xx test asserting the fast schedule still reconnects.
…n is still up The hold-for-reconnect path assumed every refused send meant the session had gone down. The client can also answer False while it stays connected (a send that raised a server error the client only reports), and the sender would then retry the same chunk in a tight loop. A refused send is held only when the session event is clear, which is what `session_down` does on an outage; when the event is still set the chunk is dropped with one warning and the sender moves on. Covered by a sender test over a fake client that refuses sends while connected.
The pacer refilled the virtual playhead to a 600 ms reserve whenever it dipped below it, so a ticker that ran while speech was still playing spliced silence between speech chunks that arrived in time. PAD_FLOOR_MS is now 0: silence is inserted only after the sent audio has drained, and only enough to cover the actual deficit. Positive lead is left alone.
Padding computed its chunk count once and then sent the whole batch, so real audio or an end that arrived during an awaited padding send was followed by stale silence. The lead is now rechecked before each chunk, and padding stops as soon as the request closes.
…layback state Preserve TEN session/turn metadata through the ordered audio sender so late PCM or end events cannot close or restart a newer identified turn. Keep request-end deduplication separate from turn retirement, and reject old turn numbers per session without dropping earlier queued audio. Wait for an interrupt send before admitting the next turn, and exclude old padding completions from a new request's playhead accounting. Add pure red/green regressions and native TEN lifecycle tests using the production hooks and startup path with a recording session boundary. Document identity requirements and the remaining unscoped-input limits.
…p retries The input queue dropped its oldest frames past 10 s of PCM. A response synthesized before the session came up lost its middle and was then closed with a normal end, so the avatar played a shortened answer. The queue no longer discards anything. Frames and ordered ends are kept within 120 s of PCM, 16 MiB and 4096 items, the in-flight item included. Admission beyond a limit cancels the buffered turn and reports a nonfatal avatar error with vendor category InputQueueOverflow instead of playing truncated speech; a failed turn can never receive a successful end. Tests: a delayed-startup regression that keeps a 26 s response byte for byte through 41 s of withheld readiness, atomic duration, byte and item limits, in-flight budget, unknown and mixed metadata, and native runtime cases for overflow reporting and stop.
Adds params.source_timeline_only (off in this commit). When set, the Agora egress is asked to publish on the source audio timeline only, and the extension refuses to start with an SDK that cannot request it or cannot verify the server's acknowledgement. A server that does not confirm the mode is a configuration error (-1012) with no retry.
Adds params.source_playback_profile: 0 keeps the earlier source-only contract, 1 requests BOUNDED_BURST_V1 and requires source-only mode. With a profile requested, the session must confirm both the agora_source_timeline_only and agora_source_burst_v1 capabilities; otherwise the session is closed, with its callbacks invalidated first, and the start fails with a configuration error and no retry.
…fault source_timeline_only now defaults to true and source_playback_profile to 1 when source-only is on (0 otherwise), so a default node negotiates the bounded burst profile with the backend. The two keys are dropped from property.json so the code defaults apply; explicit false/zero values are still forwarded to SDKs that know the fields, for compatibility mode.
…then fails The sender captures a frame's flush generation once, before the session wait, and checks it on every retry: a flush that lands while the frame's send is in flight retires it even when that send fails because the session dropped. The existing flush test only covered a frame already held for reconnect. The new test parks a send, flushes, drops the session, lets the send fail and connects a replacement session: the replacement receives nothing from the cancelled turn, and the next turn's audio still goes out on it.
…nd the gate The input queue no longer evicts frames on enqueue, connected or not: it preserves every frame and ordered end within 120 s of PCM, 16 MiB and 4096 items, and admission beyond a limit cancels the turn with an InputQueueOverflow error instead of dropping the oldest audio. The new test parks the sender at the previous request's gate on a connected session, queues 12 s of distinct 100 ms frames plus an end, releases the gate and checks that every frame reaches the sink in order, followed by the end. Under the old 10 s budget the same input is refused at frame 101.
… a timed-out start The SDK's start() waits for ServerConfirmSession with an unbounded recv(). A socket that upgrades and answers pings but never confirms the session held the connect loop forever: no retry, no idle timer. The handshake, start() and the capability check that follows it, now runs against START_TIMEOUT_S (20 s, through the injected sleep). On the deadline the call is cancelled and a TimeoutError takes the normal start-failure path: one 1001 report per outage and the fast schedule. Cancelling start() skips the SDK's own cleanup of the half-open socket, so every failed start now invalidates the session's callbacks and closes it explicitly before the retry, as the capability check already did; close() is idempotent for the other failures. Test: a session whose start() never returns is cancelled at the deadline, closed once, reported as non-fatal TimeoutError, and the next attempt after the 1 s backoff connects.
…loses a request The pacer's ticker closes a request on its own at the padding limit or the stall backstop. Only the sender reported request state to the session client, so after a request that ended without an end marker the client kept _request_open set and the idle loop skipped its planned reconnect indefinitely, letting egress leave the channel on inactivity. Pacer takes an on_request_state callback and calls it with False whenever end_request() closes a request, the ticker's closures included; the extension wires it to SessionClient.note_request_state, as it already does for the sender. Test: the real sender, pacer and session client over a fake session. 500 ms of speech with no end marker is padded to the limit and closed by the ticker, and the idle reconnect follows 10 s after the last send.
…t the viewer requirement SDK 0.4.0 is the release whose Agora egress defaults to source-timeline-only playback with the bounded burst profile, which the extension now also defaults to. requirements.txt and pyproject.toml both pin spatialreal>=0.4.0,<0.5; pyproject.toml still named the 0.2 line. The README now states the viewer requirement (web-sdk 1.0.0-beta.7 or newer, or beta.6 with agora.sourcePlaybackProfile set to bounded-burst-v1), how to select compatibility mode, that the backend must confirm both capabilities or the session fails with a configuration error, and the 20 s handshake deadline.
2f6eeb6 to
391166d
Compare
|
The four findings against 2f6eeb6 are addressed on the updated branch (rebased onto current 1. Flush generation replaced across send retries. Already fixed by ee9439c; regression test added in cdf55fb. 2. 10-second eviction while connected at the playback gate. Already fixed by 825cfc3; regression test added in 93b59f6. The input queue no longer evicts on enqueue, connected or not. Frames and ordered end markers are kept within 120 s of PCM, 16 MiB and 4096 items, the in-flight item included. Input beyond a limit cancels the buffered turn and reports a non-fatal avatar error with vendor code 3. Unbounded application handshake. Fixed in 65332b2. The whole handshake, 4. Ticker closures not reaching the idle timer. Fixed in e43519b. |
|
…flight audio send push_audio marks the request open before it awaits the sink, but counts the chunk only once the send returns. A send that yields under backpressure for a tick left the ticker reading the old playhead: it padded silence ahead of speech that had already arrived and, given enough ticks, closed the request for pad max or stall while that speech was still in flight. The pacer now counts real sends in flight. While one is pending, tick() neither pads, nor counts toward pad max, nor closes for pad max or stall; a padding send that real audio overtakes no longer closes the request after it. The next tick after the send completes reads the updated playhead. flush() still acts at once, and a send that completes after a flush, end or reset is not counted toward the request that boundary closed.
|
Fixed in 51050c4. The pacer now counts real audio sends in flight, and |
|
…g session startup The SDK starts its read loop inside start(), so the server can close or fail the session before _connect_once() publishes the connection. Those callbacks were dropped (close, retryable error) or acted on while the attempt was still in flight (fatal error), after which the attempt still marked the session connected. Callbacks of the attempt in progress are now recorded and resolved before the connection is published: a close, transport_frames or retryable error makes it a failed connect on the fast schedule, a fatal error stops the client without ever reporting the session connected. Regressions cover an immediate close, a retryable error and a fatal error during startup.
…rame limit A flush from main_python carries no turn identity, so an interrupted turn that has not delivered any PCM yet cannot be told apart from its successor. Document the bounded window and what would close it.
|
1. Interrupted turn whose first frame arrives after the flush — Confirmed, and it cannot be fixed correctly inside the extension with what reaches it today. The 2. Disconnects during session startup — Fixed in 31b3087. While a connect attempt is in progress, |
|
|
Summary
Adds
spatialreal_avatar_python, an avatar extension that drives a SpatialReal avatar into the Agora channel from a TEN graph's TTS audio.pcm_framein, request end on datatts_audio_end(REQUEST_END/ERROR,INTERRUPTEDwithout a priorflush) or datafinalize, cmdflushin and forwarded, errors asModuleErroron dataerror(module: "avatar",vendor_info.vendor: "spatialreal", codes-1012config /-1fatal /1001non-fatal).spatialrealPython SDK (PyPI,>=0.4.0,<0.5) into a session configured for Agora egress; SpatialReal's egress joins the channel asparams.agora_uidand publishes the TTS audio plus the avatar animation as SEI on a placeholder video track. There are no rendered video frames: the 3DGS avatar is rendered on the viewer's side with the SpatialReal web SDK in Agora mode (a plain Agora player shows audio and a black 64x64 picture). The README states this up front.params.source_timeline_only, defaulttrue;params.source_playback_profile, default1). Both are negotiated at session start: the backend must confirm theagora_source_timeline_onlyandagora_source_burst_v1capabilities, otherwise the session is closed and a-1012configuration error is reported, with no retry and no silent fallback.params.source_timeline_only: falseselects compatibility mode for viewers that play the egress's native audio.@spatialreal/web-sdk1.0.0-beta.7 or newer (detects the published profile automatically), or 1.0.0-beta.6 withagora.sourcePlaybackProfile: 'bounded-burst-v1'.channel(filled by the server at/start) plus aparamsobject with the SpatialReal keys (spatialreal_api_key,spatialreal_avatar_id, optionalspatialreal_app_id,environment, endpoint overrides,sample_rate, the two playback keys) and the Agora keys (agora_uid,agora_token,agora_appid,agora_appcert,agora_channel). The Agora token is used verbatim when given, otherwise minted withagora-token-builderfrom the app certificate, otherwise the App ID.metadata.session_id/turn_id; a flush retires the active, queued and in-flight turns, and late audio or ends from a retired turn are ignored. Input is kept within 120 s of PCM, 16 MiB and 4096 items; going over cancels the buffered turn with a non-fatalInputQueueOverflowerror instead of dropping audio.voice_assistant_spatialrealgraph invoice-assistant-advanced(same wiring as the HeyGen graph with the avatar node swapped) and the threeSPATIALREAL_*keys inai_agents/.env.example.Type of Change
Testing
task check(black, 80 cols): clean.pylint --rcfile=tools/pylint/.pylintrcon the extension: 10.00/10.ghcr.io/ten-framework/ten_agent_build:0.7.14withspatialreal0.4.0 installed from PyPI: 227 tests pass (211 pure unit tests, 16 under the TEN runtime, none skipped). The pure tests cover the pacer, sender ordering and turn isolation, resampling, the token rule, config resolution and the session wrapper's handshake and reconnect policy; they also run with plainpytest tests/on a laptop without the runtime.deepgram_asr_python→gemini_llm2_python→cartesia_tts→ this extension, withmain_pythonandagora_rtc) running in the TEN runtime against SpatialReal's backend, a real Agora channel and viewers on@spatialreal/web-sdkin desktop Chrome and Safari. Human conversations with interruptions, and scripted full-path runs that feed synthetic speech through the whole pipeline (ASR → LLM → TTS → avatar) and check that every normal reply drains to its exact final sample, with no audio scheduling gaps, and that an interruption during playback is followed by a clean reply. The same setup runs as a hosted public demo on released packages (spatialreal0.3.0 and@spatialreal/web-sdk1.0.0-beta.6) with both playback settings set explicitly, which is the behaviour 0.4.0 and this extension now use by default.Documentation
README.mdfor the extension: media shape, viewer requirement and playback mode, configuration table (property, env var, default, range), complete graph node, test and lint commands, limits..env.examplekeys; example graph inrebuild_property.pyandproperty.json.Breaking Changes
None. New extension and new example graph only; existing graphs are untouched.
Notes for reviewers
agora_uidis a string property (as the hosted engine passes it) but must parse as a non-zero integer: SpatialReal's egress publishes with an integer uid.ten_ai_base.utils.encrypt).