diff --git a/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx new file mode 100644 index 00000000..3e39585d --- /dev/null +++ b/versioned_docs/version-2.0/how_to_guides/tracing/log_tool_call_traces.mdx @@ -0,0 +1,43 @@ +--- +sidebar_position: 9 +--- + +import { + CodeTabs, + PythonBlock, +} from "@site/src/components/InstructionsWithCode"; + +# Log schema-based tool call traces + +If you want to log tool calls but your tools are not real functions but tool names in a schema dictionary or JSON, then trace it with `langsmith.trace` at the point where your tool is executed or chosen. + +Wrap the tool call result (or tool execution part) with `async with langsmith.trace(name=chosen_tool, inputs=chosen_tool["args"], run_type="tool"):`. + +The following code snippets show how to log a schema-based tool call in Python. + + + +Because these are just schemas for tools and not real functions, we log the result of a tool call after the tool is chosen / executed. + + +