Improve prompts and tool descriptions#35
Conversation
Greptile SummaryThis PR improves the LLM-facing tool descriptions for
Confidence Score: 4/5Safe to merge; all changes are prompt-text and light refactoring with no data-path mutations. The changes are confined to string descriptions and a thin wrapper function. The getDefaultSystemPrompt signature change has no remaining callers passing modelId, and both call sites were updated correctly. The one structural concern is that file_search_tool.rs still duplicates the description literal rather than delegating to Self::function_description(), leaving a future drift risk — but both strings were kept in sync in this PR. src/services/file_search_tool.rs — the description literal duplication between function_tool_definition() and function_description() is worth tidying before the next description update. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[useChat: build request] --> B{hasSystemMessage?}
B -- No --> C[getDefaultSystemPrompt]
C --> D[getAppendedSystemGuidance]
D --> E[getAgenticGuidance]
D --> F[getEnabledToolsSystemGuidance]
E --> G[Combine: basePrompt + guidance]
F --> G
G --> H[system message added to input]
B -- Yes --> H
I[ConversationSettingsModal] --> J[getDefaultSystemPrompt]
I --> K[getAppendedSystemGuidance]
J --> L[Read-only effective prompt preview]
K --> L
|
| serde_json::json!({ | ||
| "type": "function", | ||
| "name": "file_search", | ||
| "description": "Search for relevant information in the configured knowledge base. Use this tool when you need to find specific information, answer questions about documents, or look up facts from the available files.", | ||
| "description": "Search the knowledge base attached to this conversation (the user's uploaded files and configured vector stores) using semantic search. Returns the most relevant passages with relevance scores, not whole documents, so synthesize your answer from these snippets. Use this for questions about the user's own documents or domain data. Don't use it for general knowledge you already have; for current web information, use a web search tool if one is available.", | ||
| "parameters": Self::function_parameters_schema() | ||
| }) |
There was a problem hiding this comment.
The description string is duplicated as a literal in both
function_tool_definition() and function_description(). If one is updated without the other they silently diverge — exactly the drift risk the new documentation section warns about. web_search_tool.rs already avoids this by writing "description": Self::function_description() in its tool definition; the same pattern works here.
| serde_json::json!({ | |
| "type": "function", | |
| "name": "file_search", | |
| "description": "Search for relevant information in the configured knowledge base. Use this tool when you need to find specific information, answer questions about documents, or look up facts from the available files.", | |
| "description": "Search the knowledge base attached to this conversation (the user's uploaded files and configured vector stores) using semantic search. Returns the most relevant passages with relevance scores, not whole documents, so synthesize your answer from these snippets. Use this for questions about the user's own documents or domain data. Don't use it for general knowledge you already have; for current web information, use a web search tool if one is available.", | |
| "parameters": Self::function_parameters_schema() | |
| }) | |
| serde_json::json!({ | |
| "type": "function", | |
| "name": "file_search", | |
| "description": Self::function_description(), | |
| "parameters": Self::function_parameters_schema() | |
| }) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/services/file_search_tool.rs
Line: 200-205
Comment:
The description string is duplicated as a literal in both `function_tool_definition()` and `function_description()`. If one is updated without the other they silently diverge — exactly the drift risk the new documentation section warns about. `web_search_tool.rs` already avoids this by writing `"description": Self::function_description()` in its tool definition; the same pattern works here.
```suggestion
serde_json::json!({
"type": "function",
"name": "file_search",
"description": Self::function_description(),
"parameters": Self::function_parameters_schema()
})
```
How can I resolve this? If you propose a fix, please make it concise.
No description provided.