thedotmack/claude-mem · error · AdapterRejectedInput
adapter rejected input: missing_session_id
Error message
adapter rejected input: missing_session_id
What it means
codexAdapter.normalizeInput throws AdapterRejectedInput('missing_session_id') when r.session_id is absent, empty, or not a string after stringOrUndefined coercion. Codex events always carry a session id, so the adapter treats it as mandatory for correlating hook data with a conversation.
Solutions
- Include a non-empty session_id string in the codex hook payload
- If synthesizing events, generate a stable id (e.g. crypto.randomUUID()) and pass it as session_id
- Update/verify the Codex CLI version so hook payloads still contain session_id
- Catch AdapterRejectedInput with .reason === 'missing_session_id' and fall back to constructing input with a placeholder id
Example fix
// before
codexAdapter.normalizeInput({ hook_event_name: 'SessionStart' });
// after
codexAdapter.normalizeInput({ hook_event_name: 'SessionStart', session_id: 'abc-123' }); Defensive patterns
Strategy: validation
Validate before calling
if (typeof raw?.session_id !== 'string' || raw.session_id.length === 0) raw = { ...raw, session_id: crypto.randomUUID() }; Type guard
function hasSessionId(v: unknown): v is string { return typeof v === 'string' && v.length > 0; } Try / catch
try { adapter.normalizeInput(raw); } catch (e) { if (e instanceof AdapterRejectedInput && e.reason === 'missing_session_id') { /* inject placeholder id or reject event */ } else throw e; } Prevention
- Always forward session_id from the Codex hook payload
- Generate and pass a UUID for synthetic events
- Verify Codex CLI version still includes session_id after upgrades
When it happens
Trigger: Invoking the codex adapter with a raw payload lacking session_id entirely, or with session_id: '' / null / a non-string. Startup/resume/clear source classification succeeds but the session id check then fails.
Common situations: Codex CLI version upgrade that renamed or removed session_id from hook payloads; hand-crafted test payloads forgetting session_id; notify hooks (non-startup events) built from truncated JSON that dropped the field.
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
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/11b2ce64165cd542.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/adapters/codex.ts:85
const hookEventName = eventName(r.hook_event_name);
const toolName = stringOrUndefined(r.tool_name);
let toolInput = cloneToolInput(r.tool_input);
if (hookEventName === 'PreToolUse' && toolName) {
const filePaths = extractFilePaths(toolName, toolInput, cwd);
if (filePaths.length > 0 && toolInput && typeof toolInput === 'object' && !Array.isArray(toolInput)) {
toolInput = { ...(toolInput as Record<string, unknown>), filePaths };
}
}
const source = r.source;
const sessionSource =
source === 'startup' || source === 'resume' || source === 'clear'
? source
: undefined;
const sessionId = stringOrUndefined(r.session_id);
if (!sessionId) {
throw new AdapterRejectedInput('missing_session_id');
}
return {
sessionId,
cwd,
prompt: stringOrUndefined(r.prompt),
toolName,
toolInput,
toolResponse: r.tool_response,
transcriptPath: stringOrUndefined(r.transcript_path),
lastAssistantMessage: stringOrUndefined(r.last_assistant_message),
turnId: stringOrUndefined(r.turn_id),
stopHookActive: booleanOrUndefined(r.stop_hook_active),
permissionMode: stringOrUndefined(r.permission_mode),
model: stringOrUndefined(r.model),
sessionSource,
};
},View on GitHub (pinned to d8bc9755e7)