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

Open Beginner friendly
#2,075 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
backend

Research direction

Start in integrations/claude-code-plugin/lib/working-memory.mjs at firstUserPrompt, then compare its row filtering with lib/session-brief.mjs:157 and lib/test-gate.mjs:1090. Run the reproduction command in the issue and check both plugin copies, including the Codex plugin’s lib/working-memory.mjs. Done when caveat rows and local command echoes are skipped, while a command with arguments can still be used as the goal and sessions without a typed request retain the journal fallback.

Written by the indexing model from the issue text.

Description

bug good first issue help wanted up-for-grabs
Company

ClickHouse

Component

Agent plugin (Claude Code, Codex, Cursor)

Describe what's wrong

The Stop hook's working-memory bookmark (block session:<project>) records the text Claude Code injects for a local slash command as the session's goal:, not the person's first request. A session that starts with /clear is saved as:

goal: <local-command-caveat>The command below was run directly in Claude Code, not sent to you as a request…

The next session's primer shows that line as the goal of the work it resumes.

firstUserPrompt (integrations/claude-code-plugin/lib/working-memory.mjs:40) skips sidechain rows and tool results. It does not skip rows the client wrote itself: the isMeta: true caveat row, and the <command-name>/clear</command-name> row that echoes the command. lib/session-brief.mjs:157 and lib/test-gate.mjs:1090 already skip isMeta rows. The Codex plugin's lib/working-memory.mjs is the same file.

Does it reproduce on the latest release or main?

Yes

How to reproduce

From the repository root on main:

node --input-type=module -e '
import { firstUserPrompt } from "./integrations/claude-code-plugin/lib/working-memory.mjs";
const rows = [
  { type: "user", isMeta: true, message: { role: "user", content: "<local-command-caveat>Caveat: ...</local-command-caveat>" } },
  { type: "user", message: { role: "user", content: "<command-name>/clear</command-name>\n<command-message>clear</command-message>\n<command-args></command-args>" } },
  { type: "user", message: { role: "user", content: "fix the failing search test" } },
];
console.log(JSON.stringify(firstUserPrompt(rows)));
console.log(JSON.stringify(firstUserPrompt(rows.slice(1))));
'

The first line prints the caveat. The second, with the caveat row removed, prints the /clear echo. Both should print "fix the failing search test".

In a live session: start Claude Code with the plugin, run /clear, send a request, end the session, then read the session:<project> working-memory block.

Expected behavior

goal: holds the first request the person typed. firstUserPrompt skips isMeta rows and the echoes of local commands (<command-name> with empty <command-args>, <local-command-stdout>). A command with arguments, such as /<skill> <args>, is a request and can stand as the goal in that form. A session with no typed request falls back to the turn journal, as it does today.

Environment
  • main at b97367188600bb12a5c3acdd4ac25903019b0b44
  • Claude Code and Codex plugins 1.2.158
  • Node 25.8.0
How this was found

An AI tool found it, and I have not reproduced it myself

Additional context

It happens in every session whose first input is a local slash command such as /clear or /model: the transcript starts with the caveat row, then the command echo, then the request.

Redaction
  • I removed tokens, keys, passwords and personal or customer data from everything above.
Dominant language
Python
Stars
263
Forks
47
Avg merge
14h 13m
Merged PRs (30d)
868

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ClickHouse/loom

All issues in ClickHouse/loom

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.