Open
fix: support DeepAgent stream idle timeout configuration #568
fix: support DeepAgent stream idle timeout configuration #568
Open
chenxiyingAdd on 1 day ago
chenxiying
chenxiyingCollaborators
1 day ago

Paired: GitHub #706 ↔ GitCode !568

Configure DeepAgent stream idle timeout

Scope

Add the stream idle timeout to the DeepAgent YAML and JVM entry points on the 930 baseline. This limits the idle window while reading streamed response data; it does not cap the duration of an entire model call.

  • YAML: backend.stream_idle_seconds: 300.
  • JVM: -Dopenjiuwen.llm.http.stream-idle-seconds=300.
  • Priority: explicit backend value, JVM property, then the existing timeout fallback.
  • Preserve the existing write timeout, connection timeout, call override, retry defaults, and behavior when the new settings are absent.
  • Invalid, non-positive, NaN, and infinite values fall back to the existing timeout.

Implementation

  • Carry the optional value through YAML loading, DeepAgent backend conversion, model registration, and custom-header configuration rebuilding.
  • Apply it to the existing OpenAI-compatible OkHttp read timeout only. This client is shared by stream and invoke, so an explicitly configured value also changes non-streaming read waits; it is not a stream-only transport client or a total-call deadline.

This is intentionally narrower than the full timeout and retry configuration available on develop. Other model clients are unchanged.

Verification

  • 46 focused core tests passed: OpenAI-compatible client, DeepAgent factory, ReActAgentConfig, and dynamic model tests.
  • Core compilation passed.
  • A real local delayed-SSE regression verified that a 1.5-second pause between data segments succeeds with an explicit three-second idle timeout while the legacy timeout is one second. The same regression failed with a socket timeout before the fix.
  • New ST: three cases covering explicit YAML, JVM fallback, explicit-over-JVM priority, legacy read/write defaults, and the real OkHttp client. All three pass with this change. With the original 930 JAR, all three fail because YAML does not register the model.
  • Complete smoke: 354 tests, 0 failures, 0 errors, 59 skipped, BUILD SUCCESS. The skips are pre-existing environment or explicit capability gates: 14 Redis Cluster, two knowledge-base workflow capability gaps, and 43 other missing Milvus, Embedding, Elasticsearch, model, or Jaeger prerequisites. None of the new tests skipped.

Local full-smoke execution used an ignored Redis .env, a local MCP numeric-result fixture correction, and an explicit installed Python environment. Those local-only changes are not included in the ST PR; CI will independently verify the clean branch.

Additional CI feedback

  • Commit 246c39a8 fixes the reported G.EXP.03 mixed Double/double ternary with explicit primitive-return branches. The OpenAI-compatible client tests and complete HarnessCompatibilityTest together passed 35 tests.
  • The initially reported completedInterruptResumeShouldNotAffectNextRequestInSameSession failure passed locally by itself and in its full class on both the PR and original 930 baseline. The latest cloud CodeCheck, Maven Build, AntiPoison, and Software Composition Analysis are all SUCCESS.
  • Full local core runs are not green on Windows: the PR reports 3856 tests, 6 failures, 17 errors, and the original 930 baseline reports 3848 tests, 7 failures, 18 errors. Both include the reported interrupt-recovery test as passing. The other failures include Windows permissions/Python command assumptions and existing timing-sensitive tests; they are not treated as successful verification or modified in this PR.
  • The cloud smoke task compiled the develop test line: its KbTool imports com.openjiuwen.core.foundation.store.vector.ChromaVectorStore/MilvusVectorStore, which do not exist on 930. No test ran. For this PR, select ST agent_core_java (whose KbTool uses the retrieval adapter and whose POM includes the retrieval artifact) with the PR-built 0.1.16 JAR. That same-line configuration produced the successful smoke result above. The external pipeline configuration is not in this repository.

