Skip to content

th-1cc9fa: model-output ceiling clamp + raise starvation defaults (.NET parity)#74

Merged
brentrager merged 1 commit into
mainfrom
th-1cc9fa-dotnet-ceiling
Jul 8, 2026
Merged

th-1cc9fa: model-output ceiling clamp + raise starvation defaults (.NET parity)#74
brentrager merged 1 commit into
mainfrom
th-1cc9fa-dotnet-ceiling

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

What

.NET parity for the model-output-token ceiling clamp already merged in the Rust engine (#69, th-562b6d).

AgentOptions gains:

  • MaxOutputTokens — the per-turn output budget (the request's max_tokens). null (default) leaves it unset (passthrough).
  • ModelMaxOutputTokens — the model's HARD output ceiling (max_output_tokens), sourced from the gateway's /model/info by the consumer.
  • EffectiveMaxTokens = min(budget, ceiling) — never 0; null/≤0 ceiling ⇒ no clamp.

SmoothAgent now sends the clamped value as ChatOptions.MaxOutputTokens on every model call.

Why

A budget max_tokens can exceed what a model can physically emit → a reasoning model burns the budget on reasoning and returns EMPTY, or the upstream 400s (e.g. groq-compound caps output at 8192 under a 32768 budget). Clamping to min(configured, model.max_output_tokens) fixes it. Mirrors the Rust with_model_ceiling / effective_max_tokens.

Files

  • dotnet/core/src/AgentOptions.cs — the three properties + clamp.
  • dotnet/core/src/SmoothAgent.csBuildChatOptions sends the clamped budget.
  • dotnet/core/src/LlmProvider.csMockLlmProvider.RecordedCall captures MaxOutputTokens (test support).
  • dotnet/core/tests/MaxTokensCeilingTests.cs — 9 tests: clamp-down / passthrough / null / zero-ceiling-ignored / never-0 + end-to-end.
  • Bumps the NuGet package 1.4.0 → 1.5.0 so the server can consume the new API.

Tests

dotnet build + dotnet test on the full .slnx (Release): 133 passed, 2 skipped (network SkippableFacts).

🤖 Generated with Claude Code

…ET parity)

AgentOptions gains MaxOutputTokens (budget), ModelMaxOutputTokens (the model's
hard output ceiling), and EffectiveMaxTokens = min(budget, ceiling) (never 0;
null budget leaves max_tokens unset; null/<=0 ceiling = graceful passthrough).
SmoothAgent sends the clamped value as ChatOptions.MaxOutputTokens. Mirrors the
Rust engine's with_model_ceiling / effective_max_tokens so a policy/budget
max_tokens can never exceed what a model can physically emit — otherwise a
reasoning model burns its budget on reasoning and returns empty, or the upstream
400s (e.g. groq-compound caps output at 8192). The ceiling is sourced from the
gateway's /model/info by the consumer, kept out of the published engine.

Bumps the NuGet package 1.4.0 -> 1.5.0 so the server can consume the new API.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5776acb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smooai/smooth-operator-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brentrager
brentrager merged commit 4755fcc into main Jul 8, 2026
3 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.

1 participant