Skip to content

fix(clink): use CLI-specific agent guidance text in prompts - #463

Open
syf2211 wants to merge 2 commits into
BeehiveInnovations:mainfrom
syf2211:fix/clink-dynamic-agent-guidance
Open

fix(clink): use CLI-specific agent guidance text in prompts#463
syf2211 wants to merge 2 commits into
BeehiveInnovations:mainfrom
syf2211:fix/clink-dynamic-agent-guidance

Conversation

@syf2211

@syf2211 syf2211 commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Fix clink prompt assembly so the capabilities guidance names the actual CLI being invoked instead of always saying "Gemini CLI agent".

Fixes #461

Motivation

When clink targets 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

  • Add display-name mapping for known CLIs (claude → Claude Code agent, codex → Codex CLI agent, gemini → Gemini CLI agent)
  • Pass ResolvedCLIClient into _prepare_prompt_for_role() and _agent_capabilities_guidance()
  • Fall back to "{name} CLI agent" for unmapped CLI names
  • Add regression tests covering guidance text selection and prompt assembly

Tests

  • python3 -m pytest tests/test_clink_tool.py -q9 passed
  • python3 -m ruff check tools/clink.py tests/test_clink_tool.pypassed

Notes

  • composer-2.5 review: APPROVE
  • Text-only prompt wrapper change; no runtime CLI invocation behavior changes

_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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread tools/clink.py
Comment on lines 272 to 278
return await self._prepare_prompt_for_role(
request,
role_config,
client=client_config,
system_prompt=system_prompt_text,
include_system_prompt=include_system_prompt,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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)
    ...

Comment thread tests/test_clink_tool.py
Comment on lines +208 to +227
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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 None

When 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.
@syf2211

syf2211 commented Jul 2, 2026

Copy link
Copy Markdown
Author

Addressed the gemini-code-assist review: prepare_prompt() now resolves request.cli_name or self._default_cli_name before get_client(), matching execute() behavior. Added test_prepare_prompt_defaults_cli_name. Pushed in 50350c4; composer-2.5 review: APPROVE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clink always injects “Gemini CLI agent” guidance text regardless of selected cli_name

1 participant