{"record":{"id":"0ea6454e5cd2496f","repo":"rohitg00/agentmemory","slug":"codex-hooks-fallback-skipped-hookresult-reason","errorCode":null,"errorMessage":"Codex hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.","messagePattern":"Codex hooks fallback skipped: (.+?)\\. MCP wiring still applied\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cli/connect/codex.ts","lineNumber":122,"sourceCode":"    writeFileSync(CODEX_TOML, next, \"utf-8\");\n\n    const verify = readFileSync(CODEX_TOML, \"utf-8\");\n    if (!isWiredText(verify)) {\n      p.log.error(\n        `Verification failed: ${CODEX_TOML} did not contain ${SECTION_HEADER} after write.`,\n      );\n      return { kind: \"skipped\", reason: \"verification-failed\" };\n    }\n\n    logInstalled(\"Codex CLI\", CODEX_TOML);\n    p.log.info(\n      \"Codex picks up MCP servers on next launch. For the deeper plugin install, run: codex plugin marketplace add rohitg00/agentmemory && codex plugin add agentmemory@agentmemory\",\n    );\n\n    if (opts.withHooks) {\n      const hookResult = installCodexHooks(opts);\n      if (hookResult.kind === \"skipped\") {\n        p.log.warn(\n          `Codex hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.`,\n        );\n      }\n    }\n\n    return {\n      kind: \"installed\",\n      mutatedPath: CODEX_TOML,\n      ...(backupPath !== undefined && { backupPath }),\n    };\n  },\n};\n\n/**\n * Install the global `~/.codex/hooks.json` fallback. See\n * `codex-hooks.ts` for context (openai/codex#16430). Returns a result\n * describing the side effect for the caller's summary; failures here do\n * not roll back the MCP wiring.","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/cli/connect/codex.ts#L104-L140","documentation":"`agentmemory connect codex --with-hooks` wires the Codex MCP server and optionally installs hooks via installCodexHooks(). If that installer returns { kind: \"skipped\", reason }, the CLI logs this warning rather than failing, since MCP wiring already succeeded. Only the optional hooks fallback was not applied.","triggerScenarios":"Running `agentmemory connect codex --with-hooks` when installCodexHooks() returns a 'skipped' result — typically because the Codex config/hooks file cannot be located, the config directory does not exist, or a precondition of the hook installer fails.","commonSituations":"Codex installed but never launched (no config dir), a non-default CODEX_HOME, read-only or permission-restricted config paths, or stale Codex versions with different config layouts. Developers then see MCP working but no hook-based context recall in Codex sessions.","solutions":["Read hookResult.reason in the warning — it names the exact blocking condition.","Launch `codex` once so its config/hooks files are created, then re-run `agentmemory connect codex --with-hooks`.","Verify CODEX_HOME (if customized) points to the directory agentmemory expects and is writable.","If you only need MCP wiring, ignore the warning and confirm the server with `codex mcp list` / next launch.","Optionally use the deeper plugin install: `codex plugin marketplace add rohitg00/agentmemory && codex plugin add agentmemory@agentmemory`."],"exampleFix":"// before\nagentmemory connect codex --with-hooks\n// -> warning: Codex hooks fallback skipped: config file not found ...\n\n// after\ncodex --version          # run once to create config files\nagentmemory connect codex --with-hooks   # re-run; hooks installed","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nconst codexHome = process.env.CODEX_HOME ?? join(process.env.HOME ?? \"\", \".codex\");\nif (!existsSync(codexHome)) {\n  console.error(\"Codex config dir missing — launch `codex` once before `connect codex --with-hooks`.\");\n  process.exit(1);\n}","typeGuard":"type HookInstallResult = { kind: \"installed\" } | { kind: \"skipped\"; reason: string };\nfunction hookSkipped(r: unknown): r is { kind: \"skipped\"; reason: string } {\n  return typeof r === \"object\" && r !== null && \"kind\" in r && (r as any).kind === \"skipped\";\n}","tryCatchPattern":"try {\n  const hookResult = installCodexHooks(opts);\n  if (hookResult.kind === \"skipped\") {\n    console.warn(`Codex hooks skipped (${hookResult.reason}); MCP wiring still applied.`);\n  }\n} catch (err) {\n  console.warn(\"Codex hook install threw; MCP wiring remains applied:\", err);\n}","preventionTips":["Run `codex` once to create its config/hooks files before connecting with --with-hooks.","Verify CODEX_HOME / ~/.codex exists and is writable.","Remember MCP wiring and hooks are independent — a hooks skip does not affect the MCP server entry.","Re-run the connect command after fixing the environment."],"tags":["cli","hooks","codex","install"],"backgroundTag":"hooks-install-skipped","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}