t8y2/dbx · error
Hive Agent session not found: %s
Error message
Hive Agent session not found: %s
What it means
session(id) looks up a registered agent session under a read lock; if no session with that id is registered it returns this error. Callers (dispatch, closeSession helpers, withSession) use it to route per-session work, so it signals an unknown/stale session handle.
Source
Thrown at agents/drivers/hive-go/main.go:274
defer runtimeServer.mu.Unlock()
if _, exists := runtimeServer.sessions[id]; exists {
_ = server.disconnect()
return fmt.Errorf("Hive Agent session already exists: %s", id)
}
if len(runtimeServer.sessions) >= maxAgentSessions {
_ = server.disconnect()
return fmt.Errorf("maximum Hive Agent sessions reached (%d)", maxAgentSessions)
}
runtimeServer.sessions[id] = &agentSession{server: server}
return nil
}
func (runtimeServer *runtimeServer) session(id string) (*agentSession, error) {
runtimeServer.mu.RLock()
session := runtimeServer.sessions[id]
runtimeServer.mu.RUnlock()
if session == nil {
return nil, fmt.Errorf("Hive Agent session not found: %s", id)
}
return session, nil
}
func (runtimeServer *runtimeServer) closeSession(id string) error {
if id == "" {
id = legacyAgentSessionID
}
runtimeServer.mu.Lock()
session := runtimeServer.sessions[id]
delete(runtimeServer.sessions, id)
runtimeServer.mu.Unlock()
if session == nil {
return nil
}
session.mu.Lock()
defer session.mu.Unlock()
return session.server.disconnect()View on GitHub (pinned to c0390bff16)
Solutions
- Re-open the session (openSession) when this error occurs and retry the request.
- Ensure clients close sessions explicitly and stop using ids after close.
- After a runtime restart, have clients renegotiate sessions instead of reusing old ids.
- If behind a load balancer, enable sticky routing so all requests for a session hit the same runtime instance.
Example fix
// before
session, err := rt.session(id)
if err != nil { return err }
// after
session, err := rt.session(id)
if err != nil {
if strings.Contains(err.Error(), "session not found") {
if oerr := rt.openSession(id, params); oerr != nil { return oerr }
session, err = rt.session(id)
}
if err != nil { return err }
} Defensive patterns
Strategy: try-catch
Validate before calling
// Track session lifecycle client-side; never call after close
if closedSessions[id] {
return errors.New("session already closed locally")
} Try / catch
session, err := rt.session(id)
if err != nil {
if strings.Contains(err.Error(), "session not found") {
// re-establish and retry once
if oerr := rt.openSession(id, params); oerr == nil {
session, err = rt.session(id)
}
}
if err != nil { return err }
} Prevention
- Handle runtime restarts by re-opening sessions
- Stop using session ids after closeSession
- Enable sticky routing behind load balancers
- Log session ids consistently to avoid misrouted references
When it happens
Trigger: Any dispatch or close/withSession call referencing a session id that was never opened or was already closed via closeSession.
Common situations: Client caches a session id after the server restarted (in-memory sessions lost); double-close of a session; a typo'd or misrouted session id between worker components; load balancer routing requests to a different runtime instance than the one holding the session.
Related errors
- agent session not found: %s
- Agent session not found: %s
- agent session not found: %s
- agent session not found: {id}
- View source not found: " + name
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/73322c523a580e73.
Report an issue: GitHub.