code-puppy 0.0.350__py3-none-any.whl → 0.0.351__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -215,9 +215,39 @@ class AntigravityModel(GoogleModel):
215
215
  response = await client.post(url, json=body)
216
216
 
217
217
  if response.status_code != 200:
218
- raise RuntimeError(
219
- f"Antigravity API Error {response.status_code}: {response.text}"
220
- )
218
+ # Check for corrupted thought signature error and retry
219
+ # Error 400: { error: { code: 400, message: Corrupted thought signature., status: INVALID_ARGUMENT } }
220
+ error_text = response.text
221
+ if (
222
+ response.status_code == 400
223
+ and "Corrupted thought signature" in error_text
224
+ ):
225
+ logger.warning(
226
+ "Received 400 Corrupted thought signature. Backfilling signatures and retrying."
227
+ )
228
+ _backfill_thought_signatures(messages)
229
+
230
+ # Re-map messages
231
+ system_instruction, contents = await self._map_messages(
232
+ messages, model_request_parameters
233
+ )
234
+
235
+ # Update body
236
+ body["contents"] = contents
237
+ if system_instruction:
238
+ body["systemInstruction"] = system_instruction
239
+
240
+ # Retry request
241
+ response = await client.post(url, json=body)
242
+ # Check error again after retry
243
+ if response.status_code != 200:
244
+ raise RuntimeError(
245
+ f"Antigravity API Error {response.status_code}: {response.text}"
246
+ )
247
+ else:
248
+ raise RuntimeError(
249
+ f"Antigravity API Error {response.status_code}: {error_text}"
250
+ )
221
251
 
222
252
  data = response.json()
223
253
 
@@ -318,24 +348,56 @@ class AntigravityModel(GoogleModel):
318
348
 
319
349
  # Create async generator for SSE events
320
350
  async def stream_chunks() -> AsyncIterator[dict[str, Any]]:
321
- async with client.stream("POST", url, json=body) as response:
322
- if response.status_code != 200:
323
- text = await response.aread()
324
- raise RuntimeError(
325
- f"Antigravity API Error {response.status_code}: {text.decode()}"
326
- )
351
+ retry_count = 0
352
+ while retry_count < 2:
353
+ should_retry = False
354
+ async with client.stream("POST", url, json=body) as response:
355
+ if response.status_code != 200:
356
+ text = await response.aread()
357
+ error_msg = text.decode()
358
+ if (
359
+ response.status_code == 400
360
+ and "Corrupted thought signature" in error_msg
361
+ and retry_count == 0
362
+ ):
363
+ should_retry = True
364
+ else:
365
+ raise RuntimeError(
366
+ f"Antigravity API Error {response.status_code}: {error_msg}"
367
+ )
327
368
 
328
- async for line in response.aiter_lines():
329
- line = line.strip()
330
- if not line:
331
- continue
332
- if line.startswith("data: "):
333
- json_str = line[6:] # Remove 'data: ' prefix
334
- if json_str:
335
- try:
336
- yield json.loads(json_str)
337
- except json.JSONDecodeError:
369
+ if not should_retry:
370
+ async for line in response.aiter_lines():
371
+ line = line.strip()
372
+ if not line:
338
373
  continue
374
+ if line.startswith("data: "):
375
+ json_str = line[6:] # Remove 'data: ' prefix
376
+ if json_str:
377
+ try:
378
+ yield json.loads(json_str)
379
+ except json.JSONDecodeError:
380
+ continue
381
+ return
382
+
383
+ # Handle retry outside the context manager
384
+ if should_retry:
385
+ logger.warning(
386
+ "Received 400 Corrupted thought signature in stream. Backfilling and retrying."
387
+ )
388
+ _backfill_thought_signatures(messages)
389
+
390
+ # Re-map messages
391
+ system_instruction, contents = await self._map_messages(
392
+ messages, model_request_parameters
393
+ )
394
+
395
+ # Update body in place
396
+ body["contents"] = contents
397
+ if system_instruction:
398
+ body["systemInstruction"] = system_instruction
399
+
400
+ retry_count += 1
339
401
 
340
402
  # Create streaming response
