@yagni-app/code-staging 1.0.7-staging.1265.1 → 1.0.7-staging.1267.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -183,14 +183,20 @@ prefix instead of `claude_code`:
183
183
  `yagni_code.llm_request` and `yagni_code.tool`, carrying both the flat
184
184
  Claude Code attributes (`model`, `input_tokens`, `cost_usd`, `tool_name`)
185
185
  and the OTel GenAI conventions (`gen_ai.*`) that LLM-observability
186
- products read. The two count tokens differently on purpose: the flat
186
+ products read. `gen_ai.operation.name` classifies each span the way those
187
+ products expect: `invoke_agent` on the interaction root, `chat` on the LLM
188
+ request, `execute_tool` on tool spans (the turn span has no semconv
189
+ operation and is left unset). The two count tokens differently on purpose: the flat
187
190
  `input_tokens` / `cache_read_tokens` / `cache_creation_tokens` are disjoint,
188
191
  exactly as Claude Code reports them, while `gen_ai.usage.input_tokens`
189
192
  follows the semconv and includes the cached tokens, with
190
193
  `gen_ai.usage.cache_read.input_tokens` and
191
194
  `gen_ai.usage.cache_write.input_tokens` as subsets of it.
192
195
  `gen_ai.cost.estimated_total` carries the same sell-rate cost as `cost_usd`
193
- so vendor cost views work for the opaque tier id.
196
+ so vendor cost views work for the opaque tier id. It is an integer in
197
+ nanodollars (`cost_usd * 1e9`): Datadog reads that attribute unscaled into
198
+ its nanodollar cost metric, so a dollar value shows up a billion times too
199
+ small.
194
200
  - **Metrics:** `yagni_code.session.count`, `token.usage` (by `type` and
195
201
  `model`), `cost.usage`, `lines_of_code.count`, `commit.count`,
196
202
  `pull_request.count`, `code_edit_tool.decision`, `active_time.total`.
@@ -52,7 +52,9 @@ export declare const ATTR_GEN_AI_CACHE_READ_TOKENS_LEGACY = "gen_ai.usage.cache_
52
52
  export declare const ATTR_GEN_AI_CACHE_CREATION_TOKENS_LEGACY = "gen_ai.usage.cache_creation_input_tokens";
53
53
  /** The one cost attribute Datadog's OTLP ingestion documents. Carries the
54
54
  * same sell-rate figure as the flat `cost_usd`, so the vendor Cost view
55
- * populates for the opaque tier id, which no vendor price table knows. */
55
+ * populates for the opaque tier id, which no vendor price table knows.
56
+ * Unit is NANODOLLARS (integer), not dollars: Datadog copies the value
57
+ * unscaled into its nanodollar cost metric. */
56
58
  export declare const ATTR_GEN_AI_COST_ESTIMATED_TOTAL = "gen_ai.cost.estimated_total";
57
59
  export declare const ATTR_GEN_AI_CONVERSATION_ID = "gen_ai.conversation.id";
58
60
  export declare const ATTR_GEN_AI_AGENT_NAME = "gen_ai.agent.name";
@@ -54,7 +54,9 @@ export const ATTR_GEN_AI_CACHE_READ_TOKENS_LEGACY = "gen_ai.usage.cache_read_inp
54
54
  export const ATTR_GEN_AI_CACHE_CREATION_TOKENS_LEGACY = "gen_ai.usage.cache_creation_input_tokens";
55
55
  /** The one cost attribute Datadog's OTLP ingestion documents. Carries the
56
56
  * same sell-rate figure as the flat `cost_usd`, so the vendor Cost view
57
- * populates for the opaque tier id, which no vendor price table knows. */
57
+ * populates for the opaque tier id, which no vendor price table knows.
58
+ * Unit is NANODOLLARS (integer), not dollars: Datadog copies the value
59
+ * unscaled into its nanodollar cost metric. */
58
60
  export const ATTR_GEN_AI_COST_ESTIMATED_TOTAL = "gen_ai.cost.estimated_total";
59
61
  export const ATTR_GEN_AI_CONVERSATION_ID = "gen_ai.conversation.id";
60
62
  export const ATTR_GEN_AI_AGENT_NAME = "gen_ai.agent.name";
@@ -168,9 +168,13 @@ export class SessionTelemetry {
168
168
  this.interactionSequence += 1;
169
169
  const promptId = randomUUID();
170
170
  const promptLength = typeof prompt === "string" ? prompt.length : 0;
171
+ // `invoke_agent` is the semconv operation for the root of an agent run.
172
+ // Without it Datadog files the trace as a generic workflow, flags an
173
+ // instrumentation issue on the span, and leaves it out of per-agent views.
171
174
  const span = this.tracer.startSpan(SPAN_INTERACTION, {
172
175
  attributes: {
173
176
  ...this.spanAttributes(),
177
+ [ATTR_GEN_AI_OPERATION_NAME]: "invoke_agent",
174
178
  user_prompt_length: promptLength,
175
179
  "interaction.sequence": this.interactionSequence,
176
180
  "prompt.id": promptId,
@@ -301,8 +305,11 @@ export class SessionTelemetry {
301
305
  span.setAttribute(ATTR_GEN_AI_CACHE_WRITE_TOKENS, cacheCreation);
302
306
  span.setAttribute(ATTR_GEN_AI_CACHE_READ_TOKENS_LEGACY, cacheRead);
303
307
  span.setAttribute(ATTR_GEN_AI_CACHE_CREATION_TOKENS_LEGACY, cacheCreation);
308
+ // Datadog ingests this attribute in nanodollars (its `ml_obs.span.llm.total.cost`
309
+ // unit); sending dollars renders a $0.012 call as 1.2e-9 cents. Verified against
310
+ // a live span on 2026-09-02. `cost_usd` below stays in dollars.
304
311
  if (costKnown)
305
- span.setAttribute(ATTR_GEN_AI_COST_ESTIMATED_TOTAL, cost);
312
+ span.setAttribute(ATTR_GEN_AI_COST_ESTIMATED_TOTAL, Math.round(cost * 1_000_000_000));
306
313
  span.setAttribute("input_tokens", input);
307
314
  span.setAttribute("output_tokens", output);
308
315
  span.setAttribute("cache_read_tokens", cacheRead);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.0.7-staging.1265.1",
3
+ "version": "1.0.7-staging.1267.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -58,5 +58,5 @@
58
58
  "turndown": "^7.2.4",
59
59
  "typebox": "^1.3.15"
60
60
  },
61
- "yagniSourceSha": "996a0867c1bc4859705f5aca33cb5d4e67bd154b"
61
+ "yagniSourceSha": "594ebbbef9ba1c2233382184dad54d1e81a3bc0f"
62
62
  }