Not verified

  • No real model request or minute-scale pause was exercised; transport coverage uses a local HTTP/SSE service.
  • Local CodeArts was unavailable; the cloud CodeCheck result is recorded above.

🤖 Generated with Claude Code

likedislike
Merge blocked
atomgit-bot
atomgit-bot
1 day ago Comments:

变更摘要

本 PR 在 930 基线上为 DeepAgent 增加流式响应空闲超时(stream idle timeout)配置能力:新增 streamIdleSeconds 配置项,通过 ModelClientConfig 承载并在 YAML(backend.stream_idle_seconds)、JVM 属性(openjiuwen.llm.http.stream-idle-seconds)以及旧 timeout 之间建立优先级回退关系,最终只作用于 OpenAiCompatibleModelClient 中 OpenAI 兼容 OkHttp 客户端的读超时,写超时与连接超时行为保持不变。同时打通 YAML 加载到 DeepAgent 后端转换、模型注册和自定义 header 重建的传递链路,并补充相应测试。

主要改动

  • 新增流空闲超时解析逻辑: OpenAiCompatibleModelClient.buildOkHttpClient 将原本共用一个值的读写超时拆分为 readTimeout 与 writeTimeout,新增 resolveStreamIdleSeconds 按「显式配置 → JVM 属性 → 旧 timeout」顺序取值,并通过 isPositive 对非正数、NaN、无穷值回退到旧超时。
  • 配置模型新增字段: ModelClientConfig 增加可空的 streamIdleSeconds 字段及其 getStreamIdleSeconds() 访问器和 Builder 方法,并以 @JsonProperty("stream_idle_seconds") 暴露序列化名称。
  • 配置传递链路打通: DeepAgent 的两处后端配置构建从 backendMap 读取 stream_idle_seconds/streamIdleSeconds;ReActAgentConfig.configureCustomHeaders 在重建配置时保留该字段。
  • YAML 配置结构补充: HarnessConfig 增加 model 与 backend 字段并在 toYamlMap 中输出,HarnessConfigBuilder 将这两个字段透传,使 YAML 中的 backend.stream_idle_seconds 能被读取。
  • 测试覆盖: 新增测试验证显式值优先于 JVM 属性、仅影响读超时、无效值回退、延迟 SSE 分片在配置空闲超时下可正常读取,以及 YAML 中 stream_idle_seconds 能传递到 ReActAgentConfig。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
1 day ago Comments:

代码审查

审查结论

逐文件审查确认

文件 结论
OpenAiCompatibleModelClient.java 有 1 个 P2:流空闲值写进共享 client 的 readTimeout,非流式 invoke 超时被一并改变;resolveStreamIdleSeconds / isPositive 的 NaN、负数、空值回退逻辑本身正确
ModelClientConfig.java 有 1 个 P3:新键 stream_idle_seconds 未同步到其它同 schema 的 map 解析入口;字段拷贝、@JsonProperty、NON_NULL 序列化均正确
ReActAgentConfig.java 有 1 个 P3:configureCustomHeaders 已保留新字段,但兄弟路径 configureModelClient 重建时丢弃
DeepAgent.java 未发现问题(两处 applyBackendConfig / extractModelClientConfig 的解析一致,doubleValue(null) 返回 null,语义正确)
HarnessConfig.java 未发现问题(新增 Object model/backend + toYamlMap 写入;仓库内无 new HarnessConfig(...) 位置参数调用,@AllArgsConstructor 顺序变化无破坏;现有 HarnessConfig.builder() 调用点均不传该两字段)
HarnessConfigBuilder.java 未发现问题(.model()/.backend() 透传到 DeepAgentConfig,下游 applyModelConfig/applyBackendConfig 支持 Map 形态)
OpenAiCompatibleModelClientTest.java 有 1 个 P3:新增测试改动全局系统属性,使既有 read==write==timeout 断言变为依赖环境 JVM 参数;新增导入均被使用,无编译问题
ReActAgentConfigTest.java 未发现问题(新测试断言 headers 重建后保留 streamIdleSeconds,覆盖到位)
DeepAgentsFactoryCompatibilityTest.java 未发现问题(YAML 用例的 instanceof 条件断言前置已有 isInstanceOf 兜底,不构成漏断言)

