Repository navigation
Conversation
…puts The transport clamp and the host-facing route_effective_max_output_tokens held two parallel copies of normalize-then-intersect. Both now delegate to a single route_budget helper so they cannot drift from each other. The wrapper test gains a Some(RouteLimits) control (the doc's primary instructed input) and a normalization-sensitive pin (OpenRouter kimi-code: 32,768 canonicalized vs 8,192 raw uncatalogued), and states what the DeepSeek alias leg actually pins. The wrapper doc records the window-clamp arithmetic, the dispatched-base_url contract, and the full rename set; #[must_use] aligns the wrapper with the layers beneath it. Signed-off-by: asto <asto18089@126.com>
Fresh from-scratch review — round 1 (6 parallel lanes + local gate replication + mutation battery)Head reviewed: Verdict: approve-grade. 0 BLOCKER / 0 MAJOR / 2 MINOR (both body-level) / 5 NITs. Everything below was re-derived from primary sources on this exact head, not taken from the PR's own claims. 1. Useful, complete, root-caused — yes
2. Elegant — yesMinimal +82/−16; no wheel reinvention (the helper composes two existing functions); correct home (route_budget owns the budget math), 3. Smuggling — cleanEvery hunk maps 1:1 to the four claimed changes; 4. Bug-free — verified; gates and mutations re-run by me on the final tree
MINORs / NITs (none blocking; all are text-level)
Fork boundary: purely fork-local surface — upstream (codewhale-hq/Codewhale) has no |
JensenChen28
left a comment
There was a problem hiding this comment.
Approved at the reviewed head. The shared helper preserves the existing normalize-then-intersect behavior for both the client clamp and host wrapper, and the scoped follow-ups/tests are present. I found no blocking implementation issue.
Non-blocking documentation note: context.rs says custom endpoints “skip normalization entirely,” but wire_model_for_provider_route still normalizes OpenCode Go with an overridden base URL; consider qualifying that statement.
The current GitHub checks failed before executing steps (the reported jobs have empty step lists); the PR author reports local checks, which I did not independently rerun.
Why
No-Issue: fork-local test/documentation tightening recorded in the CodeWhale#150 review thread (JensenChen28's 2026-11-07 acknowledgment and #150's own follow-up notes); no issue tracks it (repository has issues disabled).
#150 (merged as
e972a9a05) exposedroute_effective_max_output_tokensfor hosts. Its review recorded bounded follow-ups: aSome(RouteLimits)control through the wrapper, an honest statement of what the DeepSeek alias leg pins, and closing the latent client-flow drift lane. This PR lands those. (The EnvVarGuard half of the recorded follow-up already landed pre-merge atdc73de769.)What
pub(crate) route_budget::route_effective_max_output_tokens; the transport clamp (client.rs::effective_max_output_tokens_with_limits) and the host-facingcore::engine::route_effective_max_output_tokensboth delegate to it. Previously the composition existed as two parallel copies — the exact "silently drifting from the engine" failure mode the wrapper exists to prevent. Behavior-identical: the helper performs the same two calls the clamp inlined (wire_model_for_provider_route→effective_max_output_tokens_for_route).Some(RouteLimits)control through the wrapper: a route-declared output ceiling clamps the catalogue cap exactly as the main turn'sactive_route_limitsdo, and the composition equality holds with limits attached. This is the doc's primary instructed input; until now only theNonecatalogue-default path was pinned through the wrapper.kimi-codecanonicalizes tomoonshotai/kimi-k2.7-code→ catalogued 32,768; raw, it is uncatalogued and fails closed at 8,192. Deleting the normalization call now turns the test red (mutation-verified). The previous test could not observe normalization loss: Moonshot is pass-through and the DeepSeek alias pair is budget-invariant throughprovider_capability's alias arms — recognition redundancy, which the DeepSeek leg's comment now states explicitly instead of implying it guards normalization.#[must_use]on the wrapper: the window rung clamps towindow − 2_048(input floor + headroom reserve) and the result is floored at 1;base_urlmust be the endpoint the request dispatches on (custom endpoints own their model-id namespace and skip normalization); themax_completion_tokensrename set is Xiaomi MiMo, OpenAI reasoning families, MiniMax M3, and the direct Moonshot K3 route (perapply_provider_token_limit).#[must_use]aligns the wrapper with both layers beneath it (route_budget.rs,client.rs).Verification
cargo fmt --all -- --checkclean;gitleaks dir .0 findings.CODEWHALE_MAX_OUTPUT_TOKENS=16384now passes — the guards strip ambient overrides); k3 route pin, uncatalogued pin, and the clienteffective_max_output_tokens*tests green (delegation sanity).kimi-codeleg 32,768 → 8,192); swapping the helper'sbase_url/modelargs → red (both the kimi-k3 pin and thekimi-codeleg fall to 8,192); revert → green again.Notes
route_effective_max_output_tokens_matches_the_transport_compositionis unchanged, so the parent-side fingerprint registration from the feat(engine): expose route output budget to hosts #150 gitlink batch stays valid; the new test legs are additive and will need parent fingerprint rows at the next gitlink bump (parent AGENTS.md §2).turn_loop.rs's main-turn cap computation (it readssession.modelwithout normalization; parity holds because the route install makes that the wire id) with the client-side clamp — a production-path change beyond this bounded follow-up.