Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/agent/hooks/conductor_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ async def wrap_model_call(
tokens_in=_counter(usage.get("input")),
tokens_out=_counter(usage.get("output")),
cache_read_tokens=_counter(usage.get("cache")),
cache_write_tokens=_counter(usage.get("cache_write")),
reasoning_tokens=_counter(usage.get("thoughts")),
tool_use_tokens=_counter(usage.get("tool_use")),
estimated_cost_usd_micros=_cost_micros(usage),
Expand Down Expand Up @@ -267,6 +268,7 @@ def _record(
tokens_in: int = 0,
tokens_out: int = 0,
cache_read_tokens: int = 0,
cache_write_tokens: int = 0,
reasoning_tokens: int = 0,
tool_use_tokens: int = 0,
tool_name: str | None = None,
Expand Down Expand Up @@ -303,6 +305,7 @@ def _record(
TelemetryField.TOKENS_IN: tokens_in,
TelemetryField.TOKENS_OUT: tokens_out,
TelemetryField.CACHE_READ_TOKENS: cache_read_tokens,
TelemetryField.CACHE_WRITE_TOKENS: cache_write_tokens,
TelemetryField.REASONING_TOKENS: reasoning_tokens,
TelemetryField.TOOL_USE_TOKENS: tool_use_tokens,
TelemetryField.TOOL_NAME: tool_name,
Expand Down
2 changes: 2 additions & 0 deletions app/conductor/constants/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class TelemetryField(StrEnum):
MODEL = "model"
RESPONSE_MODEL = "response_model"
CACHE_READ_TOKENS = "cache_read_tokens"
CACHE_WRITE_TOKENS = "cache_write_tokens"
REASONING_TOKENS = "reasoning_tokens"
TOOL_USE_TOKENS = "tool_use_tokens"
TOOL_NAME = "tool_name"
Expand Down Expand Up @@ -108,6 +109,7 @@ class TelemetryBatchField(StrEnum):
TelemetryField.TOKENS_IN.value,
TelemetryField.TOKENS_OUT.value,
TelemetryField.CACHE_READ_TOKENS.value,
TelemetryField.CACHE_WRITE_TOKENS.value,
TelemetryField.REASONING_TOKENS.value,
TelemetryField.TOOL_USE_TOKENS.value,
}
Expand Down
3 changes: 3 additions & 0 deletions tests/conductor/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ async def model_handler(_request: ModelRequest) -> AssistantMessage:
"input": 120,
"output": 40,
"cache": 20,
"cache_write": 15,
"thoughts": 10,
"cost": {"estimated_usd": 0.00125},
},
Expand All @@ -143,6 +144,8 @@ async def tool_handler(_ctx, _state, _call) -> str:
assert events[0][TelemetryField.MODEL] == "gpt-5.1"
assert events[0][TelemetryField.TOKENS_IN] == 120
assert events[0][TelemetryField.TOKENS_OUT] == 40
assert events[0][TelemetryField.CACHE_READ_TOKENS] == 20
assert events[0][TelemetryField.CACHE_WRITE_TOKENS] == 15
assert events[0][TelemetryField.RESPONSE_MODEL] == "openai:gpt-5.1"
assert events[0][TelemetryField.ESTIMATED_COST_USD_MICROS] == 1250
assert events[0][TelemetryField.COST_SOURCE] == "evoflux_catalog"
Expand Down