From b12deeabb50891b0ea57f10b6561617c5ab57746 Mon Sep 17 00:00:00 2001 From: Kashyap Murali <13315300+katchu11@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:18:43 -0700 Subject: [PATCH] Fix: Add git authentication to agent mode Agent mode now fetches the authenticated user (claude[bot] when using Claude App token) and configures git identity properly, matching the behavior of tag mode. This fixes the issue where commits in agent mode were failing due to missing git identity. --- src/modes/agent/index.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/modes/agent/index.ts b/src/modes/agent/index.ts index 379d23b..03c3564 100644 --- a/src/modes/agent/index.ts +++ b/src/modes/agent/index.ts @@ -4,6 +4,7 @@ import type { Mode, ModeOptions, ModeResult } from "../types"; import type { PreparedContext } from "../../create-prompt/types"; import { prepareMcpConfig } from "../../mcp/install-mcp-server"; import { parseAllowedTools } from "./parse-tools"; +import { configureGitAuth } from "../../github/operations/git-config"; /** * Agent mode implementation. @@ -41,7 +42,26 @@ export const agentMode: Mode = { return false; }, - async prepare({ context, githubToken }: ModeOptions): Promise { + async prepare({ context, githubToken, octokit }: ModeOptions): Promise { + // Configure git authentication for agent mode (same as tag mode) + // Fetch the authenticated user to set proper git identity + if (!context.inputs.useCommitSigning) { + try { + // Get the authenticated user (will be claude[bot] when using Claude App token) + const { data: authenticatedUser } = await octokit.rest.users.getAuthenticated(); + const user = { + login: authenticatedUser.login, + id: authenticatedUser.id, + }; + + // Configure git with the authenticated user's identity + await configureGitAuth(githubToken, context, user); + } catch (error) { + console.error("Failed to configure git authentication:", error); + // Continue anyway - git operations may still work with default config + } + } + // Create prompt directory await mkdir(`${process.env.RUNNER_TEMP || "/tmp"}/claude-prompts`, { recursive: true,