Skip to content

fix(types): set optimal default top_p threshold for nucleus sampling - #3048

Closed
adri22235 wants to merge 22 commits into
googleapis:mainfrom
adri22235:fix/clean-top-p
Closed

adri22235 wants to merge 22 commits into
googleapis:mainfrom
adri22235:fix/clean-top-p

Conversation

@adri22235

Copy link
Copy Markdown

Summary

This pull request ensures an explicit default top_p=0.95 is maintained across generation configuration classes in google/genai/types.py (GenerateContentConfig, GenerationConfig, Model, and LiveConnectConfig).

Motivation & Context

Provides a reliable nucleus sampling anchor to eliminate reasoning drift, token repetition loops, and hallucinations during thinking modes under default temperature: 1.0.

This directly addresses the SDK control surface requirements and reasoning calibration tracked in Issue #2954.

Key Changes

  • Explicitly set default=0.95 inside Field(...) for top_p in google/genai/types.py.

Verification

  • Tested and verified locally on Debian 12 (Bookworm).
  • Passed clean import and mypy type checking tests with zero syntax or duplicate argument errors.
  • Contributor License Agreement (CLA) signed by author (@adri22235).

claude and others added 22 commits September 27, 2026 21:56
- types: add FinishReason.MALFORMED_RESPONSE, which the API returns
  (googleapis#2937).
- _api_client: use `await asyncio.sleep` instead of `time.sleep` in the
  httpx branch of the async upload retry, so the backoff no longer blocks
  the event loop (googleapis#2938).
- _transformers: keep annotations next to a `$ref` (e.g. a field-level
  `description`) when inlining the referenced definition in
  response_schema, instead of overwriting them with the shared model's
  (googleapis#3007).
- _common: serialize Pydantic's deferred model build through a lock, since
  `defer_build=True` is not thread safe and concurrent first use could see
  a half-built model (googleapis#2991).
- _api_client: in `__del__`, close each aiohttp session on the event loop
  that created it and keep strong references to the scheduled close tasks
  so they are not destroyed while pending (googleapis#2995).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R97bRW4GzCnhFEm2VhymSq
@adri22235

Copy link
Copy Markdown
Author

Cerrado para limpieza de ramas.

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.

2 participants