Repository navigation
Conversation
port of #8557 for 2.0
amd.rs: v2.0 removed answering-machine detection, so the file and its token-mode assertion are gone. productstats: the new product statistics export belongs to no job. It signs with the key through observability_key_bearer, and stays off in token mode. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- Worker: pending CreateJobToken requests are a HashMap owned by the worker loop; the reply sender rides in the command. No shared request table, no drop guard. A dropped connection clears the map. - IPC: the supervisor holds the runner's token answers in a FuturesUnordered of its own loop; the job asks over its parent channel and waits for the parent with a signal, so no extra host call is needed to order the start. - lk-agents-net: one JobToken type, a Fetch closure instead of the Issue trait, a HashMap registry by job, and participant_token/sign_claims for tokens of other participants (key pair, else a job token). - RoomService/Telephony::of_server pick key pair or job tokens; avatar removal and warm transfer use them. The warm transfer's human agent token is made in Rust and handed to the host. - Reload in token mode: wait for registration, migrate the kept jobs, ask for each new join token; a refused job ends with the reload warning. No restoring list, no AdoptJobs. - The local thread service returns None without a key pair. - Key mode keeps closing the connection with the processes; only token mode keeps it until the processes closed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- JobContext.api uses a token provider that calls _core.participant_token when there is no key pair; create_participant_token and the avatar tokens build the claims and call the same function. - Warm transfer gets the human agent's token from Rust. - ipc/child.py and the thread service setup are back to the base, with a None check for the thread server. - AvatarStart.participant_token defaults to six hours, as access_token did. - Tests follow: the token-mode Python warm transfer test moved to Rust, the reload smoke tests drop the removed restoring behaviour. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- A kept job that launched after a reload is adopted by the worker (WorkerCommand::AdoptJob): it is active, reports its status, takes the server's termination, and is re-sent in the MigrateJobRequest of the next registration, so its job tokens are not refused after a reconnect. Both modes; a failed launch adopts nothing. - The worker connection stays open until the job processes closed, in both modes, as in 1.x. - Imports instead of inline paths in the new worker and CLI code. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Devin Review found 3 new potential issues.
6 flags not posted on this PR by your GitHub settings β view them in Devin Review. (Configure)
| Some(Message::GetRunningJobsResponse(kept)) if !kept.jobs.is_empty() => { | ||
| let jobs = kept_jobs(kept.jobs, &url, &api_key, &api_secret); | ||
| if !jobs.is_empty() { | ||
| server.reload_jobs(jobs).await.map_err(|e| HostError::new(e.to_string()))?; | ||
| } |
There was a problem hiding this comment.
π΄ Hot reload blocks credential refresh
When a kept-jobs response precedes a needed Credentials update, serve_dev_channel waits for reload before reading the update. renew_join_tokens waits for registration, so the worker keeps trying the stale token and the calls cannot resume.
Learn more
The dev channel carries both the list of calls to resume and the new registration credential. In token mode, renew_join_tokens cannot refresh a call's room token until registered_worker sees a registration. Every connection attempt reads the current worker token, but the reader cannot reach the Credentials handler while it awaits reload. The same wait also blocks running-jobs requests.
Example: A restarted worker gets one kept call while its startup token is expired. The CLI sends the replacement token next. Registration retries with the expired token while the replacement sits unread on the dev channel.
Recommended fix: Drive the initial reload concurrently with the dev-channel receive loop. Keep credential updates and running-jobs requests serviceable while reload is pending, and test with the kept-jobs response delivered before the credential that permits registration.
Was this helpful? React with π or π to provide feedback.
| Err(error) => { | ||
| log::warn!(target: lk_agents_abi::LOG_TARGET, job_id = info.job.id.as_str(), error:% = error; "job ended on reload. reload is only supported when LiveKit API key and secret are defined") | ||
| } |
There was a problem hiding this comment.
π‘ Refused reloads leave migrated jobs open
When LiveKit migrates a job but refuses its replacement token, renew_join_tokens drops the job without reporting failure. LiveKit receives no terminal status for that job from the worker.
Learn more
renew_join_tokens advertises every kept job to LiveKit before requesting its replacement token. MigrateJobs sends that wire message without registering the jobs locally. A refused job never reaches the pool and cannot report completion through the pool observer. Sending a normal status command alone is insufficient because on_job_status drops the status for jobs it does not hold.
Example: LiveKit accepts migration for AJ_refused and AJ_kept, then refuses the token for AJ_refused. The second call starts, but LiveKit never receives a failure for the first.
Recommended fix: Track advertised jobs until launch or terminal failure, then send and clear the terminal status on refusal. Extend the two-job refusal smoke test to assert that LiveKit receives JS_FAILED for the refused job.
Was this helpful? React with π or π to provide feedback.
| pub async fn renew(&self, claims: &[&str]) -> Duration { | ||
| for claims in claims { | ||
| if let Err(error) = self.token(claims).await { | ||
| // A warning: when renewals keep failing, the job loses inference and telemetry. | ||
| log::warn!(target: lk_agents_abi::LOG_TARGET, error:% = error; "failed to renew a job token, retrying"); | ||
| return RENEW_FLOOR; | ||
| } |
There was a problem hiding this comment.
π΄ Inference refusal blocks session recording
When LiveKit refuses the inference token, renew returns before requesting the independent observability token. keep_tokens_current tries inference first every time, so a persistent refusal prevents recording uploads even when LiveKit allows them.
Learn more
keep_tokens_current initializes and renews two separate credentials: inference first and observability second. A failure of the first request skips the second altogether. The Cloud upload request reads the cached observability bearer through observability_bearer, so it fails before sending when the credential never enters the cache or expires.
Example: A token-mode voice agent uses its own inference provider. LiveKit refuses inference.perform but would issue observability.write. Each renewal retries only the inference request, and the session recording is never uploaded.
Recommended fix: Attempt every due credential independently. Use the retry floor if any attempt fails, but retain successful credentials and continue scheduling their renewals. Test a persistent refusal of the first claim while the second claim succeeds.
Was this helpful? React with π or π to provide feedback.
port of #8557 for 2.0
depends on: livekit/rust-sdks#1715