Skip to content

fix(coach): retry a refused Gemini grounding turn without web search - #150

Open
foureight84 wants to merge 1 commit into
saksham2001:mainfrom
foureight84:fix/gemini-grounding-429
Open

foureight84 wants to merge 1 commit into
saksham2001:mainfrom
foureight84:fix/gemini-grounding-429

Conversation

@foureight84

Copy link
Copy Markdown
Contributor

Ports Android PR #127 (fix/123-gemini-grounding-429) to iOS.

Summary

Free-tier Gemini API keys can be refused google_search grounding with HTTP 429 RESOURCE_EXHAUSTED while plain, function-calling, and schema turns on the same key succeed. Previously this caused every Coach turn to fail whenever Web Search was enabled.

  • GeminiClient.swift:
    • When a google_search grounding turn returns HTTP 429, retries once without google_search as the plain schema turn with a note instructing the model to note in data_quality_note that web search was skipped.
    • Remembers the refused API key in-process (guarded by NSLock) so subsequent turns skip grounding without paying the extra failed round trip.
    • Non-grounding 429s and 429s on the ungrounded retry still surface normally without marking the key.

Verification

  • xcodebuild test -project PulseLoop.xcodeproj -scheme PulseLoop -destination 'platform=iOS Simulator,name=iPhone 17' -only-testing:PulseLoopTests/GeminiClientGroundingTests — 4/4 tests passed.

Port Android PR saksham2001#127:
- When a Gemini google_search grounding turn returns HTTP 429, retry once without google_search as the plain schema turn with a note that web search was skipped.
- Remember the refused API key for the process so subsequent turns skip grounding without an extra round trip; non-grounding 429s and retry 429s still surface normally.

This branch has not been deployed

No deployments
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