|
27 | 27 | result, |
28 | 28 | usage as _usage, |
29 | 29 | ) |
30 | | -from ._utils import AbstractSpan |
31 | 30 | from .models.instrumented import InstrumentationSettings, InstrumentedModel |
32 | 31 | from .result import FinalResult, OutputDataT, StreamedRunResult, ToolOutput |
33 | 32 | from .settings import ModelSettings, merge_model_settings |
@@ -1683,14 +1682,14 @@ async def main(): |
1683 | 1682 | ] |
1684 | 1683 |
|
1685 | 1684 | @overload |
1686 | | - def _span(self, *, required: Literal[False]) -> AbstractSpan | None: ... |
| 1685 | + def _traceparent(self, *, required: Literal[False]) -> str | None: ... |
1687 | 1686 | @overload |
1688 | | - def _span(self) -> AbstractSpan: ... |
1689 | | - def _span(self, *, required: bool = True) -> AbstractSpan | None: |
1690 | | - span = self._graph_run._span(required=False) # type: ignore[reportPrivateUsage] |
1691 | | - if span is None and required: # pragma: no cover |
1692 | | - raise AttributeError('Span is not available for this agent run') |
1693 | | - return span |
| 1687 | + def _traceparent(self) -> str: ... |
| 1688 | + def _traceparent(self, *, required: bool = True) -> str | None: |
| 1689 | + traceparent = self._graph_run._traceparent(required=False) # type: ignore[reportPrivateUsage] |
| 1690 | + if traceparent is None and required: # pragma: no cover |
| 1691 | + raise AttributeError('No span was created for this agent run') |
| 1692 | + return traceparent |
1694 | 1693 |
|
1695 | 1694 | @property |
1696 | 1695 | def ctx(self) -> GraphRunContext[_agent_graph.GraphAgentState, _agent_graph.GraphAgentDeps[AgentDepsT, Any]]: |
@@ -1729,7 +1728,7 @@ def result(self) -> AgentRunResult[OutputDataT] | None: |
1729 | 1728 | graph_run_result.output.tool_name, |
1730 | 1729 | graph_run_result.state, |
1731 | 1730 | self._graph_run.deps.new_message_index, |
1732 | | - self._graph_run._span(required=False), # type: ignore[reportPrivateUsage] |
| 1731 | + self._traceparent(required=False), |
1733 | 1732 | ) |
1734 | 1733 |
|
1735 | 1734 | def __aiter__( |
@@ -1847,16 +1846,16 @@ class AgentRunResult(Generic[OutputDataT]): |
1847 | 1846 | _output_tool_name: str | None = dataclasses.field(repr=False) |
1848 | 1847 | _state: _agent_graph.GraphAgentState = dataclasses.field(repr=False) |
1849 | 1848 | _new_message_index: int = dataclasses.field(repr=False) |
1850 | | - _span_value: AbstractSpan | None = dataclasses.field(repr=False) |
| 1849 | + _traceparent_value: str | None = dataclasses.field(repr=False) |
1851 | 1850 |
|
1852 | 1851 | @overload |
1853 | | - def _span(self, *, required: Literal[False]) -> AbstractSpan | None: ... |
| 1852 | + def _traceparent(self, *, required: Literal[False]) -> str | None: ... |
1854 | 1853 | @overload |
1855 | | - def _span(self) -> AbstractSpan: ... |
1856 | | - def _span(self, *, required: bool = True) -> AbstractSpan | None: |
1857 | | - if self._span_value is None and required: # pragma: no cover |
1858 | | - raise AttributeError('Span is not available for this agent run') |
1859 | | - return self._span_value |
| 1854 | + def _traceparent(self) -> str: ... |
| 1855 | + def _traceparent(self, *, required: bool = True) -> str | None: |
| 1856 | + if self._traceparent_value is None and required: # pragma: no cover |
| 1857 | + raise AttributeError('No span was created for this agent run') |
| 1858 | + return self._traceparent_value |
1860 | 1859 |
|
1861 | 1860 | @property |
1862 | 1861 | @deprecated('`result.data` is deprecated, use `result.output` instead.') |
|
0 commit comments