claude-code - 💡(How to fix) Fix `/compact <custom-args>` topic-redirect silently overridden — clobbered title is re-injected to model as session-intent (forked sessions, related to #29922)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When a session has its custom-title overwritten by the /compact title-revert bug (see #29922), the wrong title doesn't just affect the picker label — it gets injected into the model's context on the very next turn as a <system-reminder> describing the session's intent. Combined with a re-injection of the parent session's original opening prompt (on forked sessions), this silently overrides the topic-redirect the user expressed via /compact <custom-args>, causing the agent to continue working on the old topic while the user believes they have switched contexts.

This is filed separately from #29922 because the user-visible impact is a correctness failure (/compact <args> ignored), not a label glitch. Same root data, materially different severity and likely a distinct fix surface.

Root Cause

This is filed separately from #29922 because the user-visible impact is a correctness failure (/compact <args> ignored), not a label glitch. Same root data, materially different severity and likely a distinct fix surface.

Fix Action

Workaround

There isn't a clean one. The user has to:

  1. Notice the agent has drifted (often expensive — wasted tool calls, sub-agents, and context tokens).
  2. Escape.
  3. Manually re-state the redirect in plain text and hope the next reminder injection doesn't pull from the same source.

Re-running /rename doesn't help if the next /compact will clobber it again.

Code Example

line 1566: custom-title = "Renamed Title B"                  ← user's earlier /rename, persisted
...
line 2886: [type=user] "This session is being continued..."/compact begins
line 2888: [type=user] /compact <command-args>"<topic-redirect instruction to switch to Topic B>"
line 2903: custom-title = "Renamed Title B"                  ← still correct immediately post-compact
line 2905: custom-title = "Original Title A"BUG: clobbered (#29922)
line 2906: agent-name   = "Original Title A"
line 2908: [type=user] "<user's first prompt under the new (Topic B) intent>"
line 2911: [type=user] "<system-reminder>The user named this session 'Original Title A'.
                        This may indicate the session's focus or intent.</system-reminder>"
line 2914: [type=user] "<verbatim re-injection of the parent session's opening prompt — Topic A kickoff>"
... ~1,300 records of model activity follow ...
RAW_BUFFERClick to expand / collapse

Summary

When a session has its custom-title overwritten by the /compact title-revert bug (see #29922), the wrong title doesn't just affect the picker label — it gets injected into the model's context on the very next turn as a <system-reminder> describing the session's intent. Combined with a re-injection of the parent session's original opening prompt (on forked sessions), this silently overrides the topic-redirect the user expressed via /compact <custom-args>, causing the agent to continue working on the old topic while the user believes they have switched contexts.

This is filed separately from #29922 because the user-visible impact is a correctness failure (/compact <args> ignored), not a label glitch. Same root data, materially different severity and likely a distinct fix surface.

Environment

  • Claude Code 2.1.149 (also reproducible on 2.1.150)
  • macOS (Darwin 25.2.0)
  • Session was a forked session running with sessionKind: "bg"

What /compact <custom-args> is supposed to do

/compact <some custom instruction> is the documented way to compact a long conversation and redirect it to a new topic. The custom args land in the compaction prompt and instruct the model on what context to keep and what topic to focus on going forward. Users rely on this to pivot a long-running session to a new task without losing all the accumulated tool state.

What actually happens

Sequence observed in the session's JSONL, sanitized:

line 1566: custom-title = "Renamed Title B"                  ← user's earlier /rename, persisted
...
line 2886: [type=user] "This session is being continued..."  ← /compact begins
line 2888: [type=user] /compact <command-args>"<topic-redirect instruction to switch to Topic B>"
line 2903: custom-title = "Renamed Title B"                  ← still correct immediately post-compact
line 2905: custom-title = "Original Title A"                 ← BUG: clobbered (#29922)
line 2906: agent-name   = "Original Title A"
line 2908: [type=user] "<user's first prompt under the new (Topic B) intent>"
line 2911: [type=user] "<system-reminder>The user named this session 'Original Title A'.
                        This may indicate the session's focus or intent.</system-reminder>"
line 2914: [type=user] "<verbatim re-injection of the parent session's opening prompt — Topic A kickoff>"
... ~1,300 records of model activity follow ...

Two things happen at the moment of the next user turn after the title clobber:

  1. A <system-reminder> is injected telling the model the session's intent — using the clobbered title. Whatever code path emits this reminder reads the session's current custom-title value. Because #29922 has just overwritten it with the parent's title, the model is now being told the session is about Topic A, not the topic the user just explicitly redirected to via /compact <args>.

  2. The parent session's original opening prompt is re-injected verbatim as a user-type record. This further anchors the model to Topic A. (I have not been able to confirm whether this re-injection happens on non-forked sessions; on this forked session it definitely did.)

Downstream effect

After those injections, the model in this session spawned 21 Task sub-agent calls doing research on Topic A (the parent's topic, not the user's redirect). Roughly 1,300 transcript records of work accumulated before the user noticed the drift and hit Escape. None of that work was useful — the user wanted Topic B context.

The user-visible effect from inside the session is "I typed a Topic B question, hit submit, and the agent went off doing a bunch of Topic A research." From outside the session (looking at the picker) the title also looks wrong. But the session-steering is the dangerous part: /compact <args> is supposed to be a hard topic-redirect and it is being silently no-op'd.

Why this is not just #29922

#29922 reads as a session-label/UI bug. Triagers may reasonably file it as a papercut. But:

  • The clobbered title is consumed by the model via a <system-reminder> injection, so the impact is on agent behavior, not just on what shows up in /resume.
  • A user who uses /compact <args> to refocus a long session has no way to know the redirect was overridden — they will only notice when the agent starts producing irrelevant work, and may not connect that back to the title at all.
  • Fix surfaces are likely separable:
    • #29922's fix needs the title-write race resolved on /compact.
    • This issue's fix needs the session-intent reminder to either (a) read from the user's most recent rename intent rather than the disk title at injection time, or (b) suppress itself for N turns after a /compact <args> that explicitly redirected the session.
    • The parent-prompt re-injection on forked sessions is a third, related-but-distinct path worth auditing.

Repro

  1. In session A, set a custom title and accumulate some history under Topic A.
  2. Fork A → B (B inherits A's title display and history).
  3. In B, /rename to a new title that reflects Topic B.
  4. Verify the rename sticks across several turns.
  5. Run /compact <args> in B with custom args that clearly redirect to Topic B (e.g. "from now on this session is debugging Topic B, nothing to do with Topic A").
  6. After compaction completes, send a Topic B prompt.
  7. Observe:
    • Title in /resume reverts to A's title (#29922).
    • The session's JSONL shows a <system-reminder> injected naming the (wrong) title as the session's focus, followed by a re-injection of the parent's original Topic A prompt.
    • The model proceeds to do Topic A work, ignoring the user's Topic B prompt.

Suggested investigation angles

  • Find the emitter of the "The user named this session '<title>'..." system-reminder. Have it either:
    • Read from an in-memory session-intent that prefers the most recent /rename or /compact <args> over the on-disk custom-title, or
    • Suppress the reminder for some number of turns immediately following a /compact <args> that contained a topic-redirect statement.
  • Audit fork-state restore. The verbatim re-injection of the parent's opening prompt on a forked session under /compact suggests the restore path is reading from the parent rather than from the fork's own initial state.

Workaround

There isn't a clean one. The user has to:

  1. Notice the agent has drifted (often expensive — wasted tool calls, sub-agents, and context tokens).
  2. Escape.
  3. Manually re-state the redirect in plain text and hope the next reminder injection doesn't pull from the same source.

Re-running /rename doesn't help if the next /compact will clobber it again.

Cross-reference

Same root data as #29922. Filed separately because the correctness implications of /compact <args> being silently overridden are larger than the label-reversion framing in that issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING