Inject working directory into context to prevent path hallucinations

The LLM often hallucinates incorrect paths like /Users/jnbrymn/GitHub/g3
when the actual working directory is different. This causes wasted tokens
and failed commands as the LLM tries cd commands that fail.

Fix: Add the current working directory to the combined project content
that gets injected into the context at startup. This appears as:

  📂 Working Directory: /actual/path/to/workspace

This is prepended before AGENTS.md, README.md, and project memory,
so the LLM knows the correct path from the start.
This commit is contained in:
Dhanji R. Prasanna
2026-01-12 18:27:29 +05:30
parent 78516722df
commit e65bd61683
3 changed files with 27 additions and 7 deletions

View File

@@ -106,7 +106,7 @@ pub async fn run() -> Result<()> {
let config = load_config_with_cli_overrides(&cli)?;
// Combine AGENTS.md, README, and memory content
let combined_content = combine_project_content(agents_content, readme_content, memory_content);
let combined_content = combine_project_content(agents_content, readme_content, memory_content, &workspace_dir);
run_console_mode(cli, config, project, combined_content, workspace_dir).await
}