Final telemetry flush races the Substrate checkpoint: "flush telemetry after task settlement" fails with EOF on ~25% of turns
维护者通常 1 天内回复
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 22/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- go, kubernetes
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Go
- 星标
- 4.5k
- 派生
- 937
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 150
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
kagent-dev/kagent 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
kagent-dev/kagent#3792 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
kagent-dev/kagent#3790 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
kagent-dev/kagent#3789 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
kagent-dev/kagent#3787 ·
维护者通常 1 天内回复
-
[BUG] Python memory summarization fails for Gemini models: the request has no model name可能已有人在做 @BahaaMattar 于 6 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
kagent-dev/kagent#3710 ·
维护者通常 1 天内回复
查看 kagent-dev/kagent 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 1/5 1 小时以内 新手友好度 82/100
-
Add CybeDefend未关闭
难度 1/5 1 小时以内 新手友好度 66/100
slavakurilyak/awesome-ai-agents#1031 ·