th-1cc9fa: model-output ceiling clamp + raise defaults (Python server → main)#197
Merged
Conversation
…thon server) Additive onto main: cherry-picked the Python-server clamp from the stale localflavor-hardening branch (f556862) and reconciled with main's evolved turn_runner (kept main's extension-host wiring, added the raised defaults + per-turn ceiling lookup). - Raise anti-starvation turn sizing: max_tokens 512 -> 8192 (DEFAULT_MAX_TOKENS), max_iterations 6 -> 20 (DEFAULT_MAX_ITERATIONS). The old chat-widget sizing starves reasoning models (empty replies / truncated tool loops). - New model_info.py: best-effort per-model output ceiling from the gateway's /model/info (map_model_info + model_output_ceiling), cached once per process, stdlib fetch, no extra deps. No key / any error / unknown model -> None -> unclamped. - Thread the resolved ceiling into AgentOptions.model_max_output so the engine clamps max_tokens to what the model can emit. Feature-detected against the core. - Bump the core pin to the published PyPI smooai-smooth-operator-core>=1.3.2 and drop the git-rev source (1.3.2 ships BOTH the clamp field and the SEP extension host the git rev was pinned for), so the clamp is LIVE (_CORE_SUPPORTS_CEILING now True), not dormant. Tests: 138 passed, 0 skipped (the forward-compat clamp test now runs against the clamp-capable 1.3.2). ruff check + format clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Python WebSocket server (
python/server/) shipped with chat-widget turn sizing (max_tokens=512,max_iterations=6) that starves reasoning models — they exhaust the budget on reasoning and return empty replies / truncated tool loops. It also had no per-model output ceiling, so it couldn't safely raisemax_tokens. This is the Python-server parity for the Rust/Go server hardening already on main (#193).The change lived only on the stale
localflavor-hardening-based branchth-1cc9fa-py-ceiling; this brings it tomainadditively.Solution
Cherry-picked the clamp commit (
f556862) and reconciled with main's evolvedturn_runner(kept main's extension-host wiring; added the raised defaults + per-turn ceiling lookup):DEFAULT_MAX_TOKENS512→8192,DEFAULT_MAX_ITERATIONS6→20 (mirrors the Rust/Go server constants).model_info.py: best-effort per-model output ceiling from the gateway's/model/info(map_model_info+model_output_ceiling), cached once per process, stdlib fetch, no extra deps. No key / any error / unknown model →None→ unclamped.AgentOptions.model_max_outputso the engine clampsmax_tokensdown to what the model can physically emit. Feature-detected against the pinned core.smooai-smooth-operator-core>=1.3.2and drop the git-rev source — 1.3.2 ships both the clamp field (model_max_output) and the SEP extension host the git rev was pinned for, so the clamp is now LIVE (_CORE_SUPPORTS_CEILING→ True), not dormant.Verification
uv syncresolves 1.3.2 from PyPI cleanly.uv run pytest→ 138 passed, 0 skipped (the forward-compat clamp test now runs against the clamp-capable 1.3.2).uv run ruff check .+ruff format --check .→ clean._CORE_SUPPORTS_CEILING=True,DEFAULT_MAX_TOKENS=8192,DEFAULT_MAX_ITERATIONS=20.🤖 Generated with Claude Code