samplingModelOptions translates the server's advisory preferences into the host's model options. Only MaxTokens is honoured today (with an upper bound enforced by the underlying provider); temperature, stop sequences, and ModelPreferences are intentionally left to the host's configuration. Structure
(req *mcp.CreateMessageParams)
| 214 | // reshape the model's reply into something the MCP server didn't ask |
| 215 | // for. |
| 216 | func samplingModelOptions(req *mcp.CreateMessageParams) []options.Opt { |
| 217 | opts := []options.Opt{ |
| 218 | options.WithStructuredOutput(nil), |
| 219 | options.WithNoThinking(), |
| 220 | } |
| 221 | if req.MaxTokens > 0 { |
| 222 | opts = append(opts, options.WithMaxTokens(req.MaxTokens)) |
| 223 | } |
| 224 | return opts |
| 225 | } |
| 226 | |
| 227 | // drainSamplingStream reads a chat completion stream to completion and |
| 228 | // returns the concatenated assistant content alongside the final finish |
no test coverage detected