Skip to content

feat(semconv): add cost, time-to-first-token and coding-agent attributes - #605

Merged
nik13 merged 1 commit into
devfrom
feat/semconv-agent-attributes
Nov 6, 2026
Merged

nik13 merged 1 commit into
devfrom
feat/semconv-agent-attributes

Conversation

@nik13

@nik13 nik13 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Why

Coding-agent traces in Future AGI showed 0 tokens, $0 cost and no time-to-first-token, even when the agent reported them. The agent plugins wrote these values under names the backend never reads, because fi-semantic-conventions did not define the names the backend does read.

What

Adds the missing names in TypeScript, Python, Java, C# and the five Go modules. Nothing existing is renamed or removed.

Key(s) Read by the backend at
gen_ai.cost.total / .input / .output fi-collector/pkg/adapter/adapter.go (costTotalKeys), futureagi/tracer/utils/otel.py (COST_TOTAL)
gen_ai.server.time_to_first_token futureagi/tracer/utils/otel.py (TIME_TO_FIRST_TOKEN), services/clickhouse/query_builders/dashboard.py
fi.usage.scope / fi.usage.contribution / fi.cost.kind trace-detail totals (spans with no usage contribution are excluded), so turn-level usage counts once
fi.agent.* (fidelity, timing, outcome, usage plan and additivity, cost source, gap, transport, source call id, summaries, tags, event) provenance attributes the coding-agent plugins already send; documented here as a contract

Python also gets the SpanAttributes.TOOL_CALL_ID alias, which previously existed only on ToolCallAttributes.

Open question: TTFT unit

The dashboard labels gen_ai.server.time_to_first_token in milliseconds. The OTel GenAI spec and our agentcc gateway (otel.go) use seconds. The constant's documentation records this mismatch; the backend needs to pick one unit.

Tests

Every language has a wire-contract test. All of them ran in an isolated E2B sandbox:

Suite Result
TypeScript conventions 103 / 103
Coding-agent core, patched to use these constants full suite pass
Python 32 / 32
Java contract test pass
Go (5 modules) pass
C# 12 / 12

Follow-up

The coding-agent core switches to these constants in the agent-plugins integration branch. That switch:

  • writes cost to gen_ai.cost.total;
  • writes TTFT to gen_ai.server.time_to_first_token;
  • sets tool.name and tool_call.id on tool spans;
  • counts turn tokens once: on the last generation when there is one, otherwise on the turn root.

🤖 Generated with Claude Code

Adds the attribute names Future AGI already reads but the conventions did
not define, so coding-agent traces show cost, TTFT, tool names and token
totals:

- gen_ai.cost.total / gen_ai.cost.input / gen_ai.cost.output (read by
  fi-collector pkg/adapter costTotalKeys and tracer/utils/otel.py).
- gen_ai.server.time_to_first_token. Future AGI's dashboard reads it as
  milliseconds; the OTel GenAI spec and the agentcc gateway use seconds.
  The mismatch is documented on the constant as a backend follow-up.
- fi.usage.scope / fi.usage.contribution / fi.cost.kind, which the trace
  detail totals already honour, so turn-level usage counts exactly once.
- The fi.agent.* provenance group used by the coding-agent core
  (fidelity, timing, outcome, usage plan/additivity, cost source, gaps,
  transport, source call id, non-additive summaries, tags, events).
- SpanAttributes.TOOL_CALL_ID alias in Python.

Same keys in TypeScript, Python, Java, C# and the five Go modules, each
with a wire-contract test. No existing constant is renamed or removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nik13
nik13 merged commit 78ae25e into dev Nov 6, 2026
335 checks passed
@nik13
nik13 deleted the feat/semconv-agent-attributes branch November 6, 2026 23:44
nik13 added a commit that referenced this pull request Nov 7, 2026
- @traceai/auto 0.1.0: zero-code Node auto-instrumentation (adapters off by default), with bundled third-party notices.
- @traceai/fi-core 1.2.0: content privacy runtime, typed session.id exported with setSession, base64 images never exported; non-HTTP(S) URLs in text are kept.
- fi-instrumentation-otel 1.3.0: base64 image cap defaults to 0; semantic conventions from #605 listed in the changelog.
- Package fixes: openai 0.1.17, langchain 0.1.6, vercel 0.1.4, genkit 0.1.1, strands 0.1.3.
- Release pipeline: NuGet publication stays off.
nik13 added a commit that referenced this pull request Nov 10, 2026
…14 and Java 1.0.3

Core 1.3.1 also ships the PII-redaction scoping fixes (#195/#244) that sat under
Unreleased, and the 1.3.0 heading gets its release date. OpenAI 0.1.14 also
ships the Azure metadata (#154), Baseten (#541), Azure Government (#502),
OpenRouter host (#547), full multi-message input (#245) and exhausted-stream
changes. Java 1.0.3 also ships #543 and #605. Notes the remaining blank
OTEL-env Authorization limitation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nik13 added a commit that referenced this pull request Nov 10, 2026
… traceAI-langchain 0.2.2, Java 1.0.3 (#636)

* chore(release): bump core, OpenAI, LangChain and Java patch versions

Synchronize runtime versions, reactor parent references and release changelogs for #155, #348, #397, #393 and #425. Dependency floors are unchanged.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* chore(release): list every change shipping in core 1.3.1, OpenAI 0.1.14 and Java 1.0.3

Core 1.3.1 also ships the PII-redaction scoping fixes (#195/#244) that sat under
Unreleased, and the 1.3.0 heading gets its release date. OpenAI 0.1.14 also
ships the Azure metadata (#154), Baseten (#541), Azure Government (#502),
OpenRouter host (#547), full multi-message input (#245) and exhausted-stream
changes. Java 1.0.3 also ships #543 and #605. Notes the remaining blank
OTEL-env Authorization limitation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant