th-1cc9fa: model-output ceiling clamp + raise starvation defaults (.NET parity)#74
Merged
Merged
Conversation
…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 detectedLatest commit: 5776acb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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.
What
.NET parity for the model-output-token ceiling clamp already merged in the Rust engine (#69, th-562b6d).
AgentOptionsgains:MaxOutputTokens— the per-turn output budget (the request'smax_tokens).null(default) leaves it unset (passthrough).ModelMaxOutputTokens— the model's HARD output ceiling (max_output_tokens), sourced from the gateway's/model/infoby the consumer.EffectiveMaxTokens=min(budget, ceiling)— never 0;null/≤0 ceiling ⇒ no clamp.SmoothAgentnow sends the clamped value asChatOptions.MaxOutputTokenson every model call.Why
A budget
max_tokenscan 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-compoundcaps output at 8192 under a 32768 budget). Clamping tomin(configured, model.max_output_tokens)fixes it. Mirrors the Rustwith_model_ceiling/effective_max_tokens.Files
dotnet/core/src/AgentOptions.cs— the three properties + clamp.dotnet/core/src/SmoothAgent.cs—BuildChatOptionssends the clamped budget.dotnet/core/src/LlmProvider.cs—MockLlmProvider.RecordedCallcapturesMaxOutputTokens(test support).dotnet/core/tests/MaxTokensCeilingTests.cs— 9 tests: clamp-down / passthrough / null / zero-ceiling-ignored / never-0 + end-to-end.Tests
dotnet build+dotnet teston the full.slnx(Release): 133 passed, 2 skipped (network SkippableFacts).🤖 Generated with Claude Code