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

Seven fixes across build config, runtime safety, and coverage infrastructure.

Changes

  1. B1: @step-cli/agent-sdk in buildTargets — adds agent-sdk to scripts/build-packages.mjs so pnpm build:packages produces dist/.

  2. B3: executionProfile null guard — adds optional chaining to context?.executionProfile?.workspaceMode in both agent-loop.ts and state-machine.ts.

  3. B4: negative token budgetcomputeStepMaxTokens returns 0 when remainingBudget <= 0, preventing forced output with no context space.

  4. B6: hook error handling — wraps onToolStart and onToolResult hooks in try-catch with fallback logging.

  5. B7: checkpoint failure logging — adds explicit WARNING log entry when checkpoint persistence fails.

  6. B15: retry signal leak — creates a fresh AbortSignal.any() per retry attempt so listeners don't accumulate on a shared signal.

  7. B16/B17: configurable params — makes AgentStateMachine.maxTimelineSize a constructor parameter; adds retryDelayBase/retryDelayMax/retryDelayJitter to AgentRunConfig.

  8. B18: per-module coverage thresholds — adds module-specific thresholds in vitest.config.ts for high-risk areas (core/agent, core/tools, realtime).

Verification

  • tsc --noEmit
  • pnpm lint ✅ (0 errors)
  • pnpm test ✅ (1474 passed, 8 skipped)
  • pnpm dep-graph-check

Closes #83, Closes #84, Closes #86, Closes #87, Closes #94

@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,建议你自己排好顺序。改完 @ 我们。

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

Labels

area/build scripts, .github, build/config files area/core packages/core area/protocol packages/protocol

Projects

None yet

3 participants