github/copilot-sdk · error

CreateSessionFSProvider is required in session config when…

Error message

CreateSessionFSProvider is required in session config when SessionFS is enabled in client options

What it means

When client options enable SessionFS, each session config must supply a CreateSessionFSProvider factory that builds the filesystem provider for that session. CreateSession enforces this after registering the session and unregisters it if the provider factory is missing.

Solutions

  1. Provide config.CreateSessionFSProvider returning a valid SessionFS provider.
  2. If SessionFS is not needed, remove SessionFS from client options instead.
  3. Implement the provider interface required by your SessionFS capabilities.

Example fix

// before
cfg := &SessionConfig{} // SessionFS enabled in client options
// after
cfg := &SessionConfig{
    CreateSessionFSProvider: func(s *Session) SessionFSProvider { return myProvider },
}
Defensive patterns

Strategy: validation

Validate before calling

if clientUsesSessionFS && cfg.CreateSessionFSProvider == nil { return errors.New("CreateSessionFSProvider required") }

Try / catch

if _, err := client.CreateSession(ctx, cfg); err != nil && strings.Contains(err.Error(), "CreateSessionFSProvider is required") { /* add provider */ }

Prevention

When it happens

Trigger: Client created with options.SessionFS != nil, but the SessionConfig passed to CreateSession has a nil CreateSessionFSProvider.

Common situations: Enabling SessionFS globally in client options but forgetting per-session provider wiring; copying a minimal SessionConfig example that omits the provider.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/6207cff6b2d53d86. Report an issue: GitHub.

Appendix: source

Thrown at go/client.go:1080

		}
		if config.OnAutoModeSwitchRequest != nil {
			s.registerAutoModeSwitchHandler(config.OnAutoModeSwitchRequest)
		}
		if config.CanvasHandler != nil {
			s.registerCanvasHandler(config.CanvasHandler)
		}
		if bearerTokenProviders := collectBearerTokenProviders(config.Provider, config.Providers); bearerTokenProviders != nil {
			s.registerBearerTokenProviders(bearerTokenProviders)
		}

		c.sessionsMux.Lock()
		c.sessions[sessionID] = s
		c.sessionsMux.Unlock()

		if c.options.SessionFS != nil {
			if config.CreateSessionFSProvider == nil {
				unregisterSession(sessionID, s)
				return nil, fmt.Errorf("CreateSessionFSProvider is required in session config when SessionFS is enabled in client options")
			}
			provider := config.CreateSessionFSProvider(s)
			if c.options.SessionFS.Capabilities != nil && c.options.SessionFS.Capabilities.Sqlite {
				if _, ok := provider.(SessionFSSqliteProvider); !ok {
					unregisterSession(sessionID, s)
					return nil, fmt.Errorf("SessionFS capabilities declare SQLite support but the provider does not implement SessionFSSqliteProvider")
				}
			}
			s.clientSessionAPIs.SessionFS = newSessionFSAdapter(provider)
		}
		return s, nil
	}

	var session *Session
	var registeredSessionID string

	// Pre-register non-cloud sessions BEFORE issuing the RPC so any
	// session-scoped requests the CLI emits during session.create processing

View on GitHub (pinned to cd8cf15dc3)