Skip to content

Active Memory Codex recalls repeat, time out, then fail as generation no longer current #106957

Closed

Description

@jameswagar

Summary

Active Memory using the Codex agent harness intermittently starts multiple recall runs for one inbound turn. When a run reaches its timeout, a subsequent run often fails with Codex session generation is no longer current. Successful recalls are therefore not reliably carried through, and direct replies can be delayed by the full timeout budget multiple times.

Environment

  • OpenClaw: 2026.7.1
  • Platform: macOS arm64
  • Node: 22.23.1
  • Provider/harness: OpenAI Codex
  • Active Memory model: openai/gpt-5.6-luna
  • Query mode: recent
  • Prompt style: balanced
  • Recall timeout: 15000 ms
  • Setup grace tested: 0 ms and 5000 ms

The same basic timeout pattern occurred before upgrading from 2026.6.11, while the stale-generation follow-on was observed prominently on 2026.7.1.

Reproduction

  1. Enable Active Memory for a direct-chat agent using the Codex harness.
  2. Set the model to openai/gpt-5.6-luna, timeoutMs: 15000, and setupGraceTimeoutMs: 5000.
  3. Send short direct messages that ask for known durable-memory facts, one at a time.
  4. Inspect Active Memory and Codex harness logs for the single inbound trace.

Observed results

A five-message smoke test produced 3 passes and 2 failures:

  • Successful recall pairs completed in 10.5-16.2 seconds and then used a cached result.
  • One failure produced two recalls that each exhausted the 20000 ms effective budget, followed by Codex session generation is no longer current.
  • Another failure had an initial successful recall at 18.9 seconds, but a follow-on recall exhausted 20000 ms and the retry then failed with the same stale-generation error.
  • Increasing setup grace changed some borderline timeouts into successes, but did not eliminate the repeated-run/session-lifecycle failure.

Representative sanitized log sequence:

active-memory ... activeModel=gpt-5.6-luna start timeoutMs=15000
active-memory ... done status=ok elapsedMs=18916 summaryChars=101
active-memory ... activeModel=gpt-5.6-luna start timeoutMs=15000
lane task error: lane=active-memory durationMs=20024 error="Error: active-memory timeout after 20000ms"
active-memory ... done status=timeout elapsedMs=20000 summaryChars=0
active-memory ... activeModel=gpt-5.6-luna start timeoutMs=15000
Codex agent harness failed; not falling back to embedded OpenClaw backend
Error: Codex session generation is no longer current: active-memory-<redacted>
active-memory ... done status=failed elapsedMs=258 summaryChars=0

The behavior also reproduced with the heavier openai/gpt-5.6-sol model and shorter legacy timeout, but switching to Luna and restoring the current 15-second default did not make it reliable.

Expected behavior

  • One inbound turn should not launch redundant blocking recalls, or later generations should reuse the first successful recall result.
  • A timed-out Codex recall should cleanly retire/cancel its session so a retry does not fail as no longer current.
  • A successful recall should remain usable even if a later internal generation/retry occurs.

Workaround

Active Memory was disabled temporarily. Explicit memory search remains functional.

