feat(inference): introduce XAIModels type and enhance LLMModels with reasoning support#1241
Merged
toubatbrian merged 4 commits intomainfrom Apr 15, 2026
Merged
feat(inference): introduce XAIModels type and enhance LLMModels with reasoning support#1241toubatbrian merged 4 commits intomainfrom
toubatbrian merged 4 commits intomainfrom
Conversation
…reasoning support - Added XAIModels type to support new AI models. - Updated LLMModels to include XAIModels. - Implemented logic to drop unsupported parameters for specific models. - Enhanced extra content handling in OpenAI provider to filter additional keys. - Updated AgentActivity to include generated extra data in messages.
🦋 Changeset detectedLatest commit: 155a164 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
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
approved these changes
Apr 15, 2026
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.
Description
Add XAI (Grok) model support to the LiveKit inference layer. This introduces the
XAIModelstype, strips unsupported parameters for XAI reasoning models, generalizes the provider-specificextra_contenthandling (previously Google-only) to support multiple providers (Google, LiveKit, XAI), and propagates LLM-generated extra metadata through to chat context messages.Changes Made
agents/src/inference/llm.ts: AddedXAIModelstype with 5 Grok model variants. AddeddropUnsupportedParamsfunction that strips parameters incompatible with reasoning models (OpenAI o-series, GPT-5, XAI Grok reasoning). XAI reasoning models only needpresence_penalty,frequency_penalty, andstopstripped (they still supporttemperature/top_p). Also stripsreasoning_effortfrom GPT-5.2/5.4 when tools are present. ApplieddropUnsupportedParamsto the request options inLLMStream.run().agents/src/inference/index.ts: Exported the newXAIModelstype.agents/src/llm/provider_format/openai.ts: Replaced the Google-specificgetGoogleExtrahelper with a generalizedfilterExtrafunction using an allowlist of provider keys (google,livekit,xai). AppliedfilterExtrato tool calls, function call items, and message items when serializing to OpenAI provider format.agents/src/voice/generation.ts: AddedgeneratedExtrafield to_LLMGenerationDataand accumulatechunk.delta.extrafrom the LLM stream viaObject.assign.agents/src/voice/agent_activity.ts: PassgeneratedExtraas theextrafield on assistantChatMessagecreation for both interrupted and non-interrupted playout paths.Pre-Review Checklist
Testing
Tested using https://agents-playground.livekit.io/ and locally running agent-gateway
restaurant_agent.tsandrealtime_agent.tswork properly (for major changes)Additional Notes
dropUnsupportedParamslogic andUNSUPPORTED_PARAMSmap are a direct port from the Pythonagentsrepo (livekit-agents/livekit/agents/inference/llm.py), maintaining parity across SDKs.Object.assignshallow merge forgeneratedExtramatches the Python SDK'sdict.update()semantics — this is fine given providers send extra metadata once per stream rather than progressively across chunks.dropUnsupportedParamsorfilterExtra. Consider adding unit tests for prefix matching edge cases (e.g., ensuringgrok-4-1-fast-non-reasoningdoes not match the reasoning entry).Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.