From 74a1e8563aaf3b590ecbf8b16e36f1e48dda0d24 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 23 Oct 2025 11:24:39 -0300 Subject: [PATCH] fix(prompt): reduce initial token usage by not sending file tree It can get quite big - the LLM can use the `ls` tool at any time to build the tree, so I think this is probably a good tradeof, as it would save a lot of prompt usage, especially on big projects. Sending a prompt (`hi`) in Crush's root dir, no MCPs/LSPs, qwen coder 3: 17.9k tokens 11.7k tokens Signed-off-by: Carlos Alexandro Becker --- internal/llm/prompt/coder.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/llm/prompt/coder.go b/internal/llm/prompt/coder.go index 57ed088b22de03fe875ad0822f159b35eb36a834..12ea587de9d61d8475c0913ebf1513450aef07b0 100644 --- a/internal/llm/prompt/coder.go +++ b/internal/llm/prompt/coder.go @@ -11,7 +11,6 @@ import ( "github.com/charmbracelet/catwalk/pkg/catwalk" "github.com/charmbracelet/crush/internal/config" - "github.com/charmbracelet/crush/internal/llm/tools" ) func CoderPrompt(p string, contextFiles ...string) string { @@ -53,7 +52,6 @@ func getEnvironmentInfo() string { isGit := isGitRepo(cwd) platform := runtime.GOOS date := time.Now().Format("1/2/2006") - output, _, _ := tools.ListDirectoryTree(cwd, tools.LSParams{}) return fmt.Sprintf(`Here is useful information about the environment you are running in: Working directory: %s @@ -61,10 +59,7 @@ Is directory a git repo: %s Platform: %s Today's date: %s - -%s - - `, cwd, boolToYesNo(isGit), platform, date, output) + `, cwd, boolToYesNo(isGit), platform, date) } func isGitRepo(dir string) bool {