Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions agent/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def create_inference_server(api_type: str):
if not api_key and not auth_token:
_require_env(["ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"], api_type)
return anthropic.Anthropic(api_key=api_key, auth_token=auth_token)
elif api_type in ("gemini", "google"):
api_key = os.environ.get("GEMINI_API_KEY")
if not api_key:
_require_env(["GEMINI_API_KEY"], api_type)
return openai.OpenAI(
api_key=_require_env(["GEMINI_API_KEY"], api_type),
base_url=os.environ.get("GEMINI_BASE_URL", "https://generativelanguage.googleapis.com/v1beta/openai/"),
)
Comment on lines +39 to +45

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for checking and retrieving GEMINI_API_KEY is redundant. The _require_env function already handles checking for the environment variable and raising a RuntimeError if it's missing, while returning the value if it exists. The current implementation performs manual checks and calls the helper twice unnecessarily.

        return openai.OpenAI(
            api_key=_require_env(["GEMINI_API_KEY"], api_type),
            base_url=os.environ.get("GEMINI_BASE_URL", "https://generativelanguage.googleapis.com/v1beta/openai/"),
        )

Comment on lines +38 to +45

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Gemini branch is not reachable from the current CLI flow.

create_inference_server now supports "gemini"/"google" here, but agent/main.py Line 185 restricts --api_type choices to ["openai", "claude"], and Line 109 passes that value directly. This makes the new branch effectively unusable from CLI.

Suggested follow-up patch (outside this file)
--- a/agent/main.py
+++ b/agent/main.py
@@
 parser.add_argument(
-        "--api_type", type=str, default="openai", choices=["openai", "claude"]
+        "--api_type",
+        type=str,
+        default="openai",
+        choices=["openai", "claude", "anthropic", "gemini", "google"],
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@agent/api.py` around lines 39 - 46, The Gemini/Google branch in
create_inference_server is unreachable because the CLI's --api_type choices (in
main's argument parsing and where parse_args() value is forwarded) only allow
"openai" and "claude"; update the CLI to include "gemini" and "google" in the
choices for --api_type (and any related validation or help text) so the value
passed into create_inference_server can reach the gemini/google branch; ensure
the same choices array used at argument definition and any subsequent
validation/coercion include "gemini" and "google".

else:
raise ValueError(f"Unsupported api_type: {api_type}")

Expand Down