Skip to content

Commit 71f7959

Browse files
committed
fix: serialize standard context tools
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.
1 parent b45dcb1 commit 71f7959

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/pipecat/utils/tracing/service_decorators.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,25 @@ async def wrapper(self, *args, **kwargs):
995995
try:
996996
context_tools = getattr(self._context, "tools", None)
997997
if context_tools and not operation_attrs.get("tools"):
998-
operation_attrs["tools"] = context_tools
999-
operation_attrs["tools_serialized"] = json.dumps(
1000-
context_tools
1001-
)
998+
if hasattr(context_tools, "standard_tools"):
999+
tools_list = context_tools.standard_tools
1000+
operation_attrs["tools"] = tools_list
1001+
operation_attrs["tools_serialized"] = json.dumps(
1002+
[
1003+
{
1004+
"name": getattr(t, "name", "unknown"),
1005+
"description": getattr(
1006+
t, "description", ""
1007+
),
1008+
}
1009+
for t in tools_list
1010+
]
1011+
)
1012+
else:
1013+
operation_attrs["tools"] = context_tools
1014+
operation_attrs["tools_serialized"] = json.dumps(
1015+
context_tools
1016+
)
10021017
except Exception as e:
10031018
logging.warning(f"Error extracting context tools: {e}")
10041019

0 commit comments

Comments
 (0)