Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-function-call-extra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-protocol": patch
---

Remove `FunctionCall.extra`: livekit-agents 1.7.0 to 1.8.8 fail to encode the session history with it.
56 changes: 56 additions & 0 deletions .github/workflows/regression-agents-session-history.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Regression - livekit-agents releases encode their session history

# Every published livekit-agents release must still encode its session history with a
# livekit-protocol 1.x build: those releases accept livekit-protocol<2 and are already deployed.

on:
pull_request:
branches:
- main
paths:
- livekit-protocol/**
- tests/protocol/**
- .github/workflows/regression-agents-session-history.yml
workflow_dispatch:

jobs:
regression-agents-session-history:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
submodules: true

- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: "3.12"

- name: Build livekit-protocol
run: uv build --wheel livekit-protocol -o dist

- name: Encode a session history with every livekit-agents release
run: |
set -euo pipefail
wheel=$(ls dist/livekit_protocol-*.whl)
case "$(basename "$wheel")" in
livekit_protocol-1.*) ;;
*) echo "livekit-protocol 2+ cannot reach livekit-agents 1.x"; exit 0 ;;
esac
versions=$(curl -sf https://pypi.org/pypi/livekit-agents/json | uvx --with packaging python -c '
import json, sys
from packaging.version import Version
releases = json.load(sys.stdin)["releases"]
print(" ".join(v for v in sorted(releases, key=Version)
if releases[v] and not Version(v).is_prerelease
and Version("1.7.0") <= Version(v) < Version("2")))')
failed=""
for v in $versions; do
uv venv -q --allow-existing "venv-$v"
VIRTUAL_ENV="venv-$v" uv pip install -q "livekit-agents==$v"
VIRTUAL_ENV="venv-$v" uv pip install -q --no-deps --reinstall "$wheel"
"venv-$v/bin/python" tests/protocol/regression_agents_session_history.py || failed="$failed $v"
done
if [ -n "$failed" ]; then
echo "::error::livekit-agents releases that cannot encode a session history:$failed"
exit 1
fi
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment on lines +18 to +56
296 changes: 146 additions & 150 deletions livekit-protocol/livekit/protocol/agent_pb/agent_session.py

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions livekit-protocol/livekit/protocol/agent_pb/agent_session.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

188 changes: 94 additions & 94 deletions livekit-protocol/livekit/protocol/agent_simulation.py

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions livekit-protocol/livekit/protocol/agent_simulation.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions tests/protocol/regression_agents_session_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Regression: livekit-protocol 1.1.28 added FunctionCall.extra, and livekit-agents 1.7.0 to 1.8.8
failed to upload the session history (TypeError: bad argument type for built-in operation).

Encodes a session history the way an installed livekit-agents release uploads it.

livekit-agents 1.7.0 to 1.8.8 fill every field the installed protocol declares on a chat item
from the attribute of the same name, so a new field can break releases already deployed.
Run with one livekit-agents release and the livekit-protocol build under test installed.
"""

from importlib.metadata import version

from livekit.agents import llm

items = [
llm.ChatMessage(role="user", content=["hi", "there"], extra={"lk.redacted": True}),
llm.FunctionCall(
call_id="call_1",
name="lookup",
arguments="{}",
extra={
"google": {"thought_signature": "c2ln"},
"__livekit_agents_tool_non_blocking": True,
},
),
llm.FunctionCallOutput(call_id="call_1", name="lookup", output="ok", is_error=False),
]
llm.ChatContext(items).to_proto().SerializeToString()
print(
f"livekit-agents {version('livekit-agents')} with livekit-protocol {version('livekit-protocol')}: ok"
)
Loading