Final telemetry flush races the Substrate checkpoint: "flush telemetry after task settlement" fails with EOF on ~25% of turns
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 22/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- go, kubernetes
- Área
- ai-infra-agents, observability
Línea de trabajo
Start by finding the runtime code that emits the flush telemetry after task settlement export and the worker path that logs Actor checkpointing, then look at the ordering between them; the related issues #2176, #2909 and the LoggerProvider races #2759/#2772 show where earlier flushes were hooked in. Reproduce with the steps above (short SendMessage turns against an OTLP/HTTP collector) and compare collector-received spans against the checkpoint timestamps. Done means the final flush completes before checkpointing starts, or unsent spans survive restore, verified on repeated short turns rather than one run. This is a design choice between three options in the issue, so expect discussion before a patch.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Disclosure: an AI agent (Claude) wrote this issue while debugging telemetry on a homelab kagent install. A human reviewed it before filing.
Summary
The flush that runs after task settlement races the Substrate checkpoint. Substrate starts checkpointing the actor as soon as the task settles. The runtime's flush telemetry after task settlement export starts a few milliseconds later, and the frozen sandbox cuts it off with EOF. Whatever was still buffered in that last batch is lost.
On one node, 283 of 1,110 checkpoints (25%) in 24 hours logged this error.
Environment
- kagent chart and controller
1.0.0 - Substrate worker pools
kagent-defaultandkagent-trusted(gVisor, one replica each, one node) - Traces configured on the Harness with standard OTEL variables:
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://<collector>:4318/v1/tracesOTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
- Seen on kagent-engine (adk-go) Agents and on Claude-harness Agents
Timeline of one turn
All lines are from the worker pod log for one actor (session-01a1fe27-…, a kagent-engine Agent):
| Time (UTC) | Source | Event |
|---|---|---|
| 12:48:58.247 | runtime | execute (task starts) |
| 12:49:01.701 | runtime | tool execution completed |
| 12:49:03.637 | egress | last trace POST from this actor returns 200 |
| 12:49:03.645 | worker | Actor checkpointing |
| 12:49:03.657 | runtime | ERROR flush telemetry after task settlement … error="traces export: Post \"http://<collector>:4318/v1/traces\": EOF" |
| 12:49:03.760 | worker | Actor checkpointed |
The flush starts 12 ms after checkpointing begins, and its POST ends in EOF. The egress proxy logs the same request with no HTTP status, followed by Reset { error_code: CANCEL } on the actor's connection.
Frequency
These counts come from Loki over 24 hours on one node:
sum(count_over_time({k8s_namespace_name="kagent"} |= "\"message\":\"Actor checkpointing\"" [24h])) -> 1110
sum by (target) (count_over_time({k8s_namespace_name="kagent"} |= "flush telemetry after task settlement"
| regexp "(?P<target>otel-collector\\.[a-z-]+|otel-gateway)" [24h]))
agentevals collector 275
usage collector 7
monitoring gateway 1 (a metrics export)
By agent type, over the same 24 hours:
| Agents | Checkpoints | Final flush failed |
|---|---|---|
| Claude-harness eval candidates | 695 | 275 (40%) |
| Claude-harness production agents | ~85 | 7 |
| kagent-engine agents with trace export | 18 | 1 |
The eval candidates fail most often. Their turns are short and run back to back, and each turn ends in a checkpoint.
Steps to reproduce
- Configure an Agent's Harness to export traces to an OTLP/HTTP collector (
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf). - Send several short blocking
SendMessageturns to the Agent, each one tool call and two model calls. - Search the worker pod log for
flush telemetry after task settlement. For each hit, compare its timestamp with that actor'sActor checkpointingline. The flush starts after the checkpoint has started. - Compare the spans the collector received for that turn with the spans the turn should produce. The spans still buffered at settlement are expected to be missing. These include the A2A request span,
invoke_agentand the task-store RPCs, plus any span that ended less than one batch delay earlier. I have confirmed the failed export, but not which spans it carried.
Impact
- Incomplete traces for evaluation. Trace-based scoring (agentevals) gets turns without their closing spans. That is 275 of the 283 failures here.
- Lost GenAI telemetry. Any span or log record still in the final batch is dropped. With the default 5 s batch delay, that can include the
anthropic.messages.createspan of a turn's last model call, so token and cost accounting built on traces would undercount. - Silent loss. The error is logged only inside the actor, and nothing retries the export after the actor resumes.
Expected
The final flush finishes before Substrate starts the checkpoint. One of these would do it:
- run the flush before the task is settled and reported as complete, or
- have Substrate wait for a runtime "quiescent" signal sent after the flush, or
- keep unsent telemetry in the snapshot and export it after restore, instead of dropping it.
Related
- #2176: added the pre-response flush. Here the flush does run, but too late.
- #2759 and #2772: the same checkpoint race for the LoggerProvider.
- #2909: removed
KAGENT_PRE_RESPONSE_TRACE_FLUSH. The flush is now always on, so this affects every install that exports telemetry.
Workaround
OTEL_BSP_SCHEDULE_DELAY=200 on the Harness exports spans during the turn instead of at the end. That shrinks the final batch, but it can't remove it.
- Lenguaje dominante
- Go
- Estrellas
- 4.5k
- Forks
- 937
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 150
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de kagent-dev/kagent
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
kagent-dev/kagent#3792 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
kagent-dev/kagent#3790 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
kagent-dev/kagent#3789 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
kagent-dev/kagent#3787 ·
Los mantenedores suelen responder en 1 día
-
[BUG] Python memory summarization fails for Gemini models: the request has no model namePosiblemente ocupada @BahaaMattar la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
kagent-dev/kagent#3710 ·
Los mantenedores suelen responder en 1 día
Todos los issues de kagent-dev/kagent
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
Screenshot missing in READMEAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
-
Add CybeDefendAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
slavakurilyak/awesome-ai-agents#1031 ·