fix(clink): use CLI-specific agent guidance text in prompts - #463
fix(clink): use CLI-specific agent guidance text in prompts#463syf2211 wants to merge 2 commits into
Conversation
_agent_capabilities_guidance() always injected 'Gemini CLI agent' even when clink targeted Claude Code, Codex, or other configured CLIs. Pass the resolved CLI client into prompt assembly and map known CLI names to their display labels. Add regression tests for guidance text selection. Fixes BeehiveInnovations#461
There was a problem hiding this comment.
Code Review
This pull request introduces CLI-specific agent capabilities guidance by mapping CLI names to display names and passing the client configuration to _prepare_prompt_for_role. It also adds corresponding unit tests. Feedback highlights a potential bug in prepare_prompt when request.cli_name is None (which would raise an AttributeError) and suggests adding a regression test to cover this default scenario.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| return await self._prepare_prompt_for_role( | ||
| request, | ||
| role_config, | ||
| client=client_config, | ||
| system_prompt=system_prompt_text, | ||
| include_system_prompt=include_system_prompt, | ||
| ) |
There was a problem hiding this comment.
There is a potential bug in prepare_prompt when request.cli_name is None (which is its default value).
Currently, line 268 directly calls self._registry.get_client(request.cli_name). If request.cli_name is None, this will raise an AttributeError: 'NoneType' object has no attribute 'lower' inside get_client.
To fix this, prepare_prompt should resolve the CLI name using self._default_cli_name as a fallback, similar to how it is done in execute:
async def prepare_prompt(self, request) -> str:
selected_cli = request.cli_name or self._default_cli_name
if not selected_cli:
raise ValueError("No CLI clients are configured for clink.")
client_config = self._registry.get_client(selected_cli)
role_config = client_config.get_role(request.role)
...| async def test_prepare_prompt_includes_cli_specific_guidance(): | ||
| tool = CLinkTool() | ||
| client = tool._registry.get_client("claude") | ||
| role = client.get_role("default") | ||
| request = CLinkRequest( | ||
| prompt="Review auth module", | ||
| cli_name="claude", | ||
| role="default", | ||
| ) | ||
|
|
||
| prompt = await tool._prepare_prompt_for_role( | ||
| request, | ||
| role, | ||
| client=client, | ||
| system_prompt="", | ||
| include_system_prompt=False, | ||
| ) | ||
|
|
||
| assert "Claude Code agent" in prompt | ||
| assert "Gemini CLI agent" not in prompt |
There was a problem hiding this comment.
To prevent regressions and ensure that prepare_prompt correctly handles the default case where cli_name is None, we should add a test case that invokes prepare_prompt directly with cli_name=None.
@pytest.mark.asyncio
async def test_prepare_prompt_includes_cli_specific_guidance():
tool = CLinkTool()
client = tool._registry.get_client("claude")
role = client.get_role("default")
request = CLinkRequest(
prompt="Review auth module",
cli_name="claude",
role="default",
)
prompt = await tool._prepare_prompt_for_role(
request,
role,
client=client,
system_prompt="",
include_system_prompt=False,
)
assert "Claude Code agent" in prompt
assert "Gemini CLI agent" not in prompt
@pytest.mark.asyncio
async def test_prepare_prompt_with_default_cli():
tool = CLinkTool()
request = CLinkRequest(
prompt="Review auth module",
cli_name=None,
role="default",
)
prompt = await tool.prepare_prompt(request)
assert prompt is not NoneWhen prepare_prompt is called without cli_name (the field default), resolve the configured default CLI before loading client config. Matches execute() behavior and avoids KeyError/AttributeError from get_client(None). Add regression test for default-cli guidance text.
|
Addressed the gemini-code-assist review: |
Summary
Fix
clinkprompt assembly so the capabilities guidance names the actual CLI being invoked instead of always saying "Gemini CLI agent".Fixes #461
Motivation
When
clinktargets Claude Code, Codex, or another configured CLI,_agent_capabilities_guidance()still injected hardcoded Gemini-specific text. That made logs and downstream prompts misleading even though the correct CLI executable was used.Changes
claude→ Claude Code agent,codex→ Codex CLI agent,gemini→ Gemini CLI agent)ResolvedCLIClientinto_prepare_prompt_for_role()and_agent_capabilities_guidance()"{name} CLI agent"for unmapped CLI namesTests
python3 -m pytest tests/test_clink_tool.py -q→ 9 passedpython3 -m ruff check tools/clink.py tests/test_clink_tool.py→ passedNotes