Skip to content

Commit bb8547c

Browse files
tobertclaude
andcommitted
fix: remove from __future__ import annotations to fix Gemini AFC
The google-genai SDK's convert_argument_from_function uses raw param.annotation from inspect.signature() — which are strings under PEP 563 deferred annotations — then passes them to isinstance(), causing "isinstance() arg 2 must be a type" errors on every autonomous tool call. This silently broke all Gemini tool functions (list_directory, read_file, search_project) and was caught/reported as generic errors by the AFC loop. Removing the import is safe since we require Python >=3.12 where all annotation syntax (str | None, list[str], etc.) works natively. Also enables exposing gemini_search and semantic_search as autonomous Gemini tools — Gemini can now search the web and do vector search during codebase exploration. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 84d8a98 commit bb8547c

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

‎src/gpal/server.py‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
autonomous codebase exploration capabilities.
66
"""
77

8-
from __future__ import annotations
9-
108
import argparse
119
import asyncio
1210
import datetime
@@ -166,8 +164,12 @@ def detect_mime_type(path: str) -> str | None:
166164
Your role is to provide high-agency, deep reasoning and analysis on tasks,
167165
usually in git repositories.
168166
169-
You have tools: list_directory, read_file, and search_project.
170-
Use them proactively to explore the codebase—don't guess when you can verify.
167+
You have tools:
168+
- list_directory, read_file, search_project — explore the local codebase
169+
- gemini_search — search the web via Google Search
170+
- semantic_search — find code by meaning using vector embeddings
171+
172+
Use them proactively to explore and verify—don't guess when you can look it up.
171173
172174
You have a massive context window (2M tokens). Read entire files or multiple
173175
modules when needed to gather complete context.
@@ -693,7 +695,7 @@ def _wrap(text: str) -> ToolResult:
693695
# Build generation config
694696
config_kwargs = {
695697
"temperature": 0.2,
696-
"tools": [list_directory, read_file, search_project],
698+
"tools": [list_directory, read_file, search_project, gemini_search, semantic_search],
697699
"automatic_function_calling": types.AutomaticFunctionCallingConfig(
698700
disable=False,
699701
maximum_remote_calls=RESPONSE_MAX_TOOL_CALLS,
@@ -845,7 +847,6 @@ def _send_with_retry(session: Any, parts: list[types.Part], config: types.Genera
845847
# ─────────────────────────────────────────────────────────────────────────────
846848

847849

848-
@mcp.tool()
849850
def gemini_search(
850851
query: str,
851852
num_results: int = 5,
@@ -859,6 +860,8 @@ def gemini_search(
859860
"""
860861
return _gemini_search(query, num_results, model)
861862

863+
mcp.tool(gemini_search)
864+
862865

863866
@mcp.tool()
864867
def gemini_code_exec(
@@ -994,7 +997,6 @@ def delete_context_cache(cache_name: str) -> str:
994997
return f"Error deleting cache: {e}"
995998

996999

997-
@mcp.tool()
9981000
def semantic_search(query: str, limit: int = 5, path: str = ".") -> str:
9991001
"""Find code semantically related to the query using vector embeddings."""
10001002
try:
@@ -1009,6 +1011,8 @@ def semantic_search(query: str, limit: int = 5, path: str = ".") -> str:
10091011
except Exception as e:
10101012
return f"Error: {e}"
10111013

1014+
mcp.tool(semantic_search)
1015+
10121016

10131017
@mcp.tool(timeout=300)
10141018
async def rebuild_index(path: str = ".", ctx: Context | None = None) -> str:

0 commit comments

Comments
 (0)