Skip to content

fix(coding-agent): label Mnemopi recall-query truncation as mnemopi.recall - #15413

Open
jaredlyon wants to merge 2 commits into
can1357:mainfrom
jaredlyon:fix/mnemopi-recall-truncation-phase
Open

jaredlyon wants to merge 2 commits into
can1357:mainfrom
jaredlyon:fix/mnemopi-recall-truncation-phase

Conversation

@jaredlyon

@jaredlyon jaredlyon commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Another addition to the recall logging. For debugging, of course.

What

Follow-up to #15001. Two of the three Mnemopi recall paths closed the mnemopi.recall span after composeRecallQuery() and then called truncateRecallQuery() unlabeled:

  • recallForCompaction() (mnemopi/state.ts)
  • maybeRecallOnAgentStart(), the background first-turn recall

Both now compose and truncate inside one mnemopi.recall span, the same way beforeAgentStartPrompt() already did. Nothing else changes: the span wraps the same synchronous expressions, and no await moves.

Why

Codex flagged this on #15001 after its last push (thread), and #15001 was merged before it was fixed. truncateRecallQuery() repeatedly unshifts and joins context lines while filling the budget. With a raised mnemopi.recallMaxQueryChars and a long, newline-heavy context, a stall there was logged as phase: "unknown" instead of mnemopi.recall.

Refs #15027.

Testing

  • New case in test/mnemopi-loop-phase-coverage.test.ts. It spies on truncateRecallQuery, records currentLoopPhase() on each call, and runs all three recall paths against a real Mnemopi bank:
    • on main: fails with ["mnemopi.recall", undefined, undefined]
    • with the fix: passes with mnemopi.recall three times
  • Windows 11 x64, Bun 1.4.2: bun run check passes in packages/coding-agent. These suites are 0 fail:
    • mnemopi-loop-phase-coverage (2)
    • memory-tools (75)
    • memory-recall-resume (20)
    • agent-session-memory-backend (24)
    • agent-session-message-pipeline (80)
    • agent-session-queued-policy (47)
    • agent-session-dispose-concurrent (5)
    • hindsight-backend (31)
    • internal-urls/memory-protocol (32)
    • memory-redaction (9)
    • autolearn-tools-gating (18)
  • mnemopi-recall-features fails 1 of 2 identically on main: the temp-dir cleanup in afterEach hits a Windows file lock.

  • bun check passes
  • Tested locally
  • CHANGELOG updated with the required attribution (if user-facing; internal issue fixes use issue links, external contributions add the PR link and contributor credit after creation)

…ecall

recallForCompaction() and maybeRecallOnAgentStart() closed the mnemopi.recall
span after composeRecallQuery() and ran truncateRecallQuery() unlabeled, so a
stall in truncation logged phase "unknown". Both now compose and truncate in one
span, as beforeAgentStartPrompt() already did.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T21:23:29.196710Z 8b8817b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@roboomp roboomp added agent Agent runtime planning and orchestration fix review:p0 triaged labels Oct 11, 2026

@roboomp roboomp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, P0, ready to merge. recallForCompaction() (mnemopi/state.ts:681) and the background first-turn recall (:814) now compose and truncate inside a single withLoopPhase("mnemopi.recall", …) block, the same way beforeAgentStartPrompt() (:649) already does. Only synchronous code moved into the span, and no await changed position.

Checked locally: bun test test/mnemopi-loop-phase-coverage.test.ts passes 2/2. oxfmt --check and oxlint are clean on both touched files. The spy records three truncateRecallQuery calls, so it does intercept the namespace import. On main the two unwrapped call sites would record undefined. The changelog entry is under [Unreleased] with credit.

Thanks @jaredlyon for closing out the leftover thread from #15001.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Agent runtime planning and orchestration fix review:p0 triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants