-
-
Notifications
You must be signed in to change notification settings - Fork 51
🐛 Fix Antigravity No-System-Prompt Compatibility and Premium Model Streaming #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Fix Antigravity No-System-Prompt Compatibility and Premium Model Streaming #66
Conversation
…m model streaming fallback Fixes Antigravity provider compatibility with OpenAI-compatible clients that don't send system prompts. ## Problem - Antigravity models return bare 429 errors when requests don't include a system prompt - This breaks compatibility with translation tools, simple chat UIs, and any OpenAI-compatible client - Premium models (Gemini 3 Pro, Claude Sonnet/Opus 4.5) reject non-streaming requests ## Solution 1. **Default System Prompt Injection** (lines 2985-2992) - When no user system prompt is provided and identity override is enabled - Inject minimal default: 'You are a helpful AI assistant.' - Matches the fallback statement in the override instruction 2. **Streaming Fallback for Non-Streaming Requests** (lines 3906-3934 + new method at 3987-4085) - Premium models reject non-streaming but accept streaming - When bare 429 occurs after retries, automatically try streaming - Collect chunks and assemble into non-streaming response - Transparent to the user - they request non-streaming and get non-streaming back ## Test Results All 9 tests passed with non-streaming mode: | Model | No Sys + No Tools | No Sys + Tools | With Sys Prompt | |------------------------|-------------------|----------------|-----------------| | gemini-3-pro-preview | ✅ PASS | ✅ PASS | ✅ PASS | | claude-sonnet-4.5 | ✅ PASS | ✅ PASS | ✅ PASS | | claude-opus-4.5 | ✅ PASS | ✅ PASS | ✅ PASS | ## Log Evidence Streaming fallback working correctly: ## Impact - ✅ Existing streaming users (OpenCode, coding agents) are NOT affected - ✅ When user requests stream: true, code takes streaming path directly - ✅ Fallback only activates for stream: false requests that fail with bare 429 - ✅ No duplication or interference with existing streaming functionality Closes: Mirrowel#63
|
Starting my review of the Antigravity no-system-prompt fix and streaming fallback logic. Diving into the provider changes to assess the retry flow and edge case handling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall Assessment
This PR introduces a solid fix for Antigravity compatibility issues with OpenAI-compatible clients. The approach of injecting a minimal default system prompt when none is provided, and transparently falling back to streaming for non-streaming requests that fail with bare 429, is pragmatic and well-justified. The implementation is clean and well-documented with clear comments explaining the rationale.
Architectural Feedback
The streaming fallback approach is sound—making the fallback transparent to clients preserves API contract expectations while working around upstream provider quirks. The _collect_streaming_as_non_streaming method cleanly separates this concern.
One consideration: the method signature for _collect_streaming_as_non_streaming has many parameters (13). While this is functional, you might consider packaging related parameters into a dataclass or NamedTuple in a future refactor to improve readability. Not blocking.
Key Suggestions
-
Bug Fix Needed:
asyncio.get_event_loop().time()should be replaced withtime.time()(see inline comment on line 4104). The current implementation produces monotonic clock values, not Unix timestamps. -
Edge Case Handling: Consider adding a fallback or warning for tool calls that arrive without an index field.
-
Observability: A warning when zero chunks are received from the streaming fallback would aid debugging.
Nitpicks and Minor Points
- The default system prompt message
"You are a helpful AI assistant."is appropriately minimal. No concerns here. - Test evidence in the PR description is thorough and confidence-inspiring.
Questions for the Author
- Have you considered adding integration tests for the streaming fallback path? Manual testing is documented, but automated coverage would catch regressions.
This review was generated by an AI assistant.
- Replace asyncio.get_event_loop().time() with time.time() for correct Unix timestamps - Add fallback handling for tool calls without index field (logs warning and appends sequentially) - Add warning log when streaming fallback receives zero chunks for better debugging Addresses suggestions from mirrobot-agent code review on PR Mirrowel#66.
|
I have a bit of a different idea. Gonna look at this asap. |
Cool, I also tested it again after the bot suggestions and implementation, here's the result of the unit test: |
|
I want to make streaming accumulation the default path. Also, the system instruction part about the role are handled in the injection, so i am not sure what it is about |
"If no user system prompt is provided, you are a helpful AI assistant" |
|
Wait. @MasuRii you saying in here: That antigravity needs AGY prompt+override+another prompt? Upd: Tested without this change with simple curl and no had no issues. |
Try testing streaming and non streaming, i think that's the main issue, the one from the extra prompt seems to be the old one that I forgot to revert to the original. I'm currently committing another new fix right now. |
I noticed earlied today non-streaming was problematic. Hence why a refactor to only have streaming internally and accumulate it. |
Refactor the provider to exclusively use the streaming endpoint (`:streamGenerateContent`) internally for all API interactions. Requests with `stream=False` now consume the stream and aggregate chunks into a single response. - Solves persistent stability issues and "bare 429" errors observed with premium models (e.g., Gemini 3 Pro) on non-streaming endpoints. - Eliminates the separate `_handle_non_streaming` path and its specific retry logic, unifying error handling under the streaming implementation. - Updates the identity override system instruction to be more robust when no user system prompt is provided.
📝 Summary
Fixes Antigravity provider compatibility with OpenAI-compatible clients that don't send system prompts. Implements two key solutions: default system prompt injection for requests without user system prompts, and a transparent streaming fallback for premium models (Gemini 3 Pro, Claude Sonnet/Opus 4.5) that reject non-streaming requests.
✨ Changes
1. Default System Prompt Injection (Lines 2985-2992)
"You are a helpful AI assistant."2. Streaming Fallback for Non-Streaming Requests (Lines 3906-3934 + New Method 3987-4085)
📁 Files Changed
src/rotator_library/providers/antigravity_provider.py🧪 Testing Instructions
Test Results - All 9 Tests Passed ✅
Log Evidence of Streaming Fallback
🔗 Impact Analysis
✅ Existing Streaming Users NOT Affected
stream: true, the code takes the streaming path directlystream: falserequests that fail with bare 429✅ Compatibility Improved
🔧 Technical Details
Changes Overview
_collect_streaming_as_non_streaming()for transparent streaming fallbackBreaking Changes: None
This fix is fully backward compatible and only improves functionality.
📋 Checklist
🎯 Why This Fix Is Needed
This fix resolves critical compatibility issues that prevent many OpenAI-compatible tools from working with Antigravity providers:
Without this fix, users would see bare 429 errors and be unable to use Antigravity with these tools. With this fix, these tools work seamlessly while maintaining full backward compatibility.
Important
Fixes Antigravity compatibility with clients lacking system prompts and adds streaming fallback for premium models rejecting non-streaming requests.
antigravity_provider.pywhen no user system prompt is provided and identity override is enabled.antigravity_provider.pyfor premium models (Gemini 3 Pro, Claude) that reject non-streaming requests, collecting streaming chunks into a non-streaming response._collect_streaming_as_non_streaming()inantigravity_provider.pyto handle streaming fallback.acompletion()inantigravity_provider.pyto attempt streaming fallback after retries.This description was created by
for 5c61827. You can customize this summary. It will automatically update as commits are pushed.