Final telemetry flush races the Substrate checkpoint: "flush telemetry after task settlement" fails with EOF on ~25% of turns
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 22/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- go, kubernetes
- Ambito
- ai-infra-agents, observability
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Go
- Stelle
- 4.5k
- Fork
- 937
- Merge medio
- 1g 10h
- PR unite (30g)
- 150
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di kagent-dev/kagent
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
kagent-dev/kagent#3792 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
kagent-dev/kagent#3790 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
kagent-dev/kagent#3789 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
kagent-dev/kagent#3787 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Python memory summarization fails for Gemini models: the request has no model nameForse già presa @BahaaMattar l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
kagent-dev/kagent#3710 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di kagent-dev/kagent
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Screenshot missing in READMEAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
Add CybeDefendAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 66/100
slavakurilyak/awesome-ai-agents#1031 ·