Skip to content

fix(ptc): stop calling wait_agent and multi-dispatch programs a single operation (#893) - #938

Open
Y-fyan wants to merge 1 commit into
T-Auto:mainfrom
Y-fyan:fix/893-batching-shape
Open

Y-fyan wants to merge 1 commit into
T-Auto:mainfrom
Y-fyan:fix/893-batching-shape

Conversation

@Y-fyan

@Y-fyan Y-fyan commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Closes #893

Split out from #899 per review feedback, with job_output and wait: true also scoped out of comments and string literals.

What was wrong

  • WAITING in src/ptc/batching-guidance.ts did not recognize tools.wait_agent(...) or tools["wait_agent"](...) calls, and violationsOf(shape) did not exclude shape.isWaiting from the shape violation. In addition, WAITING matched against raw code, so // job_output( or "wait: true" inside a comment or string literal still set isWaiting.
  • violationsOf(shape) triggered on shape.dispatchSites >= 1 whenever a short program had no loop/Promise.all/branching, misclassifying sequential multi-dispatch scripts (such as a grep whose result determines the next read_file) as "The program ran a single operation".

The change

  • src/ptc/batching-guidance.ts:
    • Match wait_agent and job_output only at real tools.* / tools["..."] dispatch sites (WAITING_TOOL = /^(?:wait_agent|job_output)$/u) and match wait: true against readable.bare, so comments and string literals never set isWaiting.
    • Tighten the shape violation condition in violationsOf(shape) to shape.dispatchSites === 1 && !shape.hasBatchingStructure && !shape.hasBranching && !shape.isWaiting && shape.chars < THIN_CODE_CHARS.
  • test/batching-trigger.test.mjs & docs/CHANGELOG.md:
    • Pin dot/bracket wait_agent, comment/string counterexamples for wait_agent, job_output and wait: true, dependent multi-dispatch programs, single-read regression, and independence of plan/bypass checks.
    • Add bilingual ## [Unreleased] entry in docs/CHANGELOG.md.

Validation

  • One pull_request-triggered CI required run, URL below
  • npm run build, npm run typecheck, npm run check:size, and node test/run.mjs batching-trigger pass
  • Reverting src/ptc/batching-guidance.ts turns the two new assertions in batching-trigger red
  • docs/CHANGELOG.md ## [Unreleased] entry added (English and Chinese)
  • No dependency, package.json version, or optionalDependencies change; no model-facing schema/prompt change
$ npm run build
build: bundled 11 browser modules (92116 bytes)
build: generated PTC declarations for 18 capabilities (120358 bytes)
build: compiled src/ to lib/ and copied 60 assets

$ npm run typecheck
(exit 0)

$ npm run check:size
check-file-size: 820 code file(s) checked, all at or under 1000 lines (longest: native/crates/ops-search/src/lib.rs (928))

$ node test/run.mjs batching-trigger
dsh-ops batching-trigger: all 16 checks passed

Revert-red verification:

$ git checkout HEAD~1 -- src/ptc/batching-guidance.ts && npm run build && node test/run.mjs batching-trigger
  FAIL waiting on an agent is a dependency barrier, read only from a real dispatch site (#893)
  FAIL only a single dispatch site earns the single-operation shape notice (#893)
dsh-ops batching-trigger: 2 of 16 check(s) failed

Environment

Linux x64, Node v22.22.1, based on upstream main commit 88ecc72, local source checkout.

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] batching shape 将 wait_agent 等待及有依赖的多次派发误判为 single operation

1 participant