Skip to content

Allow overriding Claude preset tool name via env var#652

Open
ldthorne wants to merge 4 commits intogit-ai-project:mainfrom
ldthorne:main
Open

Allow overriding Claude preset tool name via env var#652
ldthorne wants to merge 4 commits intogit-ai-project:mainfrom
ldthorne:main

Conversation

@ldthorne
Copy link

@ldthorne ldthorne commented Mar 6, 2026

Allow the Claude preset's agent_id.tool field to be overridden via the GIT_AI_CLAUDE_PRESET_TOOL_NAME environment variable. This is not a breaking change – if unset, it will continue to be claude

This enables platforms that embed Claude Code to identify themselves correctly in git notes authorship metadata without needing a dedicated preset.

I've added a test case but if you'd like to test manually:

  • Without env var set, commit a change. agent_id.tool should remain claude (no behavior change)
  • With GIT_AI_CLAUDE_PRESET_TOOL_NAME set to my_new_bff, commit a change. agent_id.tool should be set to my_new_bff

Open with Devin

@git-ai-cloud-dev
Copy link

No AI authorship found for these commits. Please install git-ai to start tracking AI generated code in your commits.

@CLAassistant
Copy link

CLAassistant commented Mar 6, 2026

CLA assistant check
All committers have signed the CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 new potential issues.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +41 to +43
fn tool_name_override() -> Option<String> {
env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Overridden tool name breaks transcript refetching in repo_storage.rs

When GIT_AI_OVERRIDE_TOOL_NAME is set, the AgentId.tool field is replaced with the custom value. However, repo_storage.rs:348-369 matches tool names against hardcoded strings ("claude", "cursor", "codex", "gemini", "opencode", "github-copilot", etc.) to decide whether transcript refetching is possible. An overridden tool name (e.g. "my-custom-agent") won't match any known tool and will fall through to the default arm (// Unknown tools (like custom agent-v1 tools) can't refetch), which treats the tool as unable to refetch transcripts. This silently disables transcript refetching for any agent whose tool name has been overridden, potentially causing missing transcript data in authorship logs.

Prompt for agents
The tool_name_override() function in src/commands/checkpoint_agent/agent_presets.rs:41-43 (and inline env::var calls in agent_v1_preset.rs:86, amp_preset.rs:138, opencode_preset.rs:201) replaces the AgentId.tool field. But src/git/repo_storage.rs:348-369 matches against hardcoded tool name strings to determine refetch capability. When a tool name is overridden, it no longer matches any known tool, so transcript refetching is disabled.

Fix options:
1. Store the original tool name (e.g. "claude") in agent_metadata alongside the overridden display name, and use the original name for refetch logic in repo_storage.rs.
2. Update repo_storage.rs to also check agent_metadata for the original tool identity when the tool name doesn't match any known tool.
3. Add agent_metadata entries like "original_tool" when an override is active, and consult that in repo_storage.rs.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

} => Ok(AgentRunResult {
agent_id: AgentId {
tool: agent_name,
tool: env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or(agent_name),
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot Mar 7, 2026

Choose a reason for hiding this comment

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

🔴 Missing empty-string filter for GIT_AI_OVERRIDE_TOOL_NAME in agent_v1_preset

In agent_v1_preset.rs:86, env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or(agent_name) does not filter out empty or whitespace-only values, unlike the tool_name_override() helper in agent_presets.rs:41-43 which applies .filter(|s| !s.trim().is_empty()). If the env var is set to an empty string (e.g. GIT_AI_OVERRIDE_TOOL_NAME=""), the tool name will be set to "" instead of falling back to agent_name. This empty tool name propagates into prompt hashing (generate_short_hash), search filtering, blame display, and serialized authorship logs.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@acunniffe
Copy link
Collaborator

@ldthorne - made some changes to how this was implemented. Another team asked for this and needs OpenCode, Claude Code and Codex so I made it so one env could override tool name for any tool. This shouldn't be used locally but seems to be the right design for custom background agents

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

View 4 additional findings in Devin Review.

Open in Devin Review


let agent_id = AgentId {
tool: "amp".to_string(),
tool: env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or_else(|| "amp".to_string()),
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Missing empty-string filter for GIT_AI_OVERRIDE_TOOL_NAME in amp_preset

In amp_preset.rs:138, env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or_else(|| "amp".to_string()) does not filter out empty or whitespace-only values, unlike the tool_name_override() helper in agent_presets.rs:41-43 which applies .filter(|s| !s.trim().is_empty()). If the env var is set to "" or " ", the tool name will be set to that empty/whitespace string instead of falling back to "amp". This is inconsistent with all the other presets in agent_presets.rs that use the shared tool_name_override() helper.

Suggested change
tool: env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or_else(|| "amp".to_string()),
tool: env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().filter(|s| !s.trim().is_empty()).unwrap_or_else(|| "amp".to_string()),
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


let agent_id = AgentId {
tool: "opencode".to_string(),
tool: env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or_else(|| "opencode".to_string()),
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Missing empty-string filter for GIT_AI_OVERRIDE_TOOL_NAME in opencode_preset

In opencode_preset.rs:201, env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or_else(|| "opencode".to_string()) does not filter out empty or whitespace-only values, unlike the tool_name_override() helper in agent_presets.rs:41-43 which applies .filter(|s| !s.trim().is_empty()). If the env var is set to "" or " ", the tool name will be set to that empty/whitespace string instead of falling back to "opencode". This is inconsistent with all the other presets in agent_presets.rs that use the shared tool_name_override() helper.

Suggested change
tool: env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().unwrap_or_else(|| "opencode".to_string()),
tool: env::var("GIT_AI_OVERRIDE_TOOL_NAME").ok().filter(|s| !s.trim().is_empty()).unwrap_or_else(|| "opencode".to_string()),
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

3 participants