Skip to content

Commit 4eb0bb0

Browse files
committed
fix: ensure cost data is persisted
1 parent aa0a77f commit 4eb0bb0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • packages/optimization/src/ldai_optimizer

packages/optimization/src/ldai_optimizer/client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2229,10 +2229,17 @@ async def _execute_agent_turn(
22292229
agent_response.usage,
22302230
_find_model_config(self._current_model or "", self._model_configs),
22312231
)
2232+
# Build a _meta entry capturing raw cost and latency telemetry for every
2233+
# iteration, regardless of which optimization goals are enabled. This
2234+
# surfaces the measurements in the API/UI even when the gates are inactive.
22322235
result_ctx = dataclasses.replace(
22332236
optimize_context,
22342237
completion_response=completion_response,
2235-
scores=scores,
2238+
scores={**scores, "_meta": JudgeResult(
2239+
score=0.0,
2240+
duration_ms=agent_duration_ms,
2241+
estimated_cost_usd=agent_cost,
2242+
)},
22362243
duration_ms=agent_duration_ms,
22372244
usage=agent_response.usage,
22382245
estimated_cost_usd=agent_cost,

0 commit comments

Comments
 (0)