{"record":{"id":"dff5c36834466580","repo":"t8y2/dbx","slug":"agent-session-not-found-s-dff5c3","errorCode":null,"errorMessage":"agent session not found: %s","messagePattern":"agent session not found: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/oracle-go/main.go","lineNumber":783,"sourceCode":"\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc (r *runtimeServer) replaceSession(agentSessionID string, params connectParams) error {\n\t_ = r.closeSession(agentSessionID)\n\treturn r.openSession(agentSessionID, params)\n}\n\nfunc (r *runtimeServer) session(agentSessionID string) (*agentSession, error) {\n\tif agentSessionID == \"\" {\n\t\treturn nil, errors.New(\"agentSessionId is required\")\n\t}\n\tr.mu.RLock()\n\tsession := r.sessions[agentSessionID]\n\tr.mu.RUnlock()\n\tif session == nil {\n\t\treturn nil, fmt.Errorf(\"agent session not found: %s\", agentSessionID)\n\t}\n\treturn session, nil\n}\n\nfunc (r *runtimeServer) closeSession(agentSessionID string) error {\n\tif agentSessionID == \"\" {\n\t\treturn errors.New(\"agentSessionId is required\")\n\t}\n\tr.mu.Lock()\n\tsession := r.sessions[agentSessionID]\n\tdelete(r.sessions, agentSessionID)\n\tr.mu.Unlock()\n\tif session == nil {\n\t\treturn nil\n\t}\n\tsession.mu.Lock()\n\tdefer session.mu.Unlock()\n\treturn session.server.disconnect()","sourceCodeStart":765,"sourceCodeEnd":801,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/oracle-go/main.go#L765-L801","documentation":"The driver keeps interactive agent sessions in an in-memory map keyed by agentSessionID. When a lookup (getSession) is asked for an ID that is not currently tracked, it returns this error. An empty ID is rejected separately with 'agentSessionId is required', so this error specifically means a well-formed ID that has no live session.","triggerScenarios":"Calling any runtime method that resolves a session (e.g. executing statements within an agent session) with an agentSessionID that was never opened, or that was already closed via closeSession/disconnect, or after a driver process restart which cleared the in-memory map.","commonSituations":"Client caches a session ID from a previous run and reuses it after reconnecting; two concurrent clients where one closed the shared session; a typo'd or truncated session ID passed through tooling; the driver process was restarted so all sessions were lost.","solutions":["Re-open (or reconnect to) the agent session to obtain a fresh agentSessionID before retrying the call","Verify the agentSessionID being passed is the exact ID returned when the session was created (log it at creation)","Check that the session was not closed concurrently (closeSession/disconnect) by another client or timeout","If the driver restarted, treat all prior session IDs as invalid and rebuild client state"],"exampleFix":"// before\nsession, err := rt.getSession(staleSessionID) // error: agent session not found\n// after\nif _, err := rt.getSession(sessionID); err != nil {\n    sessionID, err = rt.openSession(cfg) // recreate session and use new ID\n    if err != nil { return err }\n}\nsession, err := rt.getSession(sessionID)","handlingStrategy":"validation","validationCode":"func validSessionID(id string) bool { return strings.TrimSpace(id) != \"\" }\n// also track liveness client-side; re-open on lookup failure","typeGuard":"func hasSession(rt *runtimeServer, id string) bool { _, err := rt.getSession(id); return err == nil }","tryCatchPattern":"session, err := rt.getSession(id)\nif err != nil {\n    // recreate session and retry once with the new ID\n    id, err = rt.openSession(cfg)\n    if err != nil { return err }\n    session, err = rt.getSession(id)\n}","preventionTips":["Treat session IDs as ephemeral: refetch after any driver restart or disconnect","Log the agentSessionID at creation and compare on every use","Centralize session access behind one client wrapper that auto-reopens on 'not found'","Avoid sharing a session ID across independent clients"],"tags":["go","oracle","session-state","stale-id"],"backgroundTag":"session-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}