chenhg5/cc-connect · error

no active session found (key=%q)

Error message

no active session found (key=%q)

What it means

After resolving the send target for the given session key, the engine found the resolved target has a nil platform — meaning no active/interactive session exists for that key. It cannot deliver a message without a live platform connection bound to the session.

Source

Thrown at core/engine.go:11281

	platform   Platform
	replyCtx   any
	sessionKey string
}

func (e *Engine) SendToSessionInWorkDir(sessionKey, message string, images []ImageAttachment, files []FileAttachment, workDir string, atUsers []string, atAll bool) error {
	if message == "" && len(images) == 0 && len(files) == 0 {
		return fmt.Errorf("message or attachment is required")
	}
	if (len(images) > 0 || len(files) > 0) && !e.attachmentSendEnabled {
		return ErrAttachmentSendDisabled
	}

	target, err := e.resolveSendTarget(sessionKey, len(images) > 0 || len(files) > 0)
	if err != nil {
		return err
	}
	if target.platform == nil {
		return fmt.Errorf("no active session found (key=%q)", sessionKey)
	}

	_, sessions, err := e.getOrCreateWorkspaceAgent(workDir)
	if err != nil {
		return err
	}
	session := sessions.NewSession(target.sessionKey, "send")
	if message != "" {
		session.AddHistory("assistant", message)
	}
	sessions.Save()
	e.bindSendWorkDir(target.sessionKey, workDir)

	var imageSender ImageSender
	if len(images) > 0 {
		var ok bool
		imageSender, ok = target.platform.(ImageSender)
		if !ok {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify the session key is currently active (list sessions) before sending
  2. Re-establish/await the interactive session, then retry with a valid key
  3. Handle the error by re-resolving the key from the current session list instead of caching it

Example fix

// before
e.SendToSessionInWorkDir(staleKey, msg, nil, nil, wd, nil, false) // no active session
// after
if !sessionExists(e, staleKey) {
    return fmt.Errorf("session %q gone; skipping send", staleKey)
}
e.SendToSessionInWorkDir(staleKey, msg, nil, nil, wd, nil, false)
Defensive patterns

Strategy: validation

Validate before calling

if engine.ActiveSession(key) == nil {
    return fmt.Errorf("session %q is not active; cannot send", key)
}

Try / catch

if err := e.SendToSessionInWorkDir(key, msg, nil, nil, wd, nil, false); err != nil {
    if strings.HasPrefix(err.Error(), "no active session") {
        // re-resolve session key from live session list before retrying
    }
}

Prevention

When it happens

Trigger: Calling SendToSessionInWorkDir (or resolveSendTarget-driven sends) with a sessionKey that no longer matches any entry in e.interactiveStates — the session ended, the bot restarted, or the key was typo'd.

Common situations: Scripts caching a session key across bot restarts; sending to a session that the user closed with /new or timeout; racy send issued just after session teardown.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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