341
403
  streamed = AntigravityStreamingResponse(
@@ -666,3 +728,12 @@ def _antigravity_process_response_from_parts(
666
728
  provider_details=vendor_details,
667
729
  provider_name=provider_name,
668
730
  )
731
+
732
+
733
+ def _backfill_thought_signatures(messages: list[ModelMessage]) -> None:
734
+ """Backfill all thinking parts with the bypass signature."""
735
+ for m in messages:
736
+ if isinstance(m, ModelResponse):
737
+ for part in m.parts:
738
+ if isinstance(part, ThinkingPart):
739
+ object.__setattr__(part, "signature", BYPASS_THOUGHT_SIGNATURE)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-puppy
3
- Version: 0.0.350
3
+ Version: 0.0.351
4
4
  Summary: Code generation agent
5
5
  Project-URL: repository, https://github.com/mpfaffenberger/code_puppy
6
6
  Project-URL: HomePage, https://github.com/mpfaffenberger/code_puppy
@@ -124,7 +124,7 @@ code_puppy/plugins/__init__.py,sha256=gWgrXWoFpl-3Mxz2DAvxKW6SkCWrOnw-hKsY9O7nHc
124
124
  code_puppy/plugins/oauth_puppy_html.py,sha256=Wpa-V_NlRiBAvo_OXHuR7wvOH_jSt8L9HSFGiab6xI0,13058
125
125
  code_puppy/plugins/antigravity_oauth/__init__.py,sha256=1miHihSqRNXO20Vh_Gn9M3Aa2szh0gtdSCaKKj9nq0Q,362
126
126
  code_puppy/plugins/antigravity_oauth/accounts.py,sha256=GQit2-K24bsopmTZyscFUq3M0cAEO5WutHWnipVdgz8,14304
127
- code_puppy/plugins/antigravity_oauth/antigravity_model.py,sha256=g0_nXnMg288CvBE48CFgZ-iAqlYbtbi1dcB4Up6cYYc,26115
127
+ code_puppy/plugins/antigravity_oauth/antigravity_model.py,sha256=T81dp_j59BAKxcE8lIt3XKJQVB9Wb0IFugcNeR8mdVQ,29195
128
128
  code_puppy/plugins/antigravity_oauth/config.py,sha256=BoQgqf5I2XoHWnBBo9vhCIc_XwPj9Mbp0Z95ygWwt78,1362
129
129
  code_puppy/plugins/antigravity_oauth/constants.py,sha256=qsrA10JJvzNuY0OobvvwCQcoGpILBninllcUUMKkUrQ,4644
130
130
  code_puppy/plugins/antigravity_oauth/oauth.py,sha256=ZHXJtZP63l6brOpX1WdLfuUClIleA79-4y36YUJc6Wo,15137
@@ -177,10 +177,10 @@ code_puppy/tools/browser/browser_scripts.py,sha256=sNb8eLEyzhasy5hV4B9OjM8yIVMLV
177
177
  code_puppy/tools/browser/browser_workflows.py,sha256=nitW42vCf0ieTX1gLabozTugNQ8phtoFzZbiAhw1V90,6491
178
178
  code_puppy/tools/browser/camoufox_manager.py,sha256=RZjGOEftE5sI_tsercUyXFSZI2wpStXf-q0PdYh2G3I,8680
179
179
  code_puppy/tools/browser/vqa_agent.py,sha256=DBn9HKloILqJSTSdNZzH_PYWT0B2h9VwmY6akFQI_uU,2913
180
- code_puppy-0.0.350.data/data/code_puppy/models.json,sha256=FMQdE_yvP_8y0xxt3K918UkFL9cZMYAqW1SfXcQkU_k,3105
181
- code_puppy-0.0.350.data/data/code_puppy/models_dev_api.json,sha256=wHjkj-IM_fx1oHki6-GqtOoCrRMR0ScK0f-Iz0UEcy8,548187
182
- code_puppy-0.0.350.dist-info/METADATA,sha256=vAuuWdLBDGW2HGexfUhPLdUeoyXpabrNvtyNgZV57sQ,27572
183
- code_puppy-0.0.350.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
184
- code_puppy-0.0.350.dist-info/entry_points.txt,sha256=Tp4eQC99WY3HOKd3sdvb22vZODRq0XkZVNpXOag_KdI,91
185
- code_puppy-0.0.350.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
186
- code_puppy-0.0.350.dist-info/RECORD,,
180
+ code_puppy-0.0.351.data/data/code_puppy/models.json,sha256=FMQdE_yvP_8y0xxt3K918UkFL9cZMYAqW1SfXcQkU_k,3105
181
+ code_puppy-0.0.351.data/data/code_puppy/models_dev_api.json,sha256=wHjkj-IM_fx1oHki6-GqtOoCrRMR0ScK0f-Iz0UEcy8,548187
182
+ code_puppy-0.0.351.dist-info/METADATA,sha256=CeEJbr8iSJB0kJ-s-PqQ-Qcef7Bkr0leg-cWB8OI-FA,27572
183
+ code_puppy-0.0.351.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
184
+ code_puppy-0.0.351.dist-info/entry_points.txt,sha256=Tp4eQC99WY3HOKd3sdvb22vZODRq0XkZVNpXOag_KdI,91
185
+ code_puppy-0.0.351.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
186
+ code_puppy-0.0.351.dist-info/RECORD,,