Skip to content

fix(plugins): skip the slash-command caveat and echoes when picking the session goal - #2092

Open
akx-vishnu wants to merge 4 commits into
ClickHouse:mainfrom
akx-vishnu:fix/working-memory-goal-2075
Open

akx-vishnu wants to merge 4 commits into
ClickHouse:mainfrom
akx-vishnu:fix/working-memory-goal-2075

Conversation

@akx-vishnu

@akx-vishnu akx-vishnu commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #2075

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The Claude Code and Codex plugins' working-memory bookmark records the first request you typed as the session's goal, not the caveat Claude Code injects when a session starts with a local slash command such as /clear or /model.

Why

firstUserPrompt (integrations/claude-code-plugin/lib/working-memory.mjs) returned the first user row that was not a sidechain or a tool result. A session that starts with a local command begins with the client's isMeta caveat row, then the command's echo (<command-name>/clear</command-name>…<command-args></command-args>), then the request. So goal: held the caveat, or the /clear echo once the caveat was gone, and the next session's primer showed it as the work to resume.

Scope and risk

  • firstUserPrompt now skips isMeta rows, as session-brief.mjs and test-gate.mjs already do. It also skips the echo of a command run with no arguments (<command-name> with empty or missing <command-args>) and local-command output (<local-command-stdout>, -stderr, -caveat).
  • A command with arguments (/<skill> <args>) is a request and still stands as the goal, in its raw form.
  • A session with no typed request gets "", so the caller falls back to the turn journal as before.
  • The Codex copy is synced with python -m scripts.codegen.agent_plugin_sync. Both plugin manifests move to 1.2.168: main is at 1.2.162, and other open PRs use 1.2.163 and 1.2.167.

Compatibility, rollout and rollback

  • Wire: none; no op or field changes.
  • Operator steps: none. Users get it with plugin 1.2.163.
  • Rollback: reverting restores the old goal; bookmarks already written keep their text until the next session overwrites them.

Tests

  • Two new cases in tests/working-memory.test.mjs with the rows from the issue's repro: caveat + /clear echo + request, echo + request, the same plus <local-command-stdout>, only client rows (""), and a command with arguments kept as the goal. node --test integrations/claude-code-plugin/tests/working-memory.test.mjs: 16 passed.
  • The issue's repro script now prints "fix the failing search test" twice.
  • session-brief.test.mjs, which also imports this module, passes. node --check passes on both copies.
  • On Windows, record-hook.test.mjs and session-start.test.mjs time out, and tests/unit/test_codex_plugin.py::test_install_codex_dry_run_runs_nothing_and_capture_writes_loom_config fails. Clean main gives the same results on this machine, so I left those to CI on Linux.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. I checked the skip rules against the issue's rows and against session-brief.mjs / test-gate.mjs, read the diff, and ran the tests above.

Note

Low Risk
Localized transcript filtering for session bookmarks; no API or persistence schema changes.

Overview
Fixes session goal picking when a Claude Code session starts with a bare local slash command (/clear, /model). Working-memory’s firstUserPrompt now ignores client-injected isMeta rows, empty-argument command echoes (<command-name> … empty <command-args>), and <local-command-*> output—same skip ideas as session-brief.mjs and test-gate.mjs. Slash commands with arguments still count as the goal. If nothing remains, the hook still falls back to the turn journal via goal: firstUserPrompt(objs) || firstUser(journal).

The same logic is synced to the Codex plugin; both manifests bump to 1.2.168. New unit tests cover caveat + echo + real request, stdout-only noise, and argument-bearing commands.

Reviewed by Cursor Bugbot for commit 4b2587c. Bugbot is set up for automated code reviews on this repo. Configure here.

…he session goal

The working-memory bookmark took the first user row of the transcript as the
session's goal. A session that starts with a local slash command such as
/clear begins with the client's isMeta caveat row and the command's echo, so
the bookmark recorded the caveat as the goal and the next session's primer
showed it.

firstUserPrompt now skips isMeta rows, the echo of a command run with no
arguments, and local-command output. A command with arguments is a request
and still stands as the goal. Both plugins move to 1.2.163.

Closes ClickHouse#2075

Signed-off-by: akx-vishnu <akx-vishnu@users.noreply.github.com>
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 3, 2026 8:21pm UTC
loom-telemetry Ready Ready Preview Dec 3, 2026 8:21pm UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 9401e50. Configure here.

Claude Code writes a local command's echo with <command-message> first in
some versions, so those echoes still became the session goal.

Signed-off-by: akx-vishnu <akx-vishnu@users.noreply.github.com>
@zlareb1 zlareb1 self-assigned this Dec 3, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No blocking findings. The parser skips caveats, local output and both tag orders for argument-free command echoes. Commands with arguments and the journal fallback keep their existing behavior. The plugin copies match. The focused Node suites passed 35 tests with one skip.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Node tests pass. The format job found two lines in the added fixture that the pinned Biome formatter rejects.

…tures

Signed-off-by: akx-vishnu <akx-vishnu@users.noreply.github.com>
@akx-vishnu

Copy link
Copy Markdown
Contributor Author

Thanks, fixed in 138b99f: I applied npx --yes @biomejs/biome@2.5.14 format to the test file; it now reports no fixes, and the lib files were already clean. node --test integrations/claude-code-plugin/tests/working-memory.test.mjs: 16 passed.

zlareb1
zlareb1 previously approved these changes Dec 3, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fixture passes Biome 2.5.14. The working-memory tests verify that both echo formats are skipped, a command with arguments is kept, and the bookmark falls back to its journal when no prompt remains. Both plugin copies match.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GitHub reports a merge conflict with main in both plugin manifests. Please reconcile the version bumps and keep the manifests in sync.

…al-2075

Signed-off-by: akx-vishnu <akx-vishnu@users.noreply.github.com>

# Conflicts:
#	integrations/claude-code-plugin/.claude-plugin/plugin.json
#	integrations/codex-plugin/.codex-plugin/plugin.json
@akx-vishnu

Copy link
Copy Markdown
Contributor Author

Reconciled in 4b2587c: I merged main and set both manifests to 1.2.168. Main is at 1.2.162, and 1.2.163 through 1.2.167 are taken by other open PRs, so this avoids sharing a version. The two manifests match, agent_plugin_sync reports no drift, and the working-memory tests pass (16).

@akx-vishnu

Copy link
Copy Markdown
Contributor Author

Correction to my last comment: of the recent open PRs, 1.2.163 and 1.2.167 are in use (not the whole 163–167 range). 1.2.168 is above both.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Both plugin copies select the first typed request after a local-command caveat, echo, or output. The focused suite passed 15 tests, with one Windows-only case skipped. Both manifests agree on version 1.2.168.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The pinned Biome check rejects the same dashboard assertion on this merge and on main. The separate repair formats that assertion. Failed job · Repair #2107

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The prepared-bot test fails at first-cell automation on this head and on clean main under Postgres 16. The repair waits for the first web process to enforce tenancy before provisioning the bot. Failed job · Repair #2106

@zlareb1

zlareb1 commented Dec 4, 2026

Copy link
Copy Markdown
Member

@akx-vishnu plz fix merge conflicts

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Working-memory bookmark records a slash-command caveat as the session goal

2 participants