Skip to content

Commit 8de75ab

Browse files
author
Codestral CLI Dev
committed
fix: Resolve conversation context issues
- Disable persistent conversation history by default (start fresh each session) - Clear conversation history on startup to prevent stale context - Add proper system prompt for clean conversations - Fix /help command handling in tool commands - Improve help display with better tool organization Fixes issue where AI was responding with stale JavaScript context from previous sessions
1 parent 0f4f1a0 commit 8de75ab

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

codestral_cli/core/async_cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ async def run_interactive(self) -> None:
6767
async with AsyncCodestralClient(self.config) as client:
6868
# Initialize tool manager with async client
6969
self.tool_manager = ToolManager(client)
70+
71+
# Clear any persistent conversation history to start fresh
72+
self.conversation_manager.clear_conversation()
7073

7174
while self.running:
7275
try:
@@ -99,6 +102,10 @@ async def run_interactive(self) -> None:
99102

100103
# Handle tool commands
101104
if user_input.startswith("/"):
105+
command = user_input[1:].strip()
106+
if command == "help":
107+
self.display.print_help()
108+
continue
102109
await self._handle_tool_command(user_input)
103110
continue
104111

@@ -208,6 +215,14 @@ async def _handle_conversation_async(
208215
# Get conversation context
209216
messages = self.conversation_manager.get_conversation()
210217

218+
# Add a simple system message if this is the first interaction
219+
if len(messages) == 1:
220+
system_msg = {
221+
"role": "system",
222+
"content": "You are Codestral, a helpful AI coding assistant. Respond naturally and helpfully to user questions about programming, code, and development."
223+
}
224+
messages.insert(0, system_msg)
225+
211226
try:
212227
# Get streaming response
213228
token_stream = client.chat_completion_stream(messages)

codestral_cli/ui/live_display.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ def print_help(self):
185185
186186
Tool Commands:
187187
/explain <command> - Explain shell commands
188-
/suggest <task> - Suggest commands for tasks
189188
/review <file> - Review code files
190-
/analyze <file> - Analyze code structure
191189
/commit - Generate commit messages
192190
/debug <error> - Help debug errors
191+
/suggest <task> - Suggest commands for tasks
192+
/analyze <file> - Analyze code structure
193193
/test <file> - Generate unit tests
194194
/docs <code> - Generate documentation
195195
"""

codestral_cli/utils/conversation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
class ConversationManager:
1212
"""Manages conversation history and context"""
1313

14-
def __init__(self, max_history: int = 10, save_history: bool = True):
14+
def __init__(self, max_history: int = 10, save_history: bool = False): # Default to False
1515
self.max_history = max_history
1616
self.save_history = save_history
1717
self.conversation: List[Dict[str, Any]] = []
1818
self.history_file = Path.home() / ".codestral" / "conversation_history.json"
1919

20-
if save_history:
21-
self._load_history()
20+
# Don't load history by default - start fresh each time
21+
# if save_history:
22+
# self._load_history()
2223

2324
def add_message(
2425
self, role: str, content: str, metadata: Optional[Dict] = None

0 commit comments

Comments
 (0)