Skip to content

[Bug]: /compact works from the CLI in 34s but stalls past 237s inside Claudian, and the result is never surfaced #1306

Open

Description

@ZhoukangChen

Before submitting

  • I searched existing issues and did not find the same problem.
  • I have read the relevant documentation (e.g., the README) but could not resolve this issue.

Problem

Summary

With the Claude provider routed to an Anthropic-compatible third-party endpoint, /compact does not work from inside Claudian — and more importantly, Claudian never tells the user whether compaction succeeded or failed.
I first hit this as: a 70-turn conversation became unusable, /compact appeared to do nothing, and I found one user turn that has a providerUserMessageId but no providerAssistantMessageId and no compact_boundary anywhere in the transcript.
Then I ran the identical operation outside Claudian, against the identical session file:
claude --resume -p "/compact"
It succeeded in 34.4 s and compacted the conversation from 95,294 → 3,242 tokens (trigger: "manual"). So the endpoint supports compaction and the CLI performs it correctly — the defect is on the plugin side.

Impact

  1. A ~7x latency gap between the SDK path and the CLI path for the same compaction on the same session: 237 s+ inside Claudian (I gave up) vs 34.4 s via CLI. I do not have plugin-side debug logs yet, so I am deliberately not guessing at the cause. Candidates I would want ruled out: a tool-permission round-trip during compaction, the plugin rebuilding the prompt differently from -p --resume, or compaction events being swallowed by the stream state machine.
  2. The outcome is never surfaced. Even the successful CLI run exits 0 with completely empty stdout, and the failure case leaves nothing in the transcript either. So if Claudian judges success from stdout or from a streamed assistant message, it cannot distinguish "compacted successfully" from "nothing happened". The user is left staring at an unchanged conversation with no error, no boundary and no status.
    transformClaudeMessage.ts:430 does handle compact_boundary, and StreamController.ts:282 does push a { type: 'context_compacted' } block — so the handling exists, but in the failing turn no boundary ever reached that code, and nothing told the user.

Related

Steps to reproduce

  1. Open Obsidian 1.13.7 with Claudian 2.2.6, provider Claude.
  2. Configure an Anthropic-compatible third-party endpoint via ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN in ~/.claude/settings.json, with a custom (non-claude-*) model name (e.g. deepseek-v4-flash[1m]) listed in Claudian's custom models.
  3. Make sure autoCompactEnabled is absent from ~/.claude/settings.json, and that <vault>/.claude/settings.json and <vault>/.claude/settings.local.json do not exist.
  4. Hold a long conversation (~70 turns, including tool calls whose results are 100–300 KB).
  5. Send /compact in the Claudian composer.
  6. Observe: no compaction boundary, no assistant turn, no error, no status message — the conversation is unchanged.
  7. Repeat the identical operation from a terminal against the same session:
    claude --resume -p "/compact"
  8. Observe: exit code 0 in 34.4 s, and the session JSONL does gain a compact_boundary with preTokens: 95294 → postTokens: 3242.
  9. Also open Obsidian DevTools (Ctrl+Shift+I) → Console during step 5 and note that no compact_boundary / context_compacted event is observed.

Expected behavior

  • Compaction triggered from Claudian should complete in the same ballpark as the CLI does for the same session (~34 s here), or at least visibly report that it is still running.
  • The outcome should always be surfaced: attempted / succeeded (preTokens → postTokens) / failed with a reason. A /compact turn that ends with no boundary and no assistant message must be reported as a failure or as "unsupported for this provider" — never silently return to idle.
  • The context meter's "approaching limit" hint should not recommend /compact when compaction is known to be unavailable for the current provider/model.

Actual behavior

  • /compact from Claudian produced no boundary, no assistant turn and no error; only providerUserMessageId was recorded for that turn, and no error record exists (no Request interrupted, no isApiErrorMessage).
  • The CLI compacts the very same session successfully in 34.4 s, which proves the endpoint and the CLI are both fine.
  • The only feedback the user gets is a tooltip telling them to run the command that appears to do nothing.

Environment

  • Claudian version: 2.2.6 (community plugin ID realclaudian)
  • Obsidian version: 1.13.7 (installer is 1.11.7; the app auto-updated, obsidian-1.13.7.asar is present)
  • Operating system: Windows 11, <FILL IN build, e.g. 24H2 (26100.xxxx)>
  • Provider: Claude, routed to an Anthropic-compatible third-party endpoint via ANTHROPIC_BASE_URL; model is a custom non-claude-* name, claude-code/Deepseek-V4-Flash[1m]
  • Provider CLI version: Claude Code 2.1.153 (bin/claude.exe)
  • Provider CLI installation method: npm global install (%APPDATA%\npm\node_modules\@anthropic-ai\claude-code)

Relevant Claudian settings: maxWarmAgentProcesses: 5, restoreTabsOnStartup: true, maxTabs: 3, loadUserSettings: true

Relevant Claude Code configuration — this is a key part of the report, nothing here enables auto-compaction:

  • ~/.claude/settings.json: no autoCompactEnabled field
  • <vault>/.claude/settings.json: does not exist
  • <vault>/.claude/settings.local.json: does not exist
  • <vault>/.claude/ contains only agents/, commands/, skills/

Logs and other evidence

1. The same command succeeds from the CLI

$ claude --resume <sessionId> -p "/compact"
# exit code 0, wall clock 34.4 s, stdout completely empty (0 bytes)
# session JSONL: 4370 → 4383 lines, 13.753 MB → 13.77 MB

The session file did gain a real compaction boundary:

