fix timestamps in tuner accumelator (#335)

* fix timestamps in tuner accumelator

* chore: refactor strip_thought_ids_from_messages

---------

Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
Mohamed-Mamdouh 2026-05-21 03:13:50 +01:00 committed by GitHub
parent af66372b65
commit 67479e98fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 54 additions and 3 deletions

View file

@ -0,0 +1,42 @@
from __future__ import annotations
from copy import deepcopy
from pipecat.utils.context.message_sanitization import (
strip_thought_from_id,
strip_thought_ids_from_messages,
)
def test_strip_thought_from_id():
assert strip_thought_from_id("call_123__thought__abc") == "call_123"
assert strip_thought_from_id("call_123") == "call_123"
assert strip_thought_from_id(None) is None
def test_strip_thought_ids_from_messages_does_not_mutate_input():
messages = [
{
"role": "assistant",
"tool_calls": [
{
"id": "call_1__thought__hidden",
"type": "function",
"function": {"name": "lookup", "arguments": "{}"},
}
],
},
{
"role": "tool",
"tool_call_id": "call_1__thought__hidden",
"content": '{"status":"ok"}',
},
]
original = deepcopy(messages)
cleaned = strip_thought_ids_from_messages(messages)
assert messages == original
assert cleaned is not messages
assert cleaned[0]["tool_calls"][0]["id"] == "call_1"
assert cleaned[1]["tool_call_id"] == "call_1"