-
Notifications
You must be signed in to change notification settings - Fork 268
feat: add Gemini CLI agent support #6
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
Open
numman-ali
wants to merge
1
commit into
berabuddies:master
Choose a base branch
from
numman-ali:feat/gemini-cli-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
|
|
||
| from agentflow.agents.base import AgentAdapter | ||
| from agentflow.env import merge_env_layers | ||
| from agentflow.prepared import ExecutionPaths, PreparedExecution | ||
| from agentflow.specs import NodeSpec, RepoInstructionsMode, ToolAccess | ||
|
|
||
|
|
||
| class GeminiAdapter(AgentAdapter): | ||
| def prepare(self, node: NodeSpec, prompt: str, paths: ExecutionPaths) -> PreparedExecution: | ||
| provider = self.provider_config(node.provider, node.agent) | ||
| executable = node.executable or "gemini" | ||
|
|
||
| # Use -p for non-interactive (headless) mode; positional prompt | ||
| # launches interactive mode which hangs in automation. | ||
| command = [ | ||
| executable, | ||
| "-p", | ||
| prompt, | ||
| "--output-format", | ||
| "stream-json", | ||
| ] | ||
|
|
||
| # Permission flags: map tools access to Gemini's approval model. | ||
| # --approval-mode plan = read-only (no writes allowed). | ||
| # --yolo = auto-approve all tool calls (required for non-interactive write). | ||
| if node.tools == ToolAccess.READ_ONLY: | ||
| command.extend(["--sandbox", "--approval-mode", "plan"]) | ||
| else: | ||
| command.extend(["--yolo"]) | ||
|
|
||
| if node.model: | ||
| command.extend(["--model", node.model]) | ||
|
|
||
| runtime_files: dict[str, str] = {} | ||
|
|
||
| repo_instructions_ignored = node.repo_instructions_mode == RepoInstructionsMode.IGNORE | ||
| if repo_instructions_ignored: | ||
| # Gemini reads GEMINI.md for repo instructions; running from runtime dir avoids it | ||
| pass | ||
|
|
||
| command.extend(node.extra_args) | ||
|
|
||
| env = merge_env_layers(getattr(provider, "env", None), node.env) | ||
| if provider: | ||
| if provider.api_key_env: | ||
| if provider.api_key_env in env: | ||
| api_key = env[provider.api_key_env] | ||
| else: | ||
| api_key = os.getenv(provider.api_key_env) | ||
| if api_key is not None: | ||
| env.setdefault("GEMINI_API_KEY", api_key) | ||
|
|
||
| cwd = paths.target_workdir | ||
| if repo_instructions_ignored: | ||
| cwd = str(Path(paths.target_runtime_dir)) | ||
|
|
||
| return PreparedExecution( | ||
| command=command, | ||
| env=env, | ||
| cwd=cwd, | ||
| trace_kind="gemini", | ||
| runtime_files=runtime_files, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
node.mcpsis silently ignored here. Unlike the Codex / Claude / Kimi adapters, the Gemini adapter never materializes an MCP config file and never passes any MCP-related flag or settings into the CLI, so a Gemini node configured with MCP servers runs without those tools.I reproduced this by building a Gemini node with a stdio MCP server and calling
GeminiAdapter.prepare(): the prepared command had no MCP arguments andruntime_fileswas empty, while the equivalent Kimi node produced a runtime config file and--mcp-config-file. Silently dropping configured MCP servers is a behavioral regression for workflows that rely onnode.mcps.