{"type":"system","subtype":"compact_boundary","content":"Conversation compacted",
 "timestamp":"2026-09-10T14:48:51.945Z",
 "compactMetadata":{
   "trigger":"manual",
   "preTokens":95294,
   "durationMs":32624,
   "postTokens":3242,
   "preservedSegment":{ },
   "preservedMessages":{ }
 },
 "entrypoint":"sdk-cli",
 "cwd":"<vault path>"}

trigger: "manual" confirms it was the manual /compact; 95,294 → 3,242 tokens (96.6% reduction), 32.6 s of model time. The following line in the JSONL is the generated summary (11,320 bytes, type: user, beginning "This session is being continued from a previous conversation that ran out of context...").

2. The in-app /compact turn produced no assistant message

From .claudian/sessions/<conversationId>.inputs.json, counting occurrences:

  • "providerUserMessageId": 30
  • "providerAssistantMessageId": 29

The single turn missing an assistant id is the /compact turn:

{
  "id": "msg-1789049660577-lxp9b01",
  "userTurnOrdinal": 71,
  "state": "accepted",
  "localMessageId": "msg-1789049660129-99n6241",
  "timestamp": 1789049660129,
  "rawDisplayText": "/compact",
  "canonicalText": "/compact",
  "providerUserMessageId": "80c34d17-26d7-4c2d-aaf6-182bf10422b1"
}

Note "state": "accepted" and the presence of a providerUserMessageId: the request reached the provider, but no assistant turn was ever recorded and no compact_boundary was written. Timeline: /compact sent at 22:14:20, next user input at 22:18:17 — 237 s with no result.

A grep of the transcript for failure markers returns 0 hits for Request interrupted, i.e. the turn did not end by an explicit user interrupt.

3. The context meter is correct, so this is not #924

.claudian/sessions/<conversationId>.meta.json:

"usage": {
  "model": "Deepseek-V4-Flash[1m]",
  "inputTokens": 220,
  "cacheReadInputTokens": 93952,
  "contextWindow": 1000000,
  "contextTokens": 94172,
  "percentage": 9,
  "contextWindowIsAuthoritative": true
}

The 1M window is correctly detected (unlike #924), and the session sat at only ~9% of it — which is exactly why a working compaction path matters here: there is no client-side threshold in Claudian that would ever fire on its own, so the CLI's behaviour is the only thing that can compact.

4. The side effect that made the session unusable while investigating

Separately reported as #1303: restoring this conversation eagerly builds the bodies of all collapsed tool-result and diff cards. readSDKSessionFile() (src/providers/claude/history/sdkSessionPaths.ts:199) also reads the whole 13.75 MB / 4,370-line CLI JSONL and JSON.parses every line synchronously on the Obsidian renderer main thread, including 72 lines larger than 20 KB (largest 333 KB). Not the cause of the compaction bug, but the reason the conversation could not be used while investigating.

(Happy to attach the raw compact_boundary line and any debug logs on request — I have redacted the vault path and session id here.)

Additional context

Two defects, and which one I would like a maintainer's read on

I can only prove the symptom, not the mechanism, so I am flagging both:

  1. Latency gap between the SDK path and the CLI path (237 s+ vs 34 s for the same session and the same context size). To isolate this I would need plugin-side debug logging; my next step is to re-run /compact in Claudian with the DevTools Console open and check whether a compact_boundary / context_compacted event arrives at all.

  2. No compaction status is ever surfaced. This one holds regardless of which layer returns the empty result, and it is the part that made the failure invisible for a long time. Even the successful CLI run exits 0 with empty stdout, so any success check based on stdout or on a streamed assistant message is unreliable by construction.

Concrete asks, in priority order

  • Surface compaction state explicitly: attempted / succeeded with preTokens→postTokens / failed with a reason.
  • Add a visible "compacting…" state or watchdog, so a compaction that runs longer than the CLI's own 32 s is distinguishable from a hang.
  • Consider not depending solely on the inherited CLI autoCompactEnabled for custom/third-party endpoints. The maintainer already sketched this direction in Long conversations hit 400 because compactionControl is never enabled on the Claude Code SDK #598: "an explicit Claude setting with an 'inherit Claude Code' default, plus enable/disable and window override behavior for users on smaller endpoints." That is exactly the configuration where the nominal window and the endpoint's real ceiling diverge.

Not claiming

I am not claiming the endpoint is at fault — I have now proven it is not, since the CLI compacts this exact session successfully. I am also not claiming a specific internal cause for the ~7x gap.

Suggested diagnostic, if useful

Re-run /compact in Claudian with Ctrl+Shift+I → Console open, and log the raw SDK message stream around compact_boundary. That will separate "the event never arrives" from "the event arrives and the renderer drops it", which point at completely different fixes.

Activity

  1. added
    bug
    on Sep 10, 2026
  2. CaoYuhaoCarl commented on Dec 1, 2026

    @CaoYuhaoCarl
    Contributor

    On main at 6624b17, sending /compact shows Compacting..., and the chat shows Conversation compacted when Claude emits compact_boundary.
    I haven't reproduced the 237-second wait on the endpoint in this report.

    I checked one detail with Claude Code 2.1.300 in an empty session. /compact emitted an assistant message saying Error: No messages to compact, followed by result with subtype success, is_error: false, and empty result text. The terminal event alone therefore doesn't tell us whether compaction worked.

    Could you retest on the latest release and share the Claudian and Claude Code versions, whether Compacting... stays visible or clears, and whether the session transcript gains a compact_boundary around that time? Event names and timings are enough.

    If the chat returns to idle with neither a boundary nor a diagnostic on the current release, would a focused PR to show that Claudian could not confirm compaction be welcome? If it stays busy, the next step would be to trace where the turn stops progressing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions