Skip to content

test: drive the acp-server turn tests with the testkit fake model - #5393

Merged
RealKai42 merged 1 commit into
test/route-new-tests-to-e2efrom
test/acp-server-testkit-model
Nov 25, 2026
Merged

RealKai42 merged 1 commit into
test/route-new-tests-to-e2efrom
test/acp-server-testkit-model

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Requirement or Bug

acp-server 的三组测试(e2e-turn、skills、lifecycle)用 test/_helpers/scriptedProvider.ts 驱动模型。这个 helper 直接 import 了 agent-core-v2 的测试 harness,绕过协议编码,往引擎里塞一个替身;剧本用完时只回一个错误,剩下没用的剧本也不检查。这个 PR 把这三组测试改成用 testkit 的假模型,删掉这个 helper,是「各包自己写的假模型收束到 testkit」的第 1 步。

这个 PR 叠在 #5385 上:它会降低 #5385 新加的冻结检查基线。#5385 合入后,这里的目标分支改回 main。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路:每组测试起一个 testkit 假模型,监听本机随机端口,把 acp-server 测试配置里假模型的 baseUrl 指过去。引擎的请求照常经过 OpenAI 协议编码和 HTTP,到达 testkit。每条用例结束时调用 verify():剧本没用完、请求比剧本多、消息结构不对,都会让用例失败。

文件 改了什么
test/_helpers/scriptedProvider.ts 删除
test/_helpers/fakeModelConfig.ts 加可选的 baseUrl(默认值不变);两个假模型的上下文窗口从 8192 改成 262144,原因见下
test/e2e-turn.test.ts、test/skills.test.ts、test/lifecycle.test.ts mockNextText 改成 model.script(say(...)),工具调用改成 call(...);callCount() 改成 model.requests().length,callHistory()[i] 改成 model.requests()[i]?.rawBody;afterEach 里先 verify() 再关闭假模型
scripts/checks/baselines/test-doubles.json acp-server 的四项旧写法清零

换成 testkit 之后,有几处改动不是机械替换,逐条说明:

改动 原因
假模型的上下文窗口 8192 → 262144,两处断言跟着改(usage_update 的 size 和 /status 里的窗口) 旧 helper 回报的 usage 几乎为 0,引擎从不觉得上下文满。testkit 按真实请求体估算 usage,光系统提示词加工具定义就超过 8192 的压缩阈值,引擎会在第一个工具调用之后自动压缩,然后多发一个没写剧本的请求。8 条用例因此失败,以前这第 3 个请求被旧 helper 悄悄回了错误。窗口调到真实模型的量级后,这些用例测回它们本来要测的路径
分块发送工具参数的两条用例:第一张待定卡片的文字从 {"command":"ec 改成空,后面检查「部分参数是完整参数的前缀 → 完整参数 → 升级为已开始 → 完成」 testkit 和真实 OpenAI 流一样,先发一块只带工具名、参数为空的增量,再分块发参数。旧断言写死的是旧 helper 的切点,不是 ACP 的契约。新断言检查的仍是用例名说的「懒建待定卡片 → 累积更新 → 升级 → 完成」
「启动途中取消」:不再写 Bash 剧本,改成 model.lane('main').unscripted('hang') 取消和模型请求谁先到不确定。写了剧本,取消先到时剧本就用不上,严格检查会失败。挂起策略下,请求到了就挂住等取消中止,没到也不报错
「未知斜杠命令不会请求模型」:去掉诱饵回复 echoed 用例断言的就是一次请求都没有。不写剧本时,多出来的请求本来就会让 verify() 失败

Behavior Changes and Affected Users

None。只改了 acp-server 的测试和测试 helper,产品代码没动。

测试覆盖:这三组用例原来覆盖的 ACP 行为都还在,现在多了 testkit 的严格检查,请求也经过真实的协议编码。

验证
  • pnpm exec vitest run packages/acp-server:169 条里 168 条通过。失败的是 lifecycle.test.ts 的 session/delete removes the session and a second delete reports invalid_params,它在改动前的代码上同样失败:本机 macOS 上一直失败,CI 的 Linux 上通过,和这次改动无关。改动涉及的三个文件连跑两次,结果相同。
  • pnpm exec tsc -p packages/acp-server/tsconfig.json --noEmit:通过。
  • pnpm lint:通过。
  • pnpm run check:duplication <main>:没有新增重复。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

The e2e-turn, skills and lifecycle tests scripted the model through
test/_helpers/scriptedProvider.ts, which imported the agent-core-v2 test
harness, skipped protocol encoding and never failed on a script that
did not match the requests.

- Start a testkit fake model per test, point the fake model config at
  it, and verify the script after each test. Delete scriptedProvider.ts.
- Raise the fake model context window from 8192 to 262144. With real
  usage estimates the engine compacted after the first tool step and
  sent a request no script covered; the old helper reported near-zero
  usage and answered that request with a silent error.
- Check the streamed tool-call cards against the ACP contract (empty
  pending card, cumulative arguments, started, completed) instead of
  the old helper's split point.
- Let an unscripted request hang in the cancel-during-launch test, and
  drop the decoy reply from the unknown slash command test.
- Lower the test-doubles baseline for acp-server.
@changeset-bot

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3e7941c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T07:04:56.257964Z 3e7941c PR opened
🔒 Security Review ✅ Completed 2026-11-25T07:05:40.966433Z 3e7941c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@3e7941c
npx https://pkg.pr.new/@moonshot-ai/kimi-code@3e7941c

commit: 3e7941c

@RealKai42
RealKai42 merged commit 5034bc7 into test/route-new-tests-to-e2e Nov 25, 2026
16 checks passed
@RealKai42
RealKai42 deleted the test/acp-server-testkit-model branch November 25, 2026 07:20
RealKai42 added a commit that referenced this pull request Nov 25, 2026
…#5385)

* test: route new tests to tests/e2e and freeze the paused E2E directories

tests/AGENTS.md and the testkit docs still sent new cases to the Desktop
and TUI E2E directories that stopped running automatically, and tests
could call the engine harness provider helpers without the test-doubles
check noticing.

- Point tests/AGENTS.md, the testkit docs and the root AGENTS.md at
  tests/e2e and tests/scenarios, and state that fake models come from
  the testkit.
- Add legacy-e2e.mjs to pnpm lint: it freezes the test cases in the
  three paused directories per file.
- Add the engine-mock-provider rule to test-doubles.mjs; requester-level
  loop-core unit tests may keep createMockProviderRequester.
- Share the file listing, baseline handling and report split of both
  count checks through ratchet.mjs.

* test: drive the acp-server turn tests with the testkit fake model (#5393)

The e2e-turn, skills and lifecycle tests scripted the model through
test/_helpers/scriptedProvider.ts, which imported the agent-core-v2 test
harness, skipped protocol encoding and never failed on a script that
did not match the requests.

- Start a testkit fake model per test, point the fake model config at
  it, and verify the script after each test. Delete scriptedProvider.ts.
- Raise the fake model context window from 8192 to 262144. With real
  usage estimates the engine compacted after the first tool step and
  sent a request no script covered; the old helper reported near-zero
  usage and answered that request with a silent error.
- Check the streamed tool-call cards against the ACP contract (empty
  pending card, cumulative arguments, started, completed) instead of
  the old helper's split point.
- Let an unscripted request hang in the cancel-during-launch test, and
  drop the decoy reply from the unknown slash command test.
- Lower the test-doubles baseline for acp-server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant