-
Notifications
You must be signed in to change notification settings - Fork 6
fix: cap embed payload at 30k chars to prevent Ollama context overflow (#53) #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6636960
2c00a13
d85f461
2a08ed6
1e16971
65c869f
cab6f3f
7be4b78
0d3334f
0eb84b0
fcb1bbf
acf1c99
ce6d98d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | |||||
| "os/signal" | ||||||
| "path/filepath" | ||||||
| "strings" | ||||||
| "sync" | ||||||
| "syscall" | ||||||
| "time" | ||||||
|
|
||||||
|
|
@@ -364,16 +365,6 @@ workspace: | |||||
| } | ||||||
|
|
||||||
| func main() { | ||||||
| // AGGRESSIVE STARTUP DEBUG | ||||||
| f, _ := os.Create("/tmp/ragcode-startup.txt") | ||||||
| cwd, _ := os.Getwd() | ||||||
| exe, _ := os.Executable() | ||||||
| fmt.Fprintf(f, "Time: %s\n", time.Now()) | ||||||
| fmt.Fprintf(f, "Exe: %s\n", exe) | ||||||
| fmt.Fprintf(f, "CWD: %s\n", cwd) | ||||||
| fmt.Fprintf(f, "Args: %v\n", os.Args) | ||||||
| f.Close() | ||||||
|
|
||||||
| // Define flags | ||||||
| configPath := flag.String("config", "config.yaml", "Path to configuration file") | ||||||
| ollamaBaseURLFlag := flag.String("ollama-base-url", "", "Ollama base URL (overrides config/env)") | ||||||
|
|
@@ -437,7 +428,7 @@ func main() { | |||||
| // Handle update flag | ||||||
| if *updateFlag { | ||||||
| fmt.Println("Checking for updates...") | ||||||
| info, err := updater.CheckForUpdates(Version) | ||||||
| info, err := updater.CheckForUpdates(context.Background(), Version, true) | ||||||
| if err != nil { | ||||||
| log.Fatalf("Failed to check for updates: %v", err) | ||||||
| } | ||||||
|
|
@@ -447,8 +438,26 @@ func main() { | |||||
| } | ||||||
|
|
||||||
| fmt.Printf("Found new version: %s\nDownloading...\n", info.LatestVersion) | ||||||
| tempFile := filepath.Join(os.TempDir(), "ragcode_update.tar.gz") | ||||||
| if err := info.DownloadAndVerify(tempFile); err != nil { | ||||||
|
|
||||||
| // Determine extension from asset URL | ||||||
| ext := ".tar.gz" | ||||||
| if strings.HasSuffix(info.AssetURL, ".zip") { | ||||||
| ext = ".zip" | ||||||
| } | ||||||
| // Create a unique temporary file securely | ||||||
| tmp, err := os.CreateTemp("", "ragcode_update_*"+ext) | ||||||
| if err != nil { | ||||||
| log.Fatalf("Failed to create temporary file for update: %v", err) | ||||||
| } | ||||||
| tempFile := tmp.Name() | ||||||
| // We only need the path; close the file descriptor | ||||||
| if err := tmp.Close(); err != nil { | ||||||
| log.Fatalf("Failed to close temporary file for update: %v", err) | ||||||
| } | ||||||
| // Ensure the temporary file is removed after applying the update | ||||||
| defer os.Remove(tempFile) | ||||||
|
|
||||||
| if err := info.DownloadAndVerify(context.Background(), tempFile); err != nil { | ||||||
| log.Fatalf("Update failed: %v", err) | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -477,12 +486,7 @@ func main() { | |||||
| } | ||||||
|
|
||||||
| // Background update check | ||||||
| go func() { | ||||||
| info, err := updater.CheckForUpdates(Version) | ||||||
| if err == nil && info != nil { | ||||||
| logger.Info("🌟 New version available: %s. Run 'rag-code-mcp --update' to upgrade.", info.LatestVersion) | ||||||
| } | ||||||
| }() | ||||||
| triggerBackgroundUpdateCheck() | ||||||
|
|
||||||
| // Apply logging settings from config unless env vars already override them | ||||||
| applyLoggingConfig(cfg.Logging) | ||||||
|
|
@@ -643,6 +647,11 @@ func main() { | |||||
|
|
||||||
| indexWorkspaceTool := tools.NewIndexWorkspaceTool(workspaceManager) | ||||||
|
|
||||||
| listSkillsTool := tools.NewListSkillsTool() | ||||||
| installSkillTool := tools.NewInstallSkillTool(workspaceManager) | ||||||
| checkUpdateTool := tools.NewCheckUpdateTool(Version) | ||||||
| applyUpdateTool := tools.NewApplyUpdateTool(Version) | ||||||
|
|
||||||
| // Example: use typed ToolHandlerFor for search_code | ||||||
| registerSearchCodeToolTyped(server, searchTool, cfg) | ||||||
|
|
||||||
|
|
@@ -655,6 +664,10 @@ func main() { | |||||
| registerAgentTool(server, searchDocsTool, cfg) | ||||||
| registerAgentTool(server, hybridTool, cfg) | ||||||
| registerAgentTool(server, indexWorkspaceTool, cfg) | ||||||
| registerAgentTool(server, listSkillsTool, cfg) | ||||||
| registerAgentTool(server, installSkillTool, cfg) | ||||||
| registerAgentTool(server, checkUpdateTool, cfg) | ||||||
| registerAgentTool(server, applyUpdateTool, cfg) | ||||||
|
Comment on lines
650
to
+670
|
||||||
|
|
||||||
| if err := registerFileResources(server); err != nil { | ||||||
| log.Fatalf("Failed to register resources: %v", err) | ||||||
|
|
@@ -708,6 +721,9 @@ func registerSearchCodeToolTyped(server *mcp.Server, tool *tools.SearchLocalInde | |||||
|
|
||||||
| logger.Info("✅ Tool '%s' completed in %v", tool.Name(), duration) | ||||||
|
|
||||||
| // Trigger background update check (non-blocking) | ||||||
| triggerBackgroundUpdateCheck() | ||||||
|
|
||||||
| return nil, SearchCodeOutput{Results: result}, nil | ||||||
| }) | ||||||
| } | ||||||
|
|
@@ -751,6 +767,9 @@ func registerAgentTool(server *mcp.Server, tool MCPTool, cfg *config.Config) { | |||||
|
|
||||||
| logger.Info("✅ Tool '%s' completed in %v", tool.Name(), duration) | ||||||
|
|
||||||
| // Trigger background update check (non-blocking) | ||||||
| triggerBackgroundUpdateCheck() | ||||||
|
|
||||||
| return &mcp.CallToolResult{ | ||||||
| Content: []mcp.Content{ | ||||||
| &mcp.TextContent{Text: result}, | ||||||
|
|
@@ -1097,6 +1116,54 @@ func getToolSchema(toolName string) map[string]interface{} { | |||||
| "required": []string{"query"}, | ||||||
| } | ||||||
|
|
||||||
| case "list_skills": | ||||||
| return map[string]interface{}{ | ||||||
| "type": "object", | ||||||
| "properties": map[string]interface{}{}, | ||||||
| } | ||||||
|
|
||||||
| case "install_skill": | ||||||
| return map[string]interface{}{ | ||||||
| "type": "object", | ||||||
| "properties": map[string]interface{}{ | ||||||
| "skill_id": map[string]interface{}{ | ||||||
| "type": "string", | ||||||
| "description": "The ID of the skill to install or uninstall", | ||||||
| }, | ||||||
| "active": map[string]interface{}{ | ||||||
| "type": "boolean", | ||||||
| "description": "True to install the skill, false to uninstall it", | ||||||
| }, | ||||||
| "file_path": map[string]interface{}{ | ||||||
| "type": "string", | ||||||
| "description": "Optional: file path to help detect workspace context", | ||||||
| }, | ||||||
| }, | ||||||
| "required": []string{"skill_id", "active"}, | ||||||
| } | ||||||
|
|
||||||
| case "check_update": | ||||||
| return map[string]interface{}{ | ||||||
| "type": "object", | ||||||
| "properties": map[string]interface{}{ | ||||||
| "force": map[string]interface{}{ | ||||||
| "type": "boolean", | ||||||
| "description": "Force check ignoring cache (default: false)", | ||||||
| }, | ||||||
| }, | ||||||
| } | ||||||
|
|
||||||
| case "apply_update": | ||||||
| return map[string]interface{}{ | ||||||
| "type": "object", | ||||||
| "properties": map[string]interface{}{ | ||||||
| "force": map[string]interface{}{ | ||||||
| "type": "boolean", | ||||||
| "description": "Force update even if version matches (default: false)", | ||||||
|
||||||
| "description": "Force update even if version matches (default: false)", | |
| "description": "Force update even if version matches (default: true)", |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "encoding/json" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "hash/fnv" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "path/filepath" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "strings" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -13,6 +14,57 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/doITmagic/rag-code-mcp/internal/memory" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // maxEmbedChars is the maximum number of Unicode characters sent to the embedding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // model. Common models (e.g. nomic-embed-text) have an 8 192-token context window | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // (~4 chars/token → ~32 768 chars). We use 30 000 to give ~6% headroom and stay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // compatible with smaller-window models. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const maxEmbedChars = 30_000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // buildEmbedText constructs the text to embed for a CodeChunk, then truncates it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // to maxChars (rune-safe, UTF-8 correct) to avoid exceeding the model's context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // window. Metadata (docstring, signature) is always preserved in full; only Code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // is truncated when the total exceeds maxChars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Returns (text, wasTruncated). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func buildEmbedText(ch codetypes.CodeChunk, maxChars int) (string, bool) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| meta := strings.TrimSpace(strings.Join(filterNonEmpty([]string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ch.Docstring, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ch.Signature, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), "\n\n")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var full string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ch.Code != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if meta != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| full = meta + "\n\n" + ch.Code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| full = ch.Code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| full = meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runes := []rune(full) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(runes) <= maxChars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return full, false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+45
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Truncate only the Code portion — keep metadata intact. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metaWithSep := meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if meta != "" && ch.Code != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metaWithSep = meta + "\n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metaRunes := []rune(metaWithSep) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| remaining := maxChars - len(metaRunes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if remaining < 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| remaining = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+59
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| codeRunes := []rune(ch.Code) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if remaining > len(codeRunes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| remaining = len(codeRunes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+60
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Converting the potentially massive codePrefix := ch.Code
if len(codePrefix) > remaining*4 {
codePrefix = codePrefix[:remaining*4]
}
codeRunes := []rune(codePrefix)
if remaining > len(codeRunes) {
remaining = len(codeRunes)
} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| truncated := metaWithSep + string(codeRunes[:remaining]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the metadata ( |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return truncated, true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+65
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var full string | |
| if ch.Code != "" { | |
| if meta != "" { | |
| full = meta + "\n\n" + ch.Code | |
| } else { | |
| full = ch.Code | |
| } | |
| } else { | |
| full = meta | |
| } | |
| runes := []rune(full) | |
| if len(runes) <= maxChars { | |
| return full, false | |
| } | |
| // Truncate only the Code portion — keep metadata intact. | |
| metaWithSep := meta | |
| if meta != "" && ch.Code != "" { | |
| metaWithSep = meta + "\n\n" | |
| } | |
| metaRunes := []rune(metaWithSep) | |
| remaining := maxChars - len(metaRunes) | |
| if remaining < 0 { | |
| remaining = 0 | |
| } | |
| codeRunes := []rune(ch.Code) | |
| if remaining > len(codeRunes) { | |
| remaining = len(codeRunes) | |
| } | |
| truncated := metaWithSep + string(codeRunes[:remaining]) | |
| return truncated, true | |
| metaWithSep := meta | |
| if meta != "" && ch.Code != "" { | |
| metaWithSep = meta + "\n\n" | |
| } | |
| metaRuneCount := len([]rune(metaWithSep)) | |
| if ch.Code == "" { | |
| if metaRuneCount <= maxChars { | |
| return meta, false | |
| } | |
| return meta, true | |
| } | |
| remaining := maxChars - metaRuneCount | |
| if remaining < 0 { | |
| return metaWithSep, true | |
| } | |
| codeRuneCount := 0 | |
| for idx := range ch.Code { | |
| if codeRuneCount == remaining { | |
| return metaWithSep + ch.Code[:idx], true | |
| } | |
| codeRuneCount++ | |
| } | |
| return metaWithSep + ch.Code, false |
Copilot
AI
Apr 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment references rag_read_file_context, but that tool name doesn't appear to exist in this codebase (the MCP tool is get_code_context). This can confuse users reading logs; consider updating the comment to the correct tool name or removing it.
| // The full code is still accessible via rag_read_file_context. | |
| // The full code is still accessible via get_code_context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
defer os.Remove(tempFile)will not execute becauseos.Exit(0)is called at the end of this block (line 470). In Go,deferstatements are not run whenos.Exit()is called. Since this is a short-lived CLI path, you should manually callos.Remove(tempFile)beforeos.Exit(0)or wrap this logic in a function to ensure the temporary archive is cleaned up.