@@ -5,6 +5,7 @@ import (
55 _ "embed"
66 "encoding/json"
77 "fmt"
8+ "html/template"
89 "io"
910 "os"
1011 "path/filepath"
@@ -18,8 +19,25 @@ import (
1819
1920const CrushLogsToolName = "crush_logs"
2021
21−//go:embed crush_logs.md
22−var crushLogsDescription string
22+//go:embed crush_logs.md.tpl
23+var crushLogsDescriptionTmpl []byte
24+
25+var crushLogsDescriptionTpl = template.Must(
26+ template.New("crushLogsDescription").
27+ Parse(string(crushLogsDescriptionTmpl)),
28+)
29+
30+type crushLogsDescriptionData struct {
31+ DefaultLines int
32+ MaxLines int
33+}
34+
35+func crushLogsDescription() string {
36+ return renderTemplate(crushLogsDescriptionTpl, crushLogsDescriptionData{
37+ DefaultLines: defaultLogLines,
38+ MaxLines: maxLogLines,
39+ })
40+}
2341
2442// Max line size to prevent memory issues with very long log lines (1 MB).
2543const maxLogLineSize = 1024 * 1024
@@ -58,7 +76,7 @@ type CrushLogsParams struct {
5876func NewCrushLogsTool(logFile string) fantasy.AgentTool {
5977 return fantasy.NewAgentTool(
6078 CrushLogsToolName,
61− crushLogsDescription,
79+ crushLogsDescription(),
6280 func(ctx context.Context, params CrushLogsParams, call fantasy.ToolCall) (fantasy.ToolResponse, error) {
6381 result := runCrushLogs(logFile, params)
6482 return fantasy.NewTextResponse(result), nil