You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 75637f5
Browse filesBrowse the repository at this point in the historyBrowse files
fix(ag2): alias cache tokens to the keys Future AGI reads
AG2's cache_read_input_tokens / cache_creation_input_tokens were aliased to
the dotted semconv names gen_ai.usage.cache_read.input_tokens /
cache_creation.input_tokens. Future AGI's attribute registry reads
gen_ai.usage.cache_read_tokens / cache_write_tokens and never the dotted
names, so cache counts never reached it. Alias to those keys instead (the
originals stay). A record_usage span that repeats a chat span's usage moves
them to ag2.usage.* with the token counts, so each call carries them once.
Checked live: an AnthropicConfig agent on CLIProxy (AG2's default prompt
caching) stored cache_read_tokens 9747 and cache_write_tokens 9749 on its
chat spans in ClickHouse, and ag2.usage.* on the record_usage spans.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Future AGI reads the cache counts from `gen_ai.usage.cache_read_tokens` /
44
+
`gen_ai.usage.cache_write_tokens`, not from the dotted OpenTelemetry
45
+
spellings (`gen_ai.usage.cache_read.input_tokens`). On a `record_usage`
46
+
span that repeats a chat span's usage (see below), they move to
47
+
`ag2.usage.*` with the token counts.
48
+
42
49
- applies `TraceConfig` (`FI_HIDE_INPUTS`, `FI_HIDE_OUTPUTS`, ...) as a
43
50
second content gate.
44
51
@@ -158,7 +165,7 @@ not copied to `input.value` / `output.value` either.
158
165
| Span kind |`AGENT`, `LLM`, `TOOL` from `gen_ai.operation.name`|`await_human_input` and `record_usage` spans get no kind (see below) |
159
166
| Model |`gen_ai.request.model`, `gen_ai.response.model` pass through | When AG2 did not set them |
160
167
| Provider |`gen_ai.provider.name` from `provider_name` or the model response | When neither is known |
161
-
| Tokens |`gen_ai.usage.input_tokens` / `output_tokens` pass through; cache and thinking tokens are aliased and kept | When the usage field is zero/absent. Cost is not emitted |
168
+
| Tokens |`gen_ai.usage.input_tokens` / `output_tokens` pass through; cache tokens are aliased to `gen_ai.usage.cache_read_tokens` / `cache_write_tokens`and thinking tokens to `gen_ai.usage.reasoning.output_tokens`, originals kept | When the usage field is zero/absent. Cost is not emitted |
162
169
| Session | Not emitted by AG2. `session.id` from traceAI's `using_session` / `using_attributes` context, which wins over a static value; or set it yourself: `setup(..., span_attributes={"session.id": "..."})`| When neither is set |
163
170
| User, metadata, tags |`user.id`, `metadata`, `tag.tags` (and the other traceAI context keys) from `using_user` / `using_metadata` / `using_tags` / `using_attributes`; a key AG2 or `span_attributes` already set is not overridden | When the context does not set them |
164
171
| Tools |`gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.tool.type`; arguments/result only with `capture_content=True`||
0 commit comments