Skip to content

fix: build config, runtime safety, and coverage thresholds - #97

Open
Misaka477 wants to merge 1 commit into
stepfun-ai:mainfrom
Misaka477:fix/build-runtime-behavior
Open

fix: build config, runtime safety, and coverage thresholds#97
Misaka477 wants to merge 1 commit into
stepfun-ai:mainfrom
Misaka477:fix/build-runtime-behavior

Conversation

@Misaka477

@Misaka477 Misaka477 commented Jul 4, 2026

Copy link
Copy Markdown

Summary

Runtime correctness and resilience fixes for the agent loop, state machine, tool approval cache, and retry lifecycle.

Changes

  1. B2: approval fingerprint eviction — replaces full cache clearing with oldest-entry eviction once the approval cache reaches its cap.
  2. B3: optional execution profile — guards executionProfile access with optional chaining.
  3. B4: exhausted token budget — after compaction, an exhausted output budget ends the run with an explicit failure without issuing a model request; covered by a test.
  4. B6/B7: hook resilience — preserves non-blocking tool hooks while catching hook errors, and records a visible warning when checkpoint persistence fails.
  5. B12: shared JSON normalization — centralizes stable JSON normalization utilities in @step-cli/utils/json.
  6. B13: validated state transitions — validates actual AgentLoop success and failure sequences, including failed -> goal_complete.
  7. B15: retry signal cleanup — gives each model request attempt a derived abort signal and removes the parent listener immediately after the request attempt completes.
  8. B16/B17: configurable limits — exposes state timeline capacity and retry backoff parameters through existing configuration surfaces.

Verification

  • pnpm check
  • 1527 passed, 8 skipped
  • Lint has no errors; remaining warnings are pre-existing on current main.

Closes #82, Closes #83, Closes #84, Closes #86, Closes #87, Closes #92, Closes #94, Closes #95

@github-actions github-actions Bot added area/build scripts, .github, build/config files area/core packages/core area/protocol packages/protocol labels Jul 4, 2026
@Misaka477
Misaka477 force-pushed the fix/build-runtime-behavior branch from 64e2221 to 1a1baf5 Compare July 4, 2026 01:12
@li-xiu-qi

Copy link
Copy Markdown
Contributor

Hi @Misaka477, thanks for the comprehensive fixes. This PR overlaps with #28 on adding @step-cli/agent-sdk to the build pipeline (scripts/build-packages.mjs). #28 is currently open and covers the same change. Wanted to flag the overlap in case you want to coordinate or consolidate.

@Misaka477
Misaka477 force-pushed the fix/build-runtime-behavior branch from 1a1baf5 to 8f44d18 Compare July 5, 2026 03:35
@Misaka477

Copy link
Copy Markdown
Author

Thanks for the heads-up! I've removed the agent-sdk build change from this PR to avoid overlap with #28. This PR now focuses only on the runtime fixes (executionProfile, token budget, hooks, checkpoint, retry signal, configurable params, coverage thresholds).

@ZouR-Ma

ZouR-Ma commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

B3(executionProfile 可选链)、B6 的 try/catch、B7 的 checkpoint 告警日志、B16/B17 的参数化都是合理的小加固,这部分我们认可。合入前有三个必须处理的点:

  1. (必须)撤销 .gitignore 改动。 AGENTS.md §7 明确「当前暂不接收对 README.mdREADME_CN.md.gitignore 的修改」;而且 docs/BUG_REPORT.md/docs/ISSUES_READY.md 是你本地的工作文件,放进本地 .git/info/exclude 就可以,不需要进仓库配置。(#96 里同样的 hunk 也请一并撤掉。)
  2. (必须)B18 的覆盖率阈值改动需要验证证据,且请恢复被删的注释。 perFile: true 把门禁从「全局聚合 80%」翻转成「每个文件都要 80%」,这是语义上的根本改变,大量现存文件会单独不达标;而这个改动至今没有在任何一次 CI 上验证过(测试矩阵还没跑过,verification 清单里也没有 coverage 运行记录)。另外阈值上方那行「Single source of truth for coverage gating…」注释是 CONTRIBUTING.md / docs/TESTING.md 与配置联动的锚点,请恢复。建议:去掉 perFile,保留 glob 阈值的话贴出完整 coverage 在三平台全绿的运行证据。
  3. (必须)B4 的描述与代码对不上。 body 说 "returns 0",代码是 return 1——返回 1 意味着仍会发起一个强制输出 1 token 的请求,拿回一条必然截断的响应。旧行为固然不对,但更合理的方向是触发上下文压缩或明确失败。至少请让描述与实现一致,并说明选 1 的理由。

两个不卡合入的提醒:B6 给 hook 加了 await——原来是发射后不管,现在工具执行会等 hook 完成,属于时序变化,请确认这是有意为之(若 hooks 契约是 void,建议只留 try/catch 不加 await);B15 用了 AbortSignal.any,需要 Node ≥ 20.3,建议在注释里点一句。另外 body 里的 B1(agent-sdk 加入 buildTargets)在 diff 里已经不存在——你回复 li-xiu-qi 时已把这部分移除(#28 也已合入 main),body 里的 B1 一段忘了删,请同步一下,让描述与 diff 一致。

流程上:测试矩阵没跑是首次贡献者 workflow 需要维护者批准,不是你的问题;修完 push,我们来批。注意本 PR 与 #98state-machine.ts 是完全相同区域的改动(同一个构造函数写了两遍),先合谁另一个都要 rebase,建议你自己排好顺序。改完 @ 我们。

@Misaka477
Misaka477 force-pushed the fix/build-runtime-behavior branch from 8f44d18 to 72ff28a Compare July 27, 2026 16:26
@github-actions github-actions Bot added the area/utils packages/utils label Jul 27, 2026
@Misaka477

Copy link
Copy Markdown
Author

@ZouR-Ma 已按反馈完成并 force-push:

PR body 和 issue 关联已同步。麻烦批准首次贡献者 workflow 跑三平台矩阵。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment