Parent
Part of #3000 and follows #4179.
Goal
Add structured /doctor memory output and session-scale counters so memory reports can distinguish V8 pressure from large conversation/tool-result retention.
Motivation
A single process/V8 snapshot is useful, but Qwen Code OOMs are often caused or amplified by agent-specific state: long chat history, large tool results, UI history, or compression-time duplication. /doctor memory should expose safe aggregate counters before asking users for heavier heap snapshots.
Proposed solution
- Add a structured output path for
/doctor memory, e.g. /doctor memory --json in non-interactive and interactive command paths.
- Extend diagnostics with safe aggregate session stats when available:
- conversation/history item count
- approximate total chars/tokens if an estimator is available
- largest tool result size and total tool result size, without content
- UI history item count, if accessible
- current model/context window metadata when safe
- Gracefully report
unavailable when the command context does not expose a counter.
- Keep all stats content-free: counts and sizes only.
Non-goals
- Do not serialize full conversation messages.
- Do not include tool result contents.
- Do not implement tool-result offload in this issue.
- Do not add heap snapshot generation here.
Acceptance criteria
/doctor memory --json returns valid JSON in non-interactive mode.
- Human-readable output includes a
Session scale or equivalent section when stats are available.
- Tests verify that session stats are aggregate-only and do not include message/tool content.
- The command still works in contexts without session/UI stats.
Parent
Part of #3000 and follows #4179.
Goal
Add structured
/doctor memoryoutput and session-scale counters so memory reports can distinguish V8 pressure from large conversation/tool-result retention.Motivation
A single process/V8 snapshot is useful, but Qwen Code OOMs are often caused or amplified by agent-specific state: long chat history, large tool results, UI history, or compression-time duplication.
/doctor memoryshould expose safe aggregate counters before asking users for heavier heap snapshots.Proposed solution
/doctor memory, e.g./doctor memory --jsonin non-interactive and interactive command paths.unavailablewhen the command context does not expose a counter.Non-goals
Acceptance criteria
/doctor memory --jsonreturns valid JSON in non-interactive mode.Session scaleor equivalent section when stats are available.