统计

  • P0:0
  • P1:0
  • P2:1
  • P3:3

总体风险判断

中心逻辑(YAML → DeepAgent → ModelClientConfig → OkHttp readTimeout)链路正确,非法值回退与优先级实现符合 PR 描述,新增测试方向正确。主要风险是语义扩大:stream_idle_seconds 实际作用于共享 OkHttpClient 的读超时,因此非流式 invoke() 的超时也被改写(放大即削弱快速失败、缩小即可能误杀长响应),这一点与本 PR 声明的「仅限流式读取空闲窗口」不一致,也是目前测试未覆盖的路径,建议合并前修正或至少在文档中明确该副作用。其余三项为可维护性/一致性层面的低优先级改进,不阻塞合入。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
Incorrect?
atomgit-bot
atomgit-bot
1 day ago Comments:

AtomGit AI 助手使用指南

在 PR 评论中使用命令即可触发。支持在普通评论和代码行评论中使用。

功能 命令 说明
代码审查 /ai review 检查代码质量、潜在问题、安全风险
PR 摘要 /ai summary 生成 PR 变更内容的结构化摘要
代码解释 /ai explain 解释代码变更的逻辑和意图
自由提问 @atomgit-bot <问题> 询问关于本 PR 的任何问题
帮助 /ai help 显示此帮助信息

免责声明

AI 助手可能存在误判,请结合自身判断。可以对评论点 👍 或 👎 帮助我们改进。

likedislike
Incorrect?
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Set shenwei21,tianmingyong as approver
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Added label: sig/sig-agent-core-java
openJiuwen-bot
openJiuwen-botCollaborators
1 day ago Comments:

欢迎来到 openJiuwen 社区

Hey @weixin_45837958 , 感谢你对社区的贡献.

机器人使用手册

有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。

联系指引

有疑问可以联系 SIG: sig-agent-core-java ,
维护者是: @shenwei21, @tianmingyong ,
审核者是: @foreach1991, @gcw_xJSJ32Ge, @jeffrey_qiao, @kangquansheng_makeIT, @xiongjie_makeit .

