diff --git a/litellm/tracing/receiver.py b/litellm/tracing/receiver.py index 71eb3764636..cbe2500493e 100644 --- a/litellm/tracing/receiver.py +++ b/litellm/tracing/receiver.py @@ -25,6 +25,7 @@ from litellm.constants import ( from litellm.integrations.clickhouse.clickhouse_client import ClickHouseClient from litellm.integrations.clickhouse.schema import ensure_schema from litellm.tracing.decode import decode_otlp +from litellm.tracing.markdown import trace_to_markdown from litellm.tracing.store import ClickHouseTraceStore from litellm.tracing.types import ( SpanDetail, @@ -121,5 +122,12 @@ class TraceReceiver: async def get_trace(self, trace_id: str, scope: TraceScope) -> Trace | None: return await self.store.get_trace(trace_id, scope) + async def get_trace_markdown(self, trace_id: str, scope: TraceScope, span_id: str | None = None) -> str | None: + """The trace (or the subtree under span_id) as Markdown, for pasting into Claude / Codex.""" + trace = await self.store.get_trace(trace_id, scope) + if trace is None: + return None + return trace_to_markdown(trace, await self.store.get_span_io(trace_id, scope), span_id) + async def get_span(self, trace_id: str, span_id: str, scope: TraceScope) -> SpanDetail | None: return await self.store.get_span(trace_id, span_id, scope)