| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Nitesh Dhanpal <NiteshDhanpal@users.noreply.github.com> Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
…#455) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…in span data Implements the trace data-source-ref convention (SGP-6513): tools declare which data sources they touch — statically, via an args resolver, or by name-keyed registry for MCP/unowned tools — and every tool-span path merges the resolved refs into span data under sgp.lineage.refs, which the SGP tracing processor already ships as span metadata. Capture is decoupled from lineage derivation so agents instrument from day one and edges backfill later. Also stamps __agent_version__ from a new AGENT_VERSION env var (same mechanism as __agent_name__), completing the trace-side join-key set: span -> agent version snapshot is the runtime half of SGP-6132. Convention spec: scaleapi packages/sgp-lineage/docs/specs/ 2026-07-22-sgp-6513-trace-data-source-ref-convention.md (PR #153026). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Implements the SDK half of the trace data-source-ref convention (SGP-6513; convention spec in scaleapi#153026): tools declare which data sources they actually touch, and the refs land in span data under sgp.lineage.refs as lineage coordinates. The SGP tracing processor already ships span data as sgp-traces span metadata, so refs are immediately filterable via the spans-search extra_metadata DSL — no schema, processor, or service changes. Capture is decoupled from lineage derivation: agents instrument from day one and graph edges backfill later from materialized traces.
Surface (agentex.lib.adk.lineage, implementation in core/tracing/lineage.py)
DataSourceRef validates URI-form namespaces per the lineage namespace conventions and rejects payload-shaped values; refs deduplicate by (namespace, name, version, role). Resolver failures are logged and swallowed — ref capture never breaks a tool call or its tracing.
Where refs get stamped
Agent build version stamp (__agent_version__)
The processor already env-stamps __agent_name__ / __agent_id__ into every span; this adds __agent_version__ from a new optional AGENT_VERSION env var (image tag or git sha, set by the deployment). This completes the trace-side join-key set — span → exact agent-version snapshot instead of a temporal join against deploy history — the runtime half of SGP-6132. Unset means no stamp, so nothing changes until a deployment wires the env var; the deploy-chart wiring is a follow-up in the deployment repo.
Deliberately deferred
MCP-server-side ref attachment via result _meta with agent-side harvest (the exact-grain path for server-private dynamic sources) — needs a cross-process contract; name-keyed agent-side declaration covers current consumers.
Tests
tests/lib/core/tracing/test_lineage.py (validation, registry, decorator both placements, item resolution, merge/dedupe), tests/lib/core/harness/test_tracer_lineage.py (SpanTracer stamps refs on tool spans, leaves reasoning/unregistered spans untouched), and TestSourceStamps in the SGP processor suite (__agent_version__ stamped when set, omitted when unset). Full harness + tracing + temporal + adk suites green locally; ruff check / ruff format clean.
🧑💻🤖 — posted via Claude Code
Greptile Summary
This PR implements the SDK side of the trace data-source-ref convention (SGP-6513): tools declare which data sources they touch via DataSourceRef / @data_sources / register_tool_sources, and the refs are stamped into span data under sgp.lineage.refs at every capture point. It also adds AGENT_VERSION stamping to the SGP tracing processor from a new optional AGENT_VERSION env var.
Confidence Score: 5/5
Safe to merge; the change is additive and self-contained — ref capture never affects tool execution or tracing correctness, and the new env var is a no-op until wired in deployment.
All integration points follow the same defensive pattern: resolver failures are logged and swallowed, refs are only merged when non-empty, and the harness import is guarded so the module stays importable without optional tracing deps. The only finding is a misleading inline comment in the regex.
Files Needing Attention: No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["@data_sources decorator\nor register_tool_sources()"] --> R[("_tool_sources\nprocess-wide registry")] B["lineage.record(span, refs)"] --> M subgraph Capture["Ref capture sites"] C["SpanTracer\nOpenSpan(kind='tool')"] -->|resolve_refs| M D["OpenAIService\nrun_agent*"] -->|resolve_refs_from_items| M E["SyncStreamingModel\nget_response / stream_response"] -->|resolve_refs_from_items| M F["TemporalStreamingModel\nstream_response"] -->|resolve_refs_from_items| M end R -->|lookup by tool name| C R -->|lookup by tool name| D R -->|lookup by tool name| E R -->|lookup by tool name| F M["merge_refs_into_data()\ndedup by (ns, name, ver, role)"] --> S["span.data\nsgp.lineage.refs"] subgraph SGP["SGP processor"] G["_add_source_to_span"] -->|"__agent_version__\n(AGENT_VERSION env var)"| S endReviews (3): Last reviewed commit: "feat(lineage): capture tool data-source ..." | Re-trigger Greptile