diff --git a/internal/agent/tools/tools.go b/internal/agent/tools/tools.go index 41adf7583904ad529a7e93fff9b44cb8aaaf8ffa..90840ccfdadf392d1e1a18dfd0d6acad02851227 100644 --- a/internal/agent/tools/tools.go +++ b/internal/agent/tools/tools.go @@ -2,6 +2,7 @@ package tools import ( "context" + "os" "strings" ) @@ -56,12 +57,14 @@ func GetModelNameFromContext(ctx context.Context) string { return getContextValue(ctx, ModelNameContextKey, "") } -// FirstLineDescription returns the first non-empty line from the embedded -// markdown description. This extracts just the concise summary line, -// significantly reducing token usage while preserving essential tool context. +// FirstLineDescription returns just the first non-empty line from the embedded +// markdown description when CRUSH_SHORT_TOOL_DESCRIPTIONS is set, significantly +// reducing token usage. Otherwise returns the full description. func FirstLineDescription(content []byte) string { - lines := strings.SplitSeq(string(content), "\n") - for line := range lines { + if os.Getenv("CRUSH_SHORT_TOOL_DESCRIPTIONS") == "" { + return strings.TrimSpace(string(content)) + } + for line := range strings.SplitSeq(string(content), "\n") { line = strings.TrimSpace(line) if line != "" { return line