forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Bug
After every message, currentSessionID is set to null in the finally blocks of both handleMessage() and handleCustomCommand(). This causes each user message to create a brand new session with zero conversation history.
Reproduction
- Send a message: "Is issue 184 still open?"
- Agent responds correctly about Can't continue session after closing opencode while working anomalyco/opencode#184
- Send follow-up: "Is there a PR linked to it?"
- Agent responds: "I don't have context for what 'it' refers to"
Root Cause
File: packages/opencode/src/cli/lite/index.ts
Line ~540 (handleMessage finally block):
finally {
isOperationInProgress = false
currentSessionID = null // ← BUG
}Line ~455 (handleCustomCommand finally block):
finally {
isOperationInProgress = false
currentSessionID = null // ← SAME BUG
}Evidence
- Token count drops from 51.7k to 25.8k between messages (no history loaded)
Session.createNext()is called every message instead of reusing the sessionMessageV2.filterCompacted(MessageV2.stream(sessionID))returns empty history for new sessions
Fix
Delete both currentSessionID = null lines. The session ID should persist across the REPL loop. It's already properly reset when the user runs /new (line ~275).
Acceptance Criteria
- Conversation context preserved across multiple messages
-
/newcommand still creates a fresh session -
bun run typecheckpasses -
bun testpasses
Metadata
Metadata
Assignees
Labels
No labels