Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/bot/handlers/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ async def continue_session(update: Update, context: ContextTypes.DEFAULT_TYPE) -
audit_logger: AuditLogger = context.bot_data.get("audit_logger")

# Parse optional prompt from command arguments
# If no prompt provided, use a default to continue the conversation
prompt = " ".join(context.args) if context.args else None
default_prompt = "Please continue where we left off"

current_dir = context.user_data.get(
"current_directory", settings.approved_directory
Expand Down Expand Up @@ -185,8 +187,9 @@ async def continue_session(update: Update, context: ContextTypes.DEFAULT_TYPE) -
)

# Continue with the existing session
# Use default prompt if none provided (Claude CLI requires a prompt)
claude_response = await claude_integration.run_command(
prompt=prompt or "",
prompt=prompt or default_prompt,
working_directory=current_dir,
user_id=user_id,
session_id=claude_session_id,
Expand All @@ -199,10 +202,11 @@ async def continue_session(update: Update, context: ContextTypes.DEFAULT_TYPE) -
parse_mode="Markdown",
)

# Use default prompt if none provided
claude_response = await claude_integration.continue_session(
user_id=user_id,
working_directory=current_dir,
prompt=prompt,
prompt=prompt or default_prompt,
)

if claude_response:
Expand All @@ -215,13 +219,13 @@ async def continue_session(update: Update, context: ContextTypes.DEFAULT_TYPE) -
# Format and send Claude's response
from ..utils.formatting import ResponseFormatter

formatter = ResponseFormatter()
formatted_messages = formatter.format_claude_response(claude_response)
formatter = ResponseFormatter(settings)
formatted_messages = formatter.format_claude_response(claude_response.content)

for msg in formatted_messages:
await update.message.reply_text(
msg.content,
parse_mode="Markdown",
msg.text,
parse_mode=msg.parse_mode,
reply_markup=msg.reply_markup,
)

Expand Down
11 changes: 7 additions & 4 deletions src/claude/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,13 @@ async def _execute_with_fallback(
# Use subprocess fallback
try:
logger.info("Executing with subprocess fallback")
# Don't pass SDK session_id to subprocess - start fresh
# SDK and subprocess have separate session management
response = await self.process_manager.execute_command(
prompt=prompt,
working_directory=working_directory,
session_id=session_id,
continue_session=continue_session,
session_id=None, # Start new session in subprocess
continue_session=False, # Fresh start
stream_callback=stream_callback,
)
logger.info("Subprocess fallback succeeded")
Expand Down Expand Up @@ -336,9 +338,10 @@ async def continue_session(
# Get most recent
latest_session = max(matching_sessions, key=lambda s: s.last_used)

# Continue session
# Continue session with default prompt if none provided
# Claude CLI requires a prompt, so we use a placeholder
return await self.run_command(
prompt=prompt or "",
prompt=prompt or "Please continue where we left off",
working_directory=working_directory,
user_id=user_id,
session_id=latest_session.session_id,
Expand Down