Skip to content

feat(task): task-local runtime thinking effort state with per-request override (DTE series 2/5) - #38

Closed
easonLiangWorldedtech wants to merge 1 commit into
feat/dte-v2-2-per-request-effortfrom
feat/dte-v2-3-task-runtime-effort
Closed

feat(task): task-local runtime thinking effort state with per-request override (DTE series 2/5)#38
easonLiangWorldedtech wants to merge 1 commit into
feat/dte-v2-2-per-request-effortfrom
feat/dte-v2-3-task-runtime-effort

Conversation

@easonLiangWorldedtech

@easonLiangWorldedtech easonLiangWorldedtech commented Sep 4, 2026

Copy link
Copy Markdown
Owner

≤400-line redo of Zoo-Code-Org#1338 — DTE series 2/5, unit 3/5

Task-local runtime thinking-effort state on Task: the in-memory override
channel, its per-request delivery at all four createMessage sites, and the
profile-switch re-capture in updateApiConfiguration. Transient state only —
nothing is persisted; persistence is the next unit (U4).

Stack

Budget (plan §2: a+d ≤ 400)

2 files changed, 397 insertions(+), 1 deletion(-) = 398 ≤ 400

File a+d
src/core/task/Task.ts 96+/1−
src/core/task/__tests__/Task.runtime-thinking-effort.test.ts (new) 301+

Budget deviation note (plan §2.6). The plan estimated U3 at ~355
(Task +132/−3 + tests ≈220); those numbers were stale. Measured against the
union, the U3 slice is Task +105/−1 + a 311-line test file = 417 > 400. Per
§2.6 (no budget bypass), the dispose boundary group is split into U4:
the task-end override reset (6 Task lines + 3 DTE JSDoc lines) and its
12-line describe("dispose") test block. This matches the plan's own U4 scope
line ("persistence + boundary cases"). U3 keeps the generic 4-line dispose()
JSDoc; U4 expands it with the DTE sentence alongside the reset code.

Provenance / fidelity

  • Task.ts: 3-way git merge-file — base 39bdfb188 (= 6ea45b36a^),
    ours = U2 head, theirs = 90b47b053 (the last U3 commit, before the U4
    persistence work). Zero conflicts. A whole-file extract was impossible:
    the union's Task.ts carries U14-orchestrator and U4/U5 content
    (215+/241− vs U1 head), and per-commit git apply --3way of the U3 patches
    fails on upstream base drift.
  • Test file: byte-exact 90b47b053 version (311 lines) minus the dispose
    describe (12 lines + separator), plus the 3 mutation-killing assertion
    lines below = 301 lines; the header comment is trimmed to the U3 scope
    ("the task-end reset in dispose()" clause moves with U4).
  • U4 content excluded: taskMetadata.ts / history.ts persistence changes,
    the describe("history persistence round-trip") and
    describe("abortTask final save") blocks, and the HistoryItem import
    (unused in the U3 slice).
  • src/eslint-suppressions.json: untouched. The union's +8/−3 suppression
    deltas are all in files owned by other units
    (gemini-format.spec.ts 5→6, ask-queued-message-drain.spec.ts 18→32,
    newTaskTool.spec.ts 26→31, new extension.ts 1) — none U3-owned.

Out of scope (next units)

  • U4 (DTE-2c): persist task thinking effort to history items,
    taskMetadata merge propagation, and the task-end override reset split out
    above (dispose boundary + its test).
  • U5 (DTE-2d): the Anthropic output_config.effort adaptive envelope.

Mutation-diff fix (killing assertions, plan L42 — same PR)

The first CI mutation-diff run (head d0b1a3dcd) reported 2 Survived
ConditionalExpression mutants — both on the two ternaries this unit
introduces:

Location Surviving variant Fix (this PR)
setRuntimeThinkingEffort source capture: effort === undefined ? undefined : source replacement: false → always source: a label passed on a clearing call leaks into source the clearing call now carries a label (setRuntimeThinkingEffort(undefined, "stale-source")); the existing source: undefined assertion then kills the variant
getRuntimeThinkingEffortMetadata: effort !== undefined ? { reasoningEffort } : {} replacement: true → always { reasoningEffort: <maybe undefined> } key-absence assertion not.toHaveProperty("reasoningEffort") while unset — toEqual({}) cannot kill it (toEqual ignores keys whose value is undefined); asserted pre-set and post-clear

The complementary variants (L1683-true, L1721-false) were already killed by
the existing toBe("test-source") and toEqual({ reasoningEffort: "high" })
assertions.

Local dev-stage gate on the amended head (§5.1):
node scripts/stryker-diff.mjs ci --base 82358bdfc --head 4075c8a75
extension 35 changed lines, 18 ranges, exit 0, 0 Survived.

Verification (local)

  • pnpm --dir src exec eslint --prune-suppressions --max-warnings=0 core/task/Task.ts core/task/__tests__/Task.runtime-thinking-effort.test.ts → exit 0 (no suppression-count change)
  • pnpm check-types → 11/11 projects
  • pnpm --dir src exec vitest run core/task/__tests__/Task.runtime-thinking-effort.test.ts → 8/8 (18.8 s)
  • git diff --shortstat 82358bdfc HEAD → 397+/1− = 398 ≤ 400
  • mutation-diff gate (dev stage, §5.1) on the amended head → exit 0, 0 Survived (see fix above)

… override (DTE series 2/5)

- Task: setRuntimeThinkingEffort/getRuntimeThinkingEffort with in-memory
  apiConfiguration merge/restore; per-request metadata at all four
  createMessage sites; profile-switch re-capture in updateApiConfiguration
- Transient state only: never persisted to settings or history
- Tests: 8 focused vitest cases (state machine, profile switch, metadata
  fragment, non-persistence)

Part of #35 (DTE-v2 ship plan, unit 3/5).
@easonLiangWorldedtech

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR Zoo-Code-Org#1523 (DTE-v2 stack moved upstream — CodeRabbit only runs there). Same head 4075c8a, same content.

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.

2 participants