Streamed turns write the whole task to Postgres once per chunk

未关闭
#3,328 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
49/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
go, postgresql
领域
backend, database

调研方向

Start with go/adk/pkg/taskstore/store.go lines 95–127, which the issue identifies as the synchronous task write path. Trace how streamed events call UpdateTask and where task state changes are represented before evaluating the suggested timer and state-change saves. Done means streamed chunks still reach the client while database updates are coalesced and state changes are persisted; the issue names no tests to run.

由索引模型根据 Issue 内容生成。

描述

With a streaming ModelConfig, the Go runtime saves every streamed event as its own synchronous UpdateTask carrying the whole task (store.go:95-127 at alpha17). So a reply's database cost grows with its chunk count rather than once per turn.

We measured on kind with kagent 1.0.0-alpha16 and Substrate 0.6.0-alpha3 (the store's write path is the same in alpha17): 20 sequential turns per agent, against a mock model that replies with 363 bytes in 121 chunks.

Per turn Streamed stream: false
kagent rows inserted / updated 126 / 256 8.8 / 20
UpdateTask calls 129 —
Postgres commits ≈2,095 ≈330
WAL ≈427 KB ≈40 KB
Later-turn latency 4.8 s 3.6 s

The commits and WAL cover the whole Postgres instance, Substrate's side included; the row counts and calls are kagent's own. With a handful of concurrent streamed Sessions the per-chunk round trips add up, because they run one after another within a turn.

Could updates be coalesced while a model streams? For example, save on a short timer and on every state change (working, input-required, completed, failed), and keep streaming each chunk to the client.

For now we've set stream: false on our ModelConfigs. We're running on AKS and happy to help with this, whether that's design input or a PR.

主要语言
Go
星标
4.2k
派生
890
平均合并
1 天 6 小时
30 天内合并 PR
189

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

kagent-dev/kagent 的其他 Issue

查看 kagent-dev/kagent 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。