Skip to content

fix(cli,mcp): forward max_tokens across step, plan, and MCP sync-after actions (#755) - #757

Merged
NianJiuZst merged 1 commit into
Tencent:mainfrom
NianJiuZst:fix/755-step-plan-max-tokens
Nov 16, 2026
Merged

NianJiuZst merged 1 commit into
Tencent:mainfrom
NianJiuZst:fix/755-step-plan-max-tokens

Conversation

@NianJiuZst

Copy link
Copy Markdown
Collaborator

Fixes #755

Summary

  • CLI (bsk step, bsk plan): Added --max-tokens to StepArgs and PlanArgs/Plan, forwarding it through step::post_sync to CooperateParams.max_tokens on sync/enable calls instead of hardcoding None.
  • MCP parity (bsk_interact, bsk_plan): Added max_tokens to InteractArgs (validated to apply only with sync_after or until_visible) and PlanArgs in crates/bsk-cli/src/cli/mcp/tools.rs.
  • Docs & Changelogs: Updated crates/bsk-cli/skill/references/step-and-cache.md, docs/plan.md, CHANGELOG.md, and CHANGELOG.zh-CN.md.

Design Trade-off

  • Explicit forwarding only (no implicit extension-side inheritance when max_tokens is omitted): In the current protocol (visual-observation.ts), max_tokens: 0 fails header/notice budget checks, so omitting max_tokens (None/undefined) is the only way for callers (including bsk sync after a truncated view or bsk recipe run) to request an unbounded full-page observation. Silently inheriting baseline.maxTokens when params.max_tokens is undefined would also violate target-policy.test.ts ("never short-circuits an unchanged page across max_tokens budgets") and Wave 3a daemon budget-isolation guarantees.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --locked (including new full-chain CLI/MCP E2E tests step_and_plan_forward_max_tokens_and_preserve_delta_budget in wave3a_lifecycle_envelope_and_cache.rs and bsk_interact/bsk_plan max_tokens assertions in wave2_ssot_mcp_e2e.rs)
  • node scripts/check-skill-bundles.mjs, node scripts/check-crate-skill.mjs, node --test scripts/*.test.mjs, and python3 scripts/check-changelog-sync.py origin/main

…r actions (Tencent#755)

Why:
`bsk open --max-tokens <N>` and `bsk sync --max-tokens <N>` store `maxTokens` on
the extension's cooperation baseline, but `bsk step`, `bsk plan`, and their MCP
counterparts (`bsk_interact` with `sync_after`/`until_visible` and `bsk_plan`)
previously exposed no `max_tokens` option and hardcoded `max_tokens: None` in
`step::post_sync`. Any post-action sync on a changed or unchanged budgeted tab
then failed `sameBudget` / `textDelta` (`baseline_reason: "token_budget_changed"`),
discarded the held baseline, and forced an unbounded full-page re-capture.

What:
- Add `--max-tokens` to `bsk step` and `bsk plan`, threading `Option<u32>`
  through `step::post_sync` into `CooperateParams.max_tokens` for `Sync`/`Enable`.
- Expose `max_tokens` on MCP `bsk_interact` (rejected unless `sync_after` or
  `until_visible` is set) and `bsk_plan` so CLI and MCP stay at parity.
- Keep `None`/`undefined` explicit (do not silently inherit prior `maxTokens` in
  the extension), preserving callers' ability to switch back to unbounded
  captures and keeping `bsk recipe run` full-VOM resolution intact.
- Update `crates/bsk-cli/skill/references/step-and-cache.md`, `docs/plan.md`,
  bilingual changelogs (`CHANGELOG.md`, `CHANGELOG.zh-CN.md`), and full-chain
  CLI/MCP E2E tests (`wave3a_lifecycle_envelope_and_cache`, `wave2_ssot_mcp_e2e`).
@NianJiuZst
NianJiuZst force-pushed the fix/755-step-plan-max-tokens branch from 222bed4 to 615d5e9 Compare November 16, 2026 09:07
@NianJiuZst
NianJiuZst merged commit 72d51aa into Tencent:main Nov 16, 2026
12 checks passed
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.

[Bug]: bsk step / recipe run drop the --max-tokens budget, forcing a full-page re-capture (17k → 115k chars per action)

1 participant