chenhg5/cc-connect · error

reasonix: session is closed

Error message

reasonix: session is closed

What it means

A sentinel liveness guard at the top of reasonixSession.Send: the session's alive flag is false (Close() ran, or the SSE reader marked the session dead after terminal disconnect). Any prompt submission is rejected before touching the HTTP endpoint.

Source

Thrown at agent/reasonix/session.go:150

			cancel()
			return nil, fmt.Errorf("reasonix: new session: %w", err)
		}
		slog.Info("reasonix: created new session")
	}

	// Start SSE reader in background
	readerCtx, readerCancel := context.WithCancel(ctx)
	s.sseCancel = readerCancel
	go s.readLoop(readerCtx)

	return s, nil
}

// ── core.AgentSession implementation ─────────────────────────────

func (s *reasonixSession) Send(prompt string, messageID string, images []core.ImageAttachment, files []core.FileAttachment) error {
	if !s.alive.Load() {
		return fmt.Errorf("reasonix: session is closed")
	}

	// Save images/files to disk and append references
	if len(images) > 0 {
		prompt = prompt + "\n\n[Attached images: " + formatImages(images) + "]"
	}
	if len(files) > 0 {
		filePaths := core.SaveFilesToDisk(s.workDir, messageID, files)
		prompt = core.AppendFileRefs(prompt, filePaths)
	}

	// Handle special commands locally
	if strings.TrimSpace(prompt) == "/compact" {
		return s.httpPost("/compact", nil)
	}

	// Submit to reasonix
	s.inTurn.Store(true)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Start a new session — this one is closed
  2. Check earlier events for why the SSE connection died
  3. Avoid sending after explicit close or fatal disconnects
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at agent/reasonix/session.go:150 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/1f740856d1d1dea7. Report an issue: GitHub.