Skip to content

Conversation

@russellmartin-livekit
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Dec 4, 2025

CLA assistant check
All committers have signed the CLA.

@russellmartin-livekit russellmartin-livekit marked this pull request as ready for review December 4, 2025 18:00
@theomonnom
Copy link
Member

@russellmartin-livekit
Copy link
Contributor Author

russellmartin-livekit commented Dec 5, 2025

I don't see extra_content from the ChoiceDelta: https://github.com/openai/openai-python/blob/dc7602151b9042891ccd5042c7be3881337368e5/src/openai/types/chat/chat_completion_chunk.py#L59

My testing shows it working

OpenAI SDK's Pydantic models use extra='allow' 1, which preserves any additional fields from the JSON response. We access it via getattr(delta, "extra_content", None). This allows providers to include additional metadata like thought signatures.

https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/llm/chat_context.py#L158

Context around google though signatures: https://ai.google.dev/gemini-api/docs/thought-signatures?authuser=1#openai

Copy link
Member

@theomonnom theomonnom left a comment

Choose a reason for hiding this comment

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

Otherwise lgtm!

name: str
arguments: str
call_id: str
extra_content: dict[str, Any] | None = None
Copy link
Member

Choose a reason for hiding this comment

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

I would still name this extra IMO

Suggested change
extra_content: dict[str, Any] | None = None
extra: dict[str, Any] | None = None

role: ChatRole | None = None
content: str | None = None
tool_calls: list[FunctionToolCall] = Field(default_factory=list)
extra_content: dict[str, Any] | None = None
Copy link
Member

Choose a reason for hiding this comment

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

Same here

Suggested change
extra_content: dict[str, Any] | None = None
extra: dict[str, Any] | None = None

- Introduced `extra_content` field in `FunctionToolCall`, `ChoiceDelta`, and `ChatMessage` models to accommodate provider-specific data (e.g., Google thought signatures).
- Updated `LLMStream` and related methods to handle `extra_content` during tool calls and message processing.
- Enhanced serialization in OpenAI provider format to include `extra_content` where applicable.
- Improved grouping logic for function calls to utilize `group_id` when available for better parallel processing.
@russellmartin-livekit russellmartin-livekit force-pushed the rm/adding-extra-content-to-openai-llm branch from 069fcf3 to e46596f Compare December 9, 2025 23:38
@davidzhao davidzhao merged commit f4b0f0a into main Dec 18, 2025
19 of 20 checks passed
@davidzhao davidzhao deleted the rm/adding-extra-content-to-openai-llm branch December 18, 2025 06:52
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.

6 participants