Skip to content

Commit e58d80d

Browse files
author
Test
committed
Fix double-path CWD bug in agent executor
The agent did os.Chdir('/work') then passed '/work' as CWD to the executor, causing all tool path resolution to produce '/work/work/...' paths. This made read_file fail with 'no such file or directory'. Pass '.' as CWD since we already chdir'd to the cloned repo.
1 parent 4c5bbe4 commit e58d80d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cmd/gptcode/agent.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99

1010
"github.com/spf13/cobra"
11-
11+
1212
"gptcode/internal/live"
1313
"gptcode/internal/llm"
1414
"gptcode/internal/modes"
@@ -51,7 +51,7 @@ func runAgent(cmd *cobra.Command, args []string) error {
5151
os.RemoveAll(cloneDir)
5252

5353
repoURL := fmt.Sprintf("https://x-access-token:%s@github.com/%s.git", token, repo)
54-
54+
5555
fmt.Printf("📦 Cloning %s (branch: %s) into %s...\n", repo, branch, cloneDir)
5656
cmdClone := exec.Command("git", "clone", "--depth", "1", "--branch", branch, repoURL, cloneDir)
5757
cmdClone.Stdout = os.Stdout
@@ -168,14 +168,14 @@ Please discover what failed by examining the code, tests, and standard CI config
168168
if queryModel == "" {
169169
queryModel = "anthropic/claude-sonnet-4"
170170
}
171-
171+
172172
liveClient := live.GetClient()
173173
var reportConfig *live.ReportConfig
174174
if liveURL != "" {
175175
reportConfig = live.DefaultReportConfig()
176176
reportConfig.SetBaseURL(liveURL)
177177
reportConfig.AgentID = agentID
178-
178+
179179
// Register on the Live Dashboard BEFORE starting execution
180180
taskLabel := "Sentry Exception Repair"
181181
if agentType != "sentry" {
@@ -192,8 +192,8 @@ Please discover what failed by examining the code, tests, and standard CI config
192192
reportConfig.AgentID = live.GetAgentID()
193193
}
194194

195-
executor := modes.NewAutonomousExecutorWithLive(provider, cloneDir, queryModel, language, liveClient, reportConfig, backendName)
196-
195+
executor := modes.NewAutonomousExecutorWithLive(provider, ".", queryModel, language, liveClient, reportConfig, backendName)
196+
197197
fmt.Println("🤖 Starting AutoFix process...")
198198
err = executor.Execute(ctx, prompt)
199199
if err != nil {

0 commit comments

Comments
 (0)