Repository navigation
Conversation
GenerateTextRequest, chat completions and /v1/messages carry sampling to the serving model as far as its API takes it. A per-vendor table (registry.SamplingSupport) decides what each model gets; the adapter leaves out the rest and the response names it in ignored_parameters and X-KTMS-Ignored-Params. The no_sampling capability sends a model none. Sampling joins the response cache key.
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
…bility Dotted Claude ids no longer pass for 4.6 and earlier, prefixed OpenAI reasoning ids are recognised, and Claude 3 keeps top_p beside temperature. Claude gets no whitespace-only stop sequence. The sampling capability turns the vendor's fields on for a model whose id misleads. HTTP drops empty stop sequences, as clients sent them while ignored.
A temperature lowered to the vendor's cap is named in ignored_parameters, and /v1/messages names top_k, which no model gets. The handler skips the vendor table when the call sets no sampling.
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.
temperature,top_p,stopandseedreach the model that serves the call. Until now/v1/chat/completionsand/v1/messagesaccepted them and dropped them.What changes
GenerateTextRequestgetstemperature = 18,top_p = 19,stop = 20andseed = 21. Field 17 is left for feat(routing): data_classification restricted keeps calls on self-hosted nodes #139.stopcan be a string or an array./v1/messagestakestemperature,top_pandstop_sequences;top_kis still ignored.temperature0..2,top_p0..1, up to 16 non-empty stop sequences. Anything else getsINVALID_ARGUMENT; batch items are checked the same way.registry.SamplingSupport(m)gives each adapter its filter at build time.ConfigureOpenAI.ignored_parameters: in the response and on the first stream chunk, cached replays included. Over HTTP it is theX-KTMS-Ignored-Paramsheader.o<digit>orgpt-5at the start of the id or after/,-or_, except-chat) get none, since they reject them.random_seed; temperature is capped at 1.5.stop_sequencesalways, minus whitespace-only sequences, which Claude rejects. Temperature (capped at 1) andtop_ponly up to 4.6: the SDK sends API version 2023-06-01, and 4.7 and later accept only default sampling. From 4 on the two together are rejected, sotop_pis dropped when both are set; Claude 3 keeps both.top_p, up to 4 stop sequences.no_sampling, for a model whose API rejects what the table would send;sampling, for a model that takes its vendor's fields although its id looks otherwise: an Azure deployment name, a Claude alias, a gpt-5 run without reasoning.Behaviour change
A client that already sends
temperature(many SDKs do by default) now gets it applied. This is in CHANGELOG under Changed. The plugin skillsassessandmigratenow say 1.4 and earlier ignore these fields.Not in this PR
ignored_parametersin batch results./v1/responsessampling, which arrives with that endpoint.Review
Ten findings from /code-review.
Fixed:
claude-opus-4.7) were treated as 4.6 or earlier;top_pwas dropped on Claude 3;Also documented: batch results carry no
ignored_parameters, and the 400s for out-of-range values over HTTP.Left as is:
SamplingSupport(m)the adapter was built with. It is one function with one model, so the two cannot drift, and the cost is a regex per response.schemaTypeinto it would change what a"null"type returns.Checks
go vet ./...,go test ./... -race, andTestSkill*.Tests cover:
Apply;Closes ai-process/docs#186
Review, second pass (with #139, docs#202 and docs#193)
Open, by severity:
GenerateTextRequest(17 there, 18–21 here) and touchgateway.pb.go,grpcapi/batch.goandserver/openai_test.go;git merge-treereports conflicts in those four files. Whichever lands second must be rebased andmake protore-run: a hand-merged raw descriptor ingateway.pb.gocan panic at init or drift from the.proto.internal/llm/sampling.go,Apply). Validation accepts 0..2 for every model, but a value above a vendor's cap (Claude, Bedrock, Mistral) is lowered without a trace:temperature=1.8onclaude-sonnet-4-6runs at 1.0 with emptyignored_parametersand noX-KTMS-Ignored-Params. The one feedback channel for sampling says nothing about a changed value. Options: reporttemperaturein the list when it was capped, or a separateadjusted_parameters.OneOfTemperatureTopPon every Claude 4.x (internal/registry/sampling.go,claudeSampling). The reviewer believes the "not both" rule started with Opus 4.1, soclaude-sonnet-4-20250514/claude-opus-4-20250514losetop_pfor no reason. To confirm against the Anthropic docs before changing.ignoredParametersrecomputes the list (internal/grpcapi/sampling.go). The adapter already rana.sampling.Apply(...)and threw the list away; the handler runsregistry.SamplingSupport(m).Applyagain. Two computations of one fact, plus regex matching on the hot path. Returning the list from the adapter (onllm.Response/ the first chunk) would leave one. Kept as is for now: same function, same model, so they cannot drift today.top_kon/v1/messagesis dropped silently (internal/server/anthropic.go). The header is documented as the list of sampling fields the model did not get, yettop_kis accepted, never sent, and not reported, unliketemperature,top_pandstop_sequencesin the same request.SamplingSupport.Apply(internal/llm/sampling.go) is 4.Resolved in 5b0e3b2:
buf generatere-run, with no hand-mergedgateway.pb.go.temperatureinignored_parametersand the header. The proto, README and docs say so.temperatureandtop_perrors on every Claude 4+ model, including Sonnet 4 and Opus 4. Claude 3 keeps both.top_kon/v1/messagesis named inX-KTMS-Ignored-Params, in plain and streamed responses.Applyis down to 3 lines.Checked and fine: every vendor of the OpenAI adapter is covered by
SamplingSupport, the semantic cache includes sampling in its key throughwriteParams, andX-KTMS-Ignored-Paramsis set before the first SSE chunk.