Skip to content

Commit cc6bcde

Browse files
committed
fix: run agent from repo_dir CWD, use absolute path to agent.py
Agent was exploring its own source code instead of the target repo because CWD was set to agent_code/. Now agent runs from repo/ with absolute path to agent.py, so CWD is the cloned target repository.
1 parent 3ce3703 commit cc6bcde

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/executor.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -612,19 +612,23 @@ async fn run_agent(
612612
}
613613
}
614614

615-
// Determine entry point
616-
let entry = if agent_dir.join("agent.py").exists() {
617-
"agent.py"
615+
// Determine entry point (use absolute path so we can run from repo_dir)
616+
let entry_file = if agent_dir.join("agent.py").exists() {
617+
agent_dir.join("agent.py")
618618
} else if agent_dir.join("main.py").exists() {
619-
"main.py"
619+
agent_dir.join("main.py")
620620
} else {
621-
"agent.py"
621+
agent_dir.join("agent.py")
622622
};
623623

624-
let mut argv = vec!["python3".to_string(), entry.to_string()];
624+
let mut argv = vec![
625+
"python3".to_string(),
626+
entry_file.to_string_lossy().to_string(),
627+
];
625628
argv.push("--instruction".into());
626629
argv.push(prompt.into());
627-
(argv, agent_dir)
630+
// Run from repo_dir so agent's CWD is the target repo
631+
(argv, repo_dir.to_path_buf())
628632
} else {
629633
// Legacy path: single-file agent code written to _agent_code.py
630634
let ext = agent_extension(agent_language);

0 commit comments

Comments
 (0)