diff --git a/docs/tracing/faq/querying_traces.mdx b/docs/tracing/faq/querying_traces.mdx index 099f01dd..e9867745 100644 --- a/docs/tracing/faq/querying_traces.mdx +++ b/docs/tracing/faq/querying_traces.mdx @@ -502,3 +502,95 @@ This type of query is useful if you want to extract a specific run conditional o ]} groupId="client-language" /> + +## Advanced Examples + +#### Exporting flattened trace view with child tool usage + +The following Python example demonstrates how to export a flattened view of traces, including information on the tools (from nested runs) used by the agent within each trace. +This can be used to analyze the behavior of your agents across multiple traces. + +This example queries all tool runs within a specified number of days and groups them by their parent (root) run ID. It then fetches the relevant information for each root run, such as the run name, inputs, outputs, and combines that information with the child run information. + +To optimize the query, the example: + +1. Selects only the necessary fields when querying tool runs to reduce query time. +2. Fetches root runs in batches while processing tool runs concurrently. + +