Activity

  1. added
    P1
    impact:session-state
    issue-rating: 🐚 platinum hermit
    clawsweeper:needs-live-repro
    on Jul 14, 2026
  2. clawsweeper commented on Jul 14, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 13, 2026, 9:38 PM ET / July 14, 2026, 01:38 UTC.

    Summary
    Keep this issue open: the report gives current-release reproduction steps and sanitized logs showing a real Active Memory reliability failure, while the evidence does not establish that current main fixes either redundant recalls or stale Codex generation cleanup.

    Reproducibility: no. independent current-main run is available, but the issue provides a precise current-release setup, a five-turn result set, and a sanitized log sequence that identifies the failing recall and Codex generation path.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.
    • Share version, platform, channel/provider, and relevant config details.

    Next step
    The report is concrete and bounded enough for one repair attempt, but the worker must reproduce current main and inspect the exact Codex cancellation contract before selecting the final owner boundary.

    Review details

    Best possible solution:

    Use one stable inbound-turn key to share an in-flight Active Memory recall and preserve its first successful result, while making timeout cancellation await Codex session retirement before any retry or replacement generation starts.

    Do we have a high-confidence way to reproduce the issue?

    No independent current-main run is available, but the issue provides a precise current-release setup, a five-turn result set, and a sanitized log sequence that identifies the failing recall and Codex generation path.

    Is this the best way to solve the issue?

    Unclear until the same-turn hook callers and Codex cancellation contract are traced together; fixing only the timeout value or adding another retry would not address redundant execution or stale generation ownership.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The available evidence does not yet distinguish whether duplicate hook invocations, completed-result-only caching, or Codex timeout cleanup is the primary cause; a one-sided fix could leave the other failure mode intact.
    • The report is against v2026.7.1 rather than an independently exercised current-main build, so the exact current-main failure frequency remains unverified.

    Codex review notes: model internal, reasoning high; reviewed against e330e4a17d3c.

    Label changes

    Label changes:

    • add P1: A documented agent workflow intermittently blocks direct replies for multiple timeout budgets and then loses usable recall behavior on the latest release.
    • add impact:session-state: The failure crosses recall retries and Codex generation ownership, producing stale session-generation state and discarded successful recall results.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.

    Label justifications:

    • P1: A documented agent workflow intermittently blocks direct replies for multiple timeout budgets and then loses usable recall behavior on the latest release.
    • impact:session-state: The failure crosses recall retries and Codex generation ownership, producing stale session-generation state and discarded successful recall results.
    Evidence reviewed

    Acceptance criteria:

    • pnpm test extensions/active-memory/index.test.ts
    • pnpm test extensions/codex/src/app-server/run-attempt.test.ts
    • pnpm check:changed -- extensions/active-memory/index.ts extensions/active-memory/index.test.ts extensions/codex/src/app-server/run-attempt.ts extensions/codex/src/app-server/run-attempt.test.ts
    • Run a sanitized Codex-harness Active Memory smoke scenario showing one recall per inbound turn and a successful turn after a forced recall timeout.

    What I checked:

    • Current-release reproduction: The report documents a five-message smoke test on v2026.7.1 with two failures, including repeated 20-second recall budgets followed by a stale-generation error; disabling Active Memory avoids the failing path while explicit memory search still works. (2d2ddc43d0dc)
    • Documented behavior contract: Active Memory is documented as a blocking pre-reply recall with an effective budget composed from the configured timeout and setup grace, supporting the expectation that recall completes or times out predictably before reply generation. Public docs: docs/concepts/active-memory.md. (docs/concepts/active-memory.md:346, e330e4a17d3c)
    • Implementation ownership: The bundled Active Memory plugin owns recall execution, result caching, timeout handling, and hook integration, making it the first surface to inspect for same-turn in-flight deduplication. (extensions/active-memory/index.ts:1, e330e4a17d3c)
    • Codex lifecycle boundary: Codex app-server sessions are stateful thread/turn resources; the stale-generation message indicates that cancellation or replacement ordering must be checked directly rather than treating this as only a slow-model timeout. (../codex/codex-rs/app-server/README.md:794)
    • Related tracker: [Bug]: Track Codex harness stability work #66251 broadly tracks Active Memory recall reliability and timeout behavior, but it does not replace this issue's specific duplicate-run and stale-generation evidence.
    • Earlier overlapping report: Reliability: active-memory blocks replies and QMD boot initialization can overload multi-agent gateways #72015 reports Active Memory blocking replies around its timeout budget; it overlaps on latency but does not establish the same Codex generation-lifecycle failure.

    Likely related people:

    • vincentkoc: The Active Memory implementation appears to have received a substantial configuration and runtime refactor in commit db5895f. (role: feature history contributor; confidence: high; commits: db5895fd2a33; files: extensions/active-memory/index.ts)
    • Takhoffman: Recent merged Active Memory work around QMD defaults and plugin behavior makes this person relevant to recall-path expectations and regression coverage. (role: recent Active Memory contributor; confidence: medium; files: extensions/active-memory/index.ts, extensions/active-memory/index.test.ts)
    • joshavant: Recent work and discussion around Codex app-server timeout and liveness behavior are closely adjacent to the reported stale-generation lifecycle. (role: recent Codex runtime contributor; confidence: medium; files: extensions/codex/src/app-server/run-attempt.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. reisball commented on Jul 16, 2026

    @reisball

    Additional sanitized live reproduction from a separate Linux installation.

    Environment:

    • OpenClaw 2026.7.1 (2d2ddc4)
    • Linux x86_64
    • Node v24.18.0
    • Direct Telegram session
    • Active Memory model: openai/gpt-5.6-luna
    • queryMode: message
    • promptStyle: recall-heavy
    • timeoutMs: 30000
    • persistTranscripts: false
    • only memory_search allowed, with a prompt requiring exactly one search before answering or returning NONE

    Before enabling the live hook, the same model passed three isolated full-agent-harness cases (positive long-context recall, negative recall, and semantic recall) in 16.09-19.44 seconds.

    One live inbound turn then produced this sequence:

    active-memory ... start ... queryChars=8183
    active-memory ... done status=ok elapsedMs=24348 summaryChars=73
    active-memory ... start ... queryChars=49730
    active-memory ... done status=timeout_partial elapsedMs=30004
    Codex session generation is no longer current: active-memory-<redacted>
    

    The first recall was correct and called memory_search exactly once. Despite that successful result, the same inbound turn started another recall with a much larger prompt, then a further attempt hit the stale-generation failure.

    A separate canary with a local non-Codex recall model also launched multiple Active Memory recalls for one inbound turn, with recall input growing from about 9k to 17k characters. That suggests the redundant hook/run behavior is not specific to Luna, while the final stale-generation error is Codex-specific.

    This appears to overlap with the raw event.prompt envelope issue in #88077 / #92013. The installed 2026.7.1 plugin still passes event.prompt into buildQuery, and completed-result caching is keyed by the full query text; a changed/inflated prompt therefore misses the previous result.

    Workaround remains disabling Active Memory. Explicit memory_search is healthy. No raw prompts, memory contents, identifiers, paths, or private infrastructure details are included here.

  4. ZaneMc-AO commented on Jul 22, 2026

    @ZaneMc-AO

    I can reproduce a closely related failure in WebChat using the native Codex runtime.

    The user-visible error is:

    Codex binding generation was retired: session-key:main:<redacted>

    Behaviour:

    • A WebChat message is accepted by the gateway but no assistant response appears.
    • The UI appears to retry or replay the request against the retired Codex binding generation.
    • Resetting the affected chat session restores normal operation, but the old browser/chat generation can continue surfacing the error until a hard refresh or new chat.
    • This looks consistent with the generation-lifecycle problem in this issue, but via the WebChat binding/replay path rather than Active Memory. In particular, a retired generation does not appear to be cleanly invalidated or rebound before a subsequent request is attempted.

    Environment:

    • Channel: WebChat direct conversation
    • Runtime: OpenAI Codex / native Codex harness
    • Host: macOS arm64
    • OpenClaw version: 2026.7.1 (2d2ddc4)
  5. self-assigned this
    on Jul 29, 2026
  6. added a commit that references this issue on Jul 29, 2026
    1b94810
  7. steipete commented on Jul 29, 2026

    @steipete
    Contributor

    Fixed on main by #115627 in 1b94810.

    Active Memory now keeps a per-run recall registry keyed by ctx.runId: overlapping or changed-prompt attempts within one run join a single recall, replacement is gated until settled timeout cleanup has retired the prior manager, and the registry entry is cleared on agent_end. The earlier collision half was fixed in #105255; #115627 completes the run-scoped ownership and cleanup-ordering fix.

    Proof: the quiet-host Active Memory extension suite passed 195/195, the rejected-replacement regression passed in isolation, final Codex autoreview was clean, and exact-head hosted CI passed before merge.

  8. added a commit that references this issue on Jul 29, 2026
    7d3758b
  9. locked as resolved and limited conversation to collaborators on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1clawsweeper:needs-live-reproimpact:session-stateissue-rating: 🐚 platinum hermit

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions