Skip to content

fix: serialize standard context tools#4123

Open
sysradium wants to merge 1 commit into
pipecat-ai:mainfrom
sysradium:sysradium/otel-fix
Open

fix: serialize standard context tools#4123
sysradium wants to merge 1 commit into
pipecat-ai:mainfrom
sysradium:sysradium/otel-fix

Conversation

@sysradium
Copy link
Copy Markdown
Contributor

@sysradium sysradium commented Mar 24, 2026

Guard tool extraction so that when context tools expose a standard_tools list we include both their raw form and a sanitized serialized version with name/description tuples; fall back to the previous behavior otherwise.

The same pattern is already being used in llm_setup branch.

Currently it leads to this issue:

app-1  | 2026-03-24 16:08:46.470 | DEBUG    | pipecat.pipeline.task:_wait_for_pipeline_start:748 - PipelineTask#0: StartFrame#0 reached the end of the pipeline, pipeline is now
ready.
app-1  | WARNING:root:Error extracting context tools: Object of type ToolsSchema is not JSON serializable
app-1  | ERROR:root:Error in OpenAI Realtime tracing (continuing without tracing): object of type 'ToolsSchema' has no len()
app-1  | 2026-03-24 16:08:46.478 | DEBUG    | pipecat.adapters.base_llm_adapter:from_standard_tools:127 - Retrieving the tools using the adapter: <class
'pipecat.adapters.services.open_ai_realtime_adapter.OpenAIRealtimeLLMAdapter'>
app-1  | 2026-03-24 16:08:46.599 | DEBUG    | pipecat.services.openai.realtime.llm:_create_response:1034 - Setting up conversation on OpenAI Realtime LLM service with initial
messages

@sysradium sysradium force-pushed the sysradium/otel-fix branch from 71f7959 to 4bf1f5f Compare March 24, 2026 16:18
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/utils/tracing/service_decorators.py 0.00% 10 Missing ⚠️
Files with missing lines Coverage Δ
src/pipecat/utils/tracing/service_decorators.py 12.83% <0.00%> (-0.20%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sysradium sysradium marked this pull request as ready for review March 24, 2026 16:21
@sysradium sysradium force-pushed the sysradium/otel-fix branch from 4bf1f5f to 0ad3c97 Compare May 5, 2026 16:33
@sysradium
Copy link
Copy Markdown
Contributor Author

sysradium commented May 5, 2026

Still relevant:
image

@sysradium
Copy link
Copy Markdown
Contributor Author

@markbackman any possibility to look into this? As I have to maintain a fork of pipcat to be able to see langsmith traces :(

@markbackman
Copy link
Copy Markdown
Contributor

Could we use the adapter here instead of manually rebuilding the tool list?

In this path context_tools can be a ToolsSchema, and OpenAI Realtime ultimately sends tools via the adapter’s provider-format conversion. This manual serialization only looks at standard_tools, so it can miss custom_tools for AdapterType.OPENAI and may drift from the actual payload sent to the provider.

Something like starting from self.get_llm_adapter().from_standard_tools(context_tools) would keep tracing aligned with the real OpenAI Realtime tool format, including custom/provider-specific tools, and avoid adding provider-specific serialization logic in tracing.

@markbackman markbackman self-requested a review May 7, 2026 23:37
Guard tool extraction so that when context tools expose a `standard_tools` list we include both their raw form and a sanitized serialized version with name/description tuples; fall back to the previous behavior otherwise.
@sysradium sysradium force-pushed the sysradium/otel-fix branch from 0ad3c97 to 32ff5a0 Compare May 11, 2026 12:10
@sysradium
Copy link
Copy Markdown
Contributor Author

sysradium commented May 11, 2026

Hey @markbackman,
Many thanks for the comments. Would something of this sort work?
I added a defensive getattr in there still. I think it should work.

@sysradium
Copy link
Copy Markdown
Contributor Author

@markbackman bump

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.

2 participants