Skip to content

test(cli): pass explicit exec output budget in external archive fixture - #7135

Merged
M4n5ter merged 1 commit into
rust-previewfrom
fix/macos-external-jobs-flake
Nov 21, 2026
Merged

M4n5ter merged 1 commit into
rust-previewfrom
fix/macos-external-jobs-flake

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 21, 2026

Copy link
Copy Markdown
Member
English

Summary

Fixes the deterministic native-macos-agent CI failure in maka-cli::external_jobs::antigravity_can_continue_after_host_restarts_during_a_prompt introduced after #7125.

Refs #7125

Root cause

  • feat(agent): unify Code Mode output budgeting, tail previews, and in-cell Read paging #7125 (1599a73ac) unified Code Mode output budgeting so exec defaults to DEFAULT_CELL_OUTPUT_TOKENS = 10_000 (40,000 UTF-16 chars) and driver_external_effects.rs (display_projection) honors display_budget_chars instead of always archiving at MAX_PAGE_CHARS (7,500).
  • readArchivedResult() in products/maka/cli/tests/support/external_codex_cli.mjs still emitted 30,000 chars without passing max_output_tokens. Under the new 40,000-char default budget, exec returned unarchived multi-line output, JSON.parse(result.content[0].text) threw a SyntaxError, and the fake ACP worker exited without replying to the pending session/prompt, leaving terminal_state hanging until the 45s follow-up completes phase deadline.
  • All 11 sibling tests in external_jobs.rs were unaffected and remain healthy.

Fix

  • Pass an explicit max_output_tokens: 1000 (4,000-char budget) with a 12,000-char payload in readArchivedResult() so external archive creation and Read continuation are tested deterministically regardless of future default-budget changes.
  • Throw a descriptive error when an archived JSON envelope is missing instead of masking JSON.parse failures as Invalid protocol JSON.
  • Track the active ACP session/prompt request ID (clearing it on reply) and return a JSON-RPC error from fail() when the fixture aborts mid-prompt so future fixture errors fail immediately instead of timing out after 45s.

Verification

  • Reproduced the exact CI failure locally before the fix (FAIL [61.920s] at external_jobs.rs:1600, deadline: follow-up completes).
  • cargo nextest run --locked -p maka-cli --test external_jobs: 12 passed, 0 failed in 29.26s (antigravity_can_continue_after_host_restarts_during_a_prompt passed in 20.07s).
  • npx biome check products/maka/cli/tests/support/external_codex_cli.mjs: passed (0 issues).
  • rustfmt --edition 2024 --check products/maka/cli/tests/external_jobs.rs: passed.
  • node scripts/ci.mjs check licenses: passed.

AI use

  • Generative tooling made a substantive contribution

Maka (Gemini) investigated the CI failure history, reproduced and diagnosed the root cause in external_codex_cli.mjs, implemented the fix, and ran local verification.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • No (test fixture only)
简体中文

摘要

修复 #7125 合并后导致 native-macos-agent 连续失败的确定性回归(maka-cli::external_jobs::antigravity_can_continue_after_host_restarts_during_a_prompt)。

Refs #7125

根因

  • feat(agent): unify Code Mode output budgeting, tail previews, and in-cell Read paging #7125(1599a73ac)统一了 Code Mode 输出预算,exec 默认预算提升至 DEFAULT_CELL_OUTPUT_TOKENS = 10_000(40,000 UTF-16 字符),且 driver_external_effects.rs 的 display_projection 开始遵循 display_budget_chars,不再固定按 MAX_PAGE_CHARS(7,500)归档。
  • 测试桩 products/maka/cli/tests/support/external_codex_cli.mjs 中的 readArchivedResult() 仍只输出 30,000 字符且未显式指定 max_output_tokens,因此输出未触发归档而是直接内联返回;随后的 JSON.parse(result.content[0].text) 抛出 SyntaxError,ACP worker 直接退出而未回复正在等待的 session/prompt,导致测试卡在 follow-up completes 直到 45 秒超时。
  • external_jobs.rs 中其余 11 个测试均未受影响且表现稳定。

修复内容

  • 在 readArchivedResult() 中显式传入 max_output_tokens: 1000(4,000 字符预算)并输出 12,000 字符,既验证外部 MCP exec 正确传递预算并触发归档续读,也避免后续再次调整默认预算时误伤该测试。
  • 当返回内容不是合法归档 JSON 时抛出明确错误信息,避免被 fail() 掩盖为 Invalid protocol JSON。
  • 追踪当前未回复的 ACP session/prompt 请求 ID(在 reply 后清空),在 fail() 中主动返回 JSON-RPC error,避免后续测试桩异常时再次静默卡死 45 秒。

验证

  • 修复前在本地稳定复现了与 CI 完全一致的失败(FAIL [61.920s],deadline: follow-up completes)。
  • cargo nextest run --locked -p maka-cli --test external_jobs:12 passed, 0 failed(总耗时 29.26s,其中目标用例 20.07s 通过)。
  • npx biome check products/maka/cli/tests/support/external_codex_cli.mjs:通过。
  • rustfmt --edition 2024 --check products/maka/cli/tests/external_jobs.rs:通过。
  • node scripts/ci.mjs check licenses:通过。

AI 使用声明

  • 生成式工具做出了实质性贡献

由 Maka (Gemini) 完成 CI 失败排查、本地复现、根因定位、修复及本地验证。

检查项

  • 测试覆盖本次改动,且在未修复前稳定复现失败
  • 格式化、许可头检查与受影响的测试套件已在本地通过

本 PR 是否引入产品行为变更?

  • 否(仅修复测试桩)

#7125 unified Code Mode output budgeting so external exec calls honor display_budget_chars (default 10,000 tokens / 40,000 UTF-16 chars) instead of always archiving at 7,500 chars. Because readArchivedResult() in external_codex_cli.mjs emitted 30,000 chars without setting max_output_tokens, exec returned inline output, JSON.parse threw a SyntaxError, and the worker exited without replying to session/prompt, causing antigravity_can_continue_after_host_restarts_during_a_prompt to hang until the 45s follow-up deadline.

Set max_output_tokens: 1000 with a 12,000-char payload so archive continuation is exercised deterministically regardless of default budget changes, surface non-JSON archive replies clearly, and fail pending ACP session/prompt requests immediately when the fixture aborts.

Refs #7125

Generated-by: Maka (Gemini)
@M4n5ter
M4n5ter merged commit cc879c1 into rust-preview Nov 21, 2026
8 of 9 checks passed
@M4n5ter
M4n5ter deleted the fix/macos-external-jobs-flake branch November 21, 2026 15:09
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