Skip to content

Add fuzz testing for Google/Gemini and fix roundtrip issues#114

Open
Matt Perpick (clutchski) wants to merge 4 commits intomainfrom
matt/more-fuzz
Open

Add fuzz testing for Google/Gemini and fix roundtrip issues#114
Matt Perpick (clutchski) wants to merge 4 commits intomainfrom
matt/more-fuzz

Conversation

@clutchski
Copy link
Contributor

Summary

  • Add property-based fuzz testing for Google/Gemini provider following existing Anthropic/Responses patterns
  • Add Google Discovery JSON spec loader for schema-driven payload generation
  • Fix roundtrip losses in Google adapter: seed, presencePenalty, frequencyPenalty now map to universal params; safetySettings, cachedContent, and generationConfig extras (candidateCount, speechConfig, responseModalities, mediaResolution, responseLogprobs, etc.) are preserved through provider extras
  • Add cross-provider roundtrip test (Google -> OpenAI -> Google) for universal params
  • Add Python validation script for testing payloads against real Gemini API

Test plan

  • All 6 Google adapter unit tests pass (including cross-provider roundtrip)
  • cargo test -p lingua --test fuzz (non-ignored) -- all 14 saved snapshot tests pass
  • Validated 16 suspected issues against real Gemini API before fixing
  • Review remaining 14 fuzz snapshots for further fixes (toolConfig, systemInstruction, part-level fields)

🤖 Generated with Claude Code

Adds Google roundtrip and Chat->Google two-arm fuzz suites following the
existing pattern for OpenAI/Anthropic. Includes a Discovery JSON schema
loader, prop_filter for valid API payloads, and a Python validation script
for checking payloads against the real Gemini API.

Also defaults missing Content.role to "user" to match real API behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…specific extras

Map seed, presencePenalty, frequencyPenalty from generationConfig to universal
params directly. Store safetySettings, cachedContent, and remaining generationConfig
fields (candidateCount, speechConfig, responseModalities, etc.) in provider extras
so they survive roundtrips. Reconstruct them in request_from_universal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace direct .get("...") calls with GENERATION_CONFIG_EXTRAS_KEY constant
in production code and typed GoogleParams/OpenAIChatParams deserialization
in test assertions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GenerationConfig.response_schema is Box<Option<Schema>> which serializes
as null when None. Strip null entries from the serialized config to avoid
spurious output. Update vitest snapshots to reflect seed, presencePenalty,
and frequencyPenalty now correctly appearing in generationConfig output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant