AntigravitySDK misclassifies Gemini 503 UNAVAILABLE errors as NonZeroAgentExitCodeError

Open
#4,498 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@ithinkihaveacat is already working on this.

Since Nov 26, 2026.

  • #4499 by @ithinkihaveacat — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
backend, testing

Research direction

Read src/harbor/agents/installed/antigravity_sdk.py and the inherited error patterns and classifier in src/harbor/agents/installed/base.py; compare the adapter-specific patterns in antigravity_cli.py. The issue includes a deterministic mocked reproduction for _exec. Done means the reported 503 error is classified as ApiOverloadedError and the related status cases described in the issue map to the appropriate typed errors; an open linked pull request already addresses this issue.

Written by the indexing model from the issue text.

Description

Description

When a trial running the antigravity-sdk agent fails due to a transient Gemini API error (such as HTTP 503 / Status: UNAVAILABLE), Harbor classifies the failure as a generic NonZeroAgentExitCodeError instead of ApiOverloadedError.

AntigravitySDK inherits BaseInstalledAgent.ERROR_PATTERNS without defining any SDK-specific patterns. In BaseInstalledAgent.ERROR_PATTERNS, the overloaded patterns match only API Error: Overloaded, ServiceUnavailableError, Selected model is at capacity\. Please try a different model\., and Codex's "turn\.failed"...unexpected status 50[234]. Because google-antigravity surfaces these failures as google.antigravity.types.AntigravityExecutionError: ... Error 503, ..., Status: UNAVAILABLE (and request failed (code 503): ...), _classify_exec_error finds no match and falls back to NonZeroAgentExitCodeError.

Triggering Code

In src/harbor/agents/installed/antigravity_sdk.py, AntigravitySDK defines no ERROR_PATTERNS override and inherits BaseInstalledAgent.ERROR_PATTERNS:

ErrorPattern(r"API Error: Overloaded", ApiOverloadedError),
ErrorPattern(r"ServiceUnavailableError", ApiOverloadedError),
ErrorPattern(
    r"Selected model is at capacity\. Please try a different model\.",
    ApiOverloadedError,
),

When the runner exits non-zero, BaseInstalledAgent._classify_exec_error iterates self._compiled_error_patterns and returns NonZeroAgentExitCodeError(detail) when none match.

Environment

  • Harbor Version: 0.27.0 (verified identical on main commit cf4bd0043f4e3a91847edf1b799343caf74cf182)
  • Agent: antigravity-sdk (google-antigravity)
  • Python: 3.13.18

Impact

  • Benchmark Scoring Integrity: In src/harbor/models/trial/error_policy.py, ApiOverloadedError has should_retry=True, has_valid_reward=False, whereas NonZeroAgentExitCodeError has should_retry=False, has_valid_reward=True. Misclassifying a transient 503 UNAVAILABLE exit causes Harbor to skip retries and record an infrastructure abort as a valid 0.0 reward.
  • Persistence Even With SDK Retries: Although Harbor 0.27.0 enables LocalAgentConfig.eval() (RetryConfig.benchmark()) inside antigravity_sdk_runner.py, Harbor's outer ERROR_PATTERNS classifier is still needed whenever SDK-level retries fail fast, exhaust, or are disabled, as well as for non-retryable auth failures (401 UNAUTHENTICATED).

Reproduction Steps

The defect reproduces deterministically offline using AntigravitySDK._exec with a mocked failed ExecResult:

import asyncio
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import AsyncMock

from harbor.agents.installed.antigravity_sdk import AntigravitySDK

output = (
    "Traceback (most recent call last):\n"
    '  File "/installed-agent/run_agent.py", line 481, in <module>\n'
    "google.antigravity.types.AntigravityExecutionError: model unreachable: "
    "Error 503, Message: This model is currently experiencing high demand. "
    "Spikes in demand are usually temporary. Please try again later., "
    "Status: UNAVAILABLE\n"
    "request failed (code 503): This model is currently experiencing high "
    "demand. Spikes in demand are usually temporary. Please try again later.\n"
)


async def main() -> None:
    env = AsyncMock()
    env.exec.return_value = AsyncMock(return_code=1, stdout=output, stderr="")
    with TemporaryDirectory() as tmp:
        agent = AntigravitySDK(logs_dir=Path(tmp))
        try:
            await agent._exec(env, command="uv run --script /installed-agent/run_agent.py")
        except Exception as exc:
            print(type(exc).__name__)


asyncio.run(main())
Expected Behavior

AntigravitySDK._exec raises ApiOverloadedError.

Actual Behavior

AntigravitySDK._exec raises NonZeroAgentExitCodeError.

Error Log

Traceback (most recent call last):
  File "/installed-agent/run_agent.py", line 481, in <module>
google.antigravity.types.AntigravityExecutionError: model unreachable: Error 503, Message: This model is currently experiencing high demand. Spikes in demand are usually temporary. Please try again later., Status: UNAVAILABLE
request failed (code 503): This model is currently experiencing high demand. Spikes in demand are usually temporary. Please try again later.

Workaround

Manually inspect failed trials whose result.json records NonZeroAgentExitCodeError for AntigravityExecutionError / code 503 in agent/antigravity_sdk.txt, exclude those trials from aggregation, and re-run them.

Analysis

Other installed agent adapters in Harbor follow a subclass-scoped ERROR_PATTERNS override rather than broadening BaseInstalledAgent.ERROR_PATTERNS (which risks false positives on unrelated tool output):

  • AntigravityCli.ERROR_PATTERNS maps AGY_ERROR: status lines (UNAVAILABLE, RESOURCE_EXHAUSTED, INTERNAL, DEADLINE_EXCEEDED, UNAUTHENTICATED) to Harbor's typed API/auth exceptions.
  • GrokBuild.ERROR_PATTERNS and Vibe similarly extend *BaseInstalledAgent.ERROR_PATTERNS with adapter-specific patterns.

Adding an ERROR_PATTERNS override on AntigravitySDK anchored to AntigravityExecutionError: and request failed (code <status>): (matching to end-of-line so rightmost-match-wins classification outranks any earlier free-text needles) cleanly classifies 502/503 (UNAVAILABLE), 429 (RESOURCE_EXHAUSTED), 500 (INTERNAL), 504 (DEADLINE_EXCEEDED), and 401 (UNAUTHENTICATED) without affecting other agents.

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.