chenhg5/cc-connect · error

session.create: %w

Error message

session.create: %w

What it means

createSession sends the 'session.create' JSON-RPC request to the Copilot CLI process and, if the CLI replies with a JSON-RPC error object, wraps it as 'session.create: %w'. This means the process is alive and responded, but it refused to create the session (bad config, auth, or internal CLI error).

Source

Thrown at agent/copilot/session.go:201

			cs.sessionID.Store(resumeSessionID)
			slog.Info("copilotSession: session resumed", "sessionId", resumeSessionID)
		case <-time.After(10 * time.Second):
			return fmt.Errorf("session.resume timeout")
		case <-cs.ctx.Done():
			return cs.ctx.Err()
		}
	} else {
		return cs.createSession()
	}
	return nil
}

func (cs *copilotSession) createSession() error {
	_, createCh := cs.rpc.call("session.create", cs.sessionConfig(newCopilotSessionID()))
	select {
	case resp := <-createCh:
		if resp.Error != nil {
			return fmt.Errorf("session.create: %w", resp.Error)
		}
		var result struct {
			SessionID string `json:"sessionId"`
		}
		if err := json.Unmarshal(resp.Result, &result); err != nil {
			return fmt.Errorf("session.create decode: %w", err)
		}
		cs.sessionID.Store(result.SessionID)
		slog.Info("copilotSession: session created", "sessionId", result.SessionID)
	case <-time.After(10 * time.Second):
		return fmt.Errorf("session.create timeout")
	case <-cs.ctx.Done():
		return cs.ctx.Err()
	}
	return nil
}

func (cs *copilotSession) sessionConfig(sessionID string) copilotSessionConfig {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the wrapped cause (%w) in the logs — the underlying resp.Error.Message from the CLI states the real reason.
  2. Re-authenticate the Copilot CLI (run it manually and complete `copilot` login / refresh the GitHub token).
  3. Validate the agent's config.toml options for the copilot agent (model name, flags) against the installed CLI version.
  4. Update or downgrade the Copilot CLI to a version compatible with cc-connect's JSON-RPC protocol.
  5. Retry; if it persists, capture stderr (logged by readLoop) and file an issue with the CLI error text.

Example fix

// before: unclear which option breaks creation
[[agents]]
name = "copilot"
[agents.options]
model = "gpt-5-turbo-ultra"   # not supported by installed CLI
// after
[agents.options]
model = "gpt-4o"              # supported by the installed CLI version
Defensive patterns

Strategy: try-catch

Validate before calling

// verify auth and version before starting the agent
out, err := exec.Command("copilot", "auth", "status").Output()
if err != nil || !strings.Contains(string(out), "logged in") {
    return fmt.Errorf("copilot CLI not authenticated")
}

Try / catch

if err := agent.StartSession(ctx, opts); err != nil {
    var cliErr error
    if errors.As(err, &cliErr) && strings.Contains(err.Error(), "session.create:") {
        slog.Error("CLI rejected session.create", "cause", errors.Unwrap(err))
    }
}

Prevention

When it happens

Trigger: handshake -> createSession -> resp.Error != nil on the 'session.create' call channel; i.e. the Copilot CLI returned an explicit JSON-RPC error for session creation (e.g. invalid sessionConfig, unauthenticated CLI, unsupported model/option in the agent config).

Common situations: Copilot CLI not authenticated (expired GitHub token); invalid sessionConfig fields produced from config.toml (bad model name, unsupported option); version mismatch between cc-connect's expectations and the installed CLI's RPC protocol.

Related errors


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