Repository navigation
Conversation
Model params.topP and params.top_p reach the stream options as topP, but the Google transports only copied temperature, maxTokens and stop into the request, so Gemini generateContent, Vertex and Interactions requests went out without nucleus sampling. Map topP to generationConfig.topP and generation_config.top_p.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThe PR forwards configured nucleus sampling values into three Google request formats. Example: Use google/gemini-2.5-flash through GenerateContent with params.topP set to 0.4.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 2 items remain This PR addresses a documented sampling bug, but its fix remains incomplete: Google's simple-stream adapters discard topP before the patched builders receive it. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherAgent config resolves topP and top_p into stream options; Google adapters project those options into GenerateContent or Interactions requests and consume streamed responses. flowchart TD
A[Model sampling configuration] --> B[Extra params resolver]
B --> C[Google plugin transport]
C --> D[GenerateContent request builder]
C --> E[Interactions simple adapter]
E --> F[Interactions request builder]
D --> G[Google HTTP endpoint]
F --> G
Technical reviewBest possible solution: Preserve topP through Google's existing simple-stream adapters and retain the three native request mappings. Do we have a high-confidence way to reproduce the issue? Current source establishes the request-field omission and the remaining simple-adapter drop; the contributor supplies a GenerateContent CLI reproduction, and this review ran no target code. Is this the best way to solve the issue? Mapping the existing option at each wire builder is appropriate, but the complete fix must also preserve it across the Google simple-stream projections. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b1b0a88900d8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +9, Tests +13. Total +22 across 6 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 31, 2026, 11:57 PM ET / November 1, 2026, 03:57 UTC. |
fix(google): forward the configured topP to Gemini requests Fixes #190468. A configured `topP` was dropped from Gemini requests on the Interactions, GenerateContent and Vertex routes, so the model ran with the provider default. The existing `topP` option is now passed through the Google adapter to all three request builders. When `topP` is not set, it is left out, and other generation parameters are unchanged. No public SDK export changes. Evidence: built CLI in secretless Node 24.22.1 Docker with local Interactions and GenerateContent fixtures and a faithful Vertex wire fixture. On each route, main dropped `topP` twice and this change forwarded it twice, for both spellings. Unset controls left it out, and other generation parameters matched in 9 of 9 comparisons. Details: #190695 (comment). Thanks @Yigtwxx, and @yetval for the earlier attempt in #190054. Co-authored-by: Ayaan Zaidi <[email protected]>
fix(google): forward the configured topP to Gemini requests Fixes openclaw#190468. A configured `topP` was dropped from Gemini requests on the Interactions, GenerateContent and Vertex routes, so the model ran with the provider default. The existing `topP` option is now passed through the Google adapter to all three request builders. When `topP` is not set, it is left out, and other generation parameters are unchanged. No public SDK export changes. Evidence: built CLI in secretless Node 24.22.1 Docker with local Interactions and GenerateContent fixtures and a faithful Vertex wire fixture. On each route, main dropped `topP` twice and this change forwarded it twice, for both spellings. Unset controls left it out, and other generation parameters matched in 9 of 9 comparisons. Details: openclaw#190695 (comment). Thanks @Yigtwxx, and @yetval for the earlier attempt in openclaw#190054. Co-authored-by: Ayaan Zaidi <[email protected]>
Summary
A Gemini model configured with nucleus sampling (
agents.defaults.models["google/<model>"].params.topP, or the documentedparams.top_palias) sends notopPto Google. The shared extra-params wrapper resolves either spelling into thetopPstream option, asdocs/gateway/config-agents/models.mddocuments ("Nucleus sampling acceptsparams.topPorparams.top_p"), and OpenAI and Ollama honor it, but every Google request builder drops it.temperaturefrom the sameparamsblock does reach the request, so the dropped value is silent.Root cause
The Google transports copy only
temperature,maxTokensandstopfrom the stream options into the request.extensions/google/transport-stream.ts(buildGoogleGenerativeAiParams, used for Gemini API and Vertex turns):The same gap exists in
packages/ai/src/providers/google-interactions-request.ts(buildGoogleInteractionsParams, whose request type already declaresgeneration_config.top_pbut never sets it) and inpackages/ai/src/providers/google-shared.ts(buildGoogleGenerateContentParams, the built-in Gemini path).Fix
Each Google request builder maps the
topPstream option to its native field, next totemperature:Interactions writes
generation_config.top_p, and the built-in generateContent builder writesconfig.topP.GoogleTransportOptionsandGoogleProviderOptionsgaintopP?: number, matching how the OpenAI and Ollama transports type the same option.Why this is the right boundary
Config resolution is already correct:
createStreamFnWithExtraParamsresolvestopP/top_pinto onetopPstream option for every provider, and the OpenAI and Ollama transports consume it. The drop happens only where the Google transports build their wire payload, so the mapping belongs in those builders. All three Google request shapes (generateContent via the plugin, Interactions, and the built-in generateContent path) are covered so no Google route keeps the gap. Nothing is sent unlesstopPis configured or passed per request, so existing requests are byte-identical. Other transports are untouched.Verification
extensions/google/transport-stream.request-config.test.ts: the generation config built bybuildGoogleGenerativeAiParamsnow includestopP: 0.4next to temperature, max output tokens and stop sequences.packages/ai/src/providers/google-interactions-shared.convert.test.ts:buildGoogleInteractionsParamsemitsgeneration_config: { temperature: 0.2, top_p: 0.4 }.packages/ai/src/providers/google-shared.test.ts:buildGoogleGenerateContentParamsemitsconfig.topP.node scripts/run-vitest.mjs <file>: the new assertions fail on pristine main and pass with the patch.oxfmt --checkis clean on all changed files.Real behavior proof
Behavior addressed: A configured Gemini
params.topP(orparams.top_p) was resolved by OpenClaw but never sent in the GooglestreamGenerateContentrequest, whiletemperaturefrom the same block was sent.Real environment tested: The real CLI from source,
node --import tsx/esm src/entry.ts agent --local --agent main --message ping --json, with an isolatedHOME/OPENCLAW_STATE_DIRwhoseopenclaw.jsonsetsagents.defaults.model.primary: "google/gemini-2.5-flash",agents.defaults.models["google/gemini-2.5-flash"].params: { temperature: 0.2, topP: 0.4 }, andmodels.providers.google.baseUrlpointing at a loopback HTTP server that stands in for the Gemini API, records each request body and answers with one SSE chunk (pong). The bundled Google plugin, its transport, the extra-params wrapper, config loading and the embedded agent run are all real; only the Google HTTP endpoint is replaced. Run on pristine main 72cab24, then on this patch with identical config.Exact steps or command run after this patch:
HOME=$H OPENCLAW_HOME=$H OPENCLAW_STATE_DIR=$H/.openclaw node --import tsx/esm src/entry.ts agent --local --agent main --message ping --json, then printed thegenerationConfigof the recorded request; repeated withparams.top_p: 0.7instead oftopPto cover the documented alias.Evidence after fix:
Observed result after fix: The Gemini request now carries the configured nucleus sampling value (
topP: 0.4, and0.7viatop_p) next totemperature; on main the same config produced a request withtemperatureonly.What was not tested: No live Google API request (loopback endpoint only); the Interactions and Vertex routes were not driven end to end through the CLI, only the shared request builders; full build not run.