t8y2/dbx · error

agent session not found

Error message

agent session not found

What it means

errAgentSessionNotFound is a sentinel error thrown when a session lookup by agentSessionID fails (session == nil). Callers wrap it with the session ID via %w so errors.Is can detect it; classifyRPCError categorizes it as a protocol error with SessionDisposition "quarantine".

Source

Thrown at agents/drivers/xugu/protocol_error.go:18

package main

import (
	"context"
	"database/sql"
	"database/sql/driver"
	"errors"
	"fmt"
	"io"
	"net"
	"regexp"
	"strconv"
	"strings"
)

var (
	errAgentSessionLimit     = errors.New("agent session limit reached")
	errAgentSessionNotFound  = errors.New("agent session not found")
	errXuguOperationTimeout  = errors.New("xugu operation timed out")
	errXuguOperationCanceled = errors.New("xugu operation canceled")

	// go-xugu-driver exposes server errors as plain strings rather than a typed
	// error. Match only the stable server error header and keep the complete
	// original message for diagnostics. A response can contain more than one
	// Xugu error; vendorCode intentionally records the first/top-level code.
	xuguServerErrorHeader = regexp.MustCompile(`(?im)^[\t ]*(?:error:[\t ]*)?\[[\t ]*E([0-9]{1,9})(?:[\t ]+L([0-9]+))?(?:[\t ]+C([0-9]+))?[\t ]*\]`)
	xuguQueryTimeout      = regexp.MustCompile(`(?i)^query timed out after [1-9][0-9]*s$`)
)

type rpcError struct {
	Code    int           `json:"code"`
	Message string        `json:"message"`
	Data    *rpcErrorData `json:"data,omitempty"`
}

type rpcErrorData struct {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Reconnect and obtain a fresh agent session ID before retrying
  2. Verify the session ID matches one returned by the original connect call
  3. Handle disconnect semantics: once released, the ID is permanently invalid
  4. Inspect the structured error's SessionDisposition field to confirm quarantine

Example fix

// before
resp, err := rpc.Call(sessionID) // err: "agent session not found: abc"
retry(sessionID)
// after
if errors.Is(err, errAgentSessionNotFound) {
    sessionID = r.connect(...) // new session
    resp, err = rpc.Call(sessionID)
}
Defensive patterns

Strategy: try-catch

Try / catch

resp, err := callRPC(sessionID, req)
if err != nil && errors.Is(err, errAgentSessionNotFound) {
    sessionID = reconnect() // obtain a fresh session
    resp, err = callRPC(sessionID, req)
}

Prevention

When it happens

Trigger: Calling an RPC that resolves a session by ID (main.go:955 path) with an ID that was never registered, or that was already released/removed after disconnect.

Common situations: Client retrying with a stale session ID after server restart, double-disconnect invalidating the session, or the server quarantining a failed session while the client still references it.

Related errors


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