t8y2/dbx · error

agentSessionId is required

Error message

agentSessionId is required

What it means

The open_session RPC requires an agentSessionId parameter to tag the new session; an empty value is rejected before decoding the connection params. Every subsequent session-scoped call is routed by this id, so it must be supplied.

Source

Thrown at agents/drivers/kingbase-go/main.go:233

		return errorResponse(req.ID, err), false
	}
	return response{JSONRPC: "2.0", ID: req.ID, Result: result}, shutdown
}

func (r *runtimeServer) dispatch(method string, params map[string]json.RawMessage) (any, bool, error) {
	switch method {
	case "handshake":
		return map[string]any{
			"protocolVersion":      protocolVersion,
			"agentProtocolVersion": protocolVersion,
			"capabilities": []string{
				"connect", "test_connection", "metadata", "query", "paged_query", "transaction", "ddl", "multi_session",
			},
		}, false, nil
	case "open_session":
		id := stringParam(params, "agentSessionId")
		if id == "" {
			return nil, false, errors.New("agentSessionId is required")
		}
		var cp connectParams
		if err := decodeParams(params, &cp); err != nil {
			return nil, false, err
		}
		return map[string]bool{"ok": true}, false, r.openSession(id, cp)
	case "close_session":
		return map[string]bool{"ok": true}, false, r.closeSession(stringParam(params, "agentSessionId"))
	case "validate_session":
		session, err := r.session(stringParam(params, "agentSessionId"))
		if err != nil {
			return nil, false, err
		}
		session.mu.Lock()
		defer session.mu.Unlock()
		return map[string]bool{"ok": true}, false, session.server.validateConnection()
	case "cancel_session":
		session, err := r.session(stringParam(params, "agentSessionId"))

View on GitHub (pinned to c0390bff16)

Solutions

  1. Generate and include a unique non-empty agentSessionId (e.g. a UUID) in the open_session params
  2. Check the client wrapper so session-opening calls always populate agentSessionId
  3. If only a single connection is needed, use the 'connect' RPC instead of open_session

Example fix

// before
r.call("open_session", map[string]any{"host": host})
// after
r.call("open_session", map[string]any{"agentSessionId": uuid.NewString(), "host": host})
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(sessionID) == "" { return errors.New("generate an agentSessionId before calling open_session") }

Try / catch

resp, err := r.call("open_session", params); if err != nil && strings.Contains(err.Error(), "agentSessionId is required") { /* fix client param construction */ }

Prevention

When it happens

Trigger: Calling the 'open_session' RPC without agentSessionId, or with an empty/whitespace stringParam result.

Common situations: A client wrapper forgot to generate or pass a session id; a multi-session tool reused a code path from single-session mode that never sets agentSessionId; params serialization dropped the field.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/eb65a132d1f49884. Report an issue: GitHub.