likedislike
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Added label: openJiuwen-cla/yes
openjiuwen-syncopenjiuwen-syncCollaborators
1 day ago Modify description of pull request
atomgit-bot
atomgit-bot1 day agoStart code review1
core/src/main/java/com/openjiuwen/core/foundation/llm/model_clients/OpenAiCompatibleModelClient.java
@@ -320,2 +322,3 @@
320322 private OkHttpClient buildOkHttpClient(double timeoutSeconds) {
321- Duration readWriteTimeout = resolveTimeout(timeoutSeconds);
323+ Duration readTimeout = resolveTimeout(resolveStreamIdleSeconds(timeoutSeconds));
324+ Duration writeTimeout = resolveTimeout(timeoutSeconds);
atomgit-bot
atomgit-bot1 day agoComments:

🟡 Medium Priority

改动行(OpenAiCompatibleModelClient.java:323)把 readTimeout 改为 resolveTimeout(resolveStreamIdleSeconds(timeoutSeconds)),而 httpClient 是类级单例字段(第 100、112 行),被 invoke()(第 169 行)与 stream()(第 210 行)共用。

证据链:OkHttp 的 readTimeout 对整个 client 生效,覆盖「等待响应头 + 读取响应体」的每次 socket 读操作,并不区分流式/非流式调用。改动前 read / write 都等于配置的 timeout;改动后 read 只受 stream_idle_seconds(backend 值 → JVM 属性 → timeout 回退)控制。

失败模式(两种方向都可触发):

  1. 按 PR 自带的示例配置(timeout: 120、stream_idle_seconds: 300)运行时,非流式的 invoke() 读超时也从 120s 变成 300s,后端半死/无响应时会多阻塞 180s,原本的快速失败能力被静默削弱。
  2. 反向配置(如 timeout: 300、stream_idle_seconds: 30)时,非流式请求的首字节等待一旦超过 30s 就抛 SocketTimeoutException → MODEL_CALL_FAILED,即长耗时非流式调用被新的流空闲值直接打断。

这与 PR 声明的范围(「仅限制读取流式响应数据片段之间的空闲窗口,不改变其他行为」)不一致,且新增测试 explicitStreamIdleControlsReadTimeoutWithoutChangingWriteTimeout 等只校验了构造出的 client 参数、streamWaitsForDelayedChunkUsingConfiguredIdleTimeout 只覆盖流式路径,未覆盖非流式路径。

建议:保持主 client 的 readTimeout 为 resolveTimeout(timeoutSeconds),在 stream() 中使用 httpClient.newBuilder().readTimeout(...) 派生带流空闲超时的 client(共享连接池),避免非流式 invoke 的读超时被新配置放大或缩小。

likedislike
Incorrect?
openJiuwen-bot
openJiuwen-botCollaborators
1 day ago Comments:
TASK STATUS DETAILS
CodeCheck ❌FAILED Click here
Blacklist Scan N/A N/A
AntiPoison ✅SUCCESS Click here
Software Composition Analysis ✅SUCCESS Click here
Maven Build ❌FAILED See CHECK tab
likedislike
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Added label: ci-failed
chenxiyingchenxiyingCollaborators
1 day ago Pushed 1 commits:246c39a8-fix: keep stream idle fallback types consistent
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Added label: stat/needs-squash
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Removed label: openJiuwen-cla/yes
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Added label: openJiuwen-cla/yes
openJiuwen-bot
openJiuwen-botCollaborators
1 day ago Comments:

CLA 签署成功

weixin_45837958, 感谢您的代码贡献。 所有的代码贡献者都已完成了 CLA 签署。 👍

likedislike
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Removed label: ci-failed
openJiuwen-bot
openJiuwen-botCollaborators
1 day ago Comments:
TASK STATUS DETAILS
CodeCheck ✅SUCCESS Click here
Blacklist Scan N/A N/A
AntiPoison ✅SUCCESS Click here
Software Composition Analysis ✅SUCCESS Click here
Maven Build ✅SUCCESS See CHECK tab
likedislike
openJiuwen-botopenJiuwen-botCollaborators
1 day ago Added label: ci-successful
chenxiying
chenxiyingCollaborators
1 day ago Comments:

本地处理与复验说明:

  1. 门禁报告中的 G.EXP.03 已在 246c39a8 修复:将 Double/double 混合三元表达式改为显式 primitive 返回分支。本地 OpenAI 客户端 15 项与 HarnessCompatibilityTest 20 项共 35 项通过。
  2. 首次 Maven Build 的 completedInterruptResumeShouldNotAffectNextRequestInSameSession 失败,本地在当前 PR 与原始 930 基线上分别单跑均通过;当前 PR 的完整 HarnessCompatibilityTest 为 20/20 通过。最新云端回评中 Maven Build 已为 SUCCESS,CodeCheck、AntiPoison、Software Composition Analysis 也均为 SUCCESS。该旧失败未通过修改中断恢复逻辑掩盖。
  3. AI 指出共享 OkHttpClient 的影响成立:stream_idle_seconds 设置的是 socket read timeout,每次阻塞读都可能应用,因此非流式调用也共享该读超时。这是本次选择的最小实现边界,未引入独立流式客户端;它不是整个调用的总超时。未配置时仍回退旧 timeout,写、连接、call override 与重试行为不变。
  4. applyBackendConfig 与 extractModelClientConfig 已同步处理新键,未发现其他 DeepAgent backend Map 解析入口。configureModelClient 是按方法入参整体重建客户端配置(旧 timeout 同样重置),不是保留已有配置的拷贝方法,因此未扩展其既有契约。
likedislike
chenxiyingchenxiyingCollaborators
1 day ago Modify description of pull request
openjiuwen-syncopenjiuwen-syncCollaborators
1 day ago Modify description of pull request
chenxiying
chenxiyingCollaborators
1 day ago Comments:

补充 smoke_test 编译失败的定位与分流结论:

  • 报错中的 KbTool.java 导入 com.openjiuwen.core.foundation.store.vector.ChromaVectorStore/MilvusVectorStore,来自 ST agent_core_java_develop 的提交 20c4f301(适配 core develop)。930 core 不包含这两个旧包路径。
  • 本 PR 的 base 是 930,配套 ST !1317 的 base 是同线 agent_core_java。该分支的 KbTool.java 使用 com.openjiuwen.retrieval.vector_store.adapter.*,并在 pom.xml 显式依赖 agent-core-retrieval-java:0.1.16,匹配 930 的 retrieval 模块拆分。
  • 本地已用当前 core 构建的 0.1.16 JAR 在 agent_core_java 上执行完整 smoke:354 项、0 失败、0 错误、59 跳过、BUILD SUCCESS;新 ST 3 项全部执行通过。59 项为已核实的条件跳过,不记为通过。
  • 因此本次 smoke 失败发生在测试源码编译阶段,尚未执行任何测试;不是本 PR 的模型超时逻辑或 ST 新用例断言失败,也不能通过修改/跳过 KbTool 断言解决。

需要 smoke_test 对 core base=930 选择 ST agent_core_java(可将配套 !1317 合入后使用其分支),而不是 agent_core_java_develop;并继续传入当前 PR 构建的 core 0.1.16 制品。配套 ST !1317 不能改到 develop base,否则会重新引入这两个缺失类。仓内未找到该外部流水线的分支选择配置,未擅自重跑云流水线。

likedislike
chenxiyingchenxiyingCollaborators
1 day ago Modify description of pull request
openjiuwen-syncopenjiuwen-syncCollaborators
1 day ago Modify description of pull request
yaodonghaiyaodonghaiCollaborators
1 day ago Set whylazy as approver
yaodonghaiyaodonghaiCollaborators
1 day ago Approval passed
thesky58
thesky5817 hours agoStart code review1
core/src/main/java/com/openjiuwen/core/foundation/llm/model_clients/OpenAiCompatibleModelClient.java
@@ -380,0 +384,4 @@
384+ * @return effective stream idle seconds
385+ * @since 0.1.16
386+ */
387+ private double resolveStreamIdleSeconds(double timeoutSeconds) {
thesky58
thesky5817 hours agoComments:

这里的取值链是「显式配置 → JVM 属性 → 旧 timeout」,没有范围校验,未配置时默认沿用旧 timeout(示例里 60s)。主分支 develop 上同一件事已经由 com.openjiuwen.core.foundation.llm.modelclients.ModelTimeoutResolver 实现,语义不同:validateStreamIdleSeconds 限定 [300, 900],默认 DEFAULT_STREAM_IDLE_SECONDS = 600;并且把「响应头等待」单独作为一层(显式 timeout → JVM 属性 → 配置的 stream idle),只有读响应体时用 stream idle。

后果:同一份 backend.stream_idle_seconds 在 develop 和 930 上行为不一致——930 不配就退回旧 timeout,配了也不校验下限(isPositive 只挡非正数,0.5s 也接受),而响应头等待会被空闲值一并改写。从 930 升到 develop 的用户会看到超时行为变化。

如果 930 这条发布线还要继续维护,建议把这里的取值与校验对齐 ModelTimeoutResolver(至少补 [300, 900] 校验和 600s 默认),或者直接把这套分层超时回移到 930;只保留一套语义,后面合并/升级时少一处需要重新对账的分叉。

likedislike