paperclipai/paperclip · warning · Error

Could not parse Claude CLI usage output.

Error message

Could not parse Claude CLI usage output.

What it means

Thrown by parseClaudeCliUsageText when the parsed usage sections do not include one whose normalized label equals 'currentsession'. The parser splits the captured Claude CLI /usage output into labeled sections; the 'current session' window is mandatory, so its absence means the output did not contain the expected usage panel and cannot be reported as valid quota data.

Source

Thrown at packages/adapters/claude-local/src/server/quota.ts:422

      continue;
    }
    if (current) current.lines.push(line);
  }
  if (current) sections.push(current);

  const windows = sections.map<QuotaWindow>((section) => {
    const usedPercent = section.lines.map(percentFromLine).find((value) => value != null) ?? null;
    return {
      label: section.label,
      usedPercent,
      resetsAt: null,
      valueLabel: null,
      detail: formatClaudeCliDetail(section.label, section.lines),
    };
  });

  if (!windows.some((window) => normalizeForLabelSearch(window.label) === "currentsession")) {
    throw new Error("Could not parse Claude CLI usage output.");
  }
  return windows;
}

function quoteForShell(value: string): string {
  return `'${value.replace(/'/g, `'\\''`)}'`;
}

function buildClaudeCliShellProbeCommand(): string {
  const feed = "(sleep 2; printf '/usage\\r'; sleep 6; printf '\\033'; sleep 1; printf '\\003')";
  const claudeCommand = "claude --tools \"\"";
  if (process.platform === "darwin") {
    return `${feed} | script -q /dev/null ${claudeCommand}`;
  }
  return `${feed} | script -q -e -f -c ${quoteForShell(claudeCommand)} /dev/null`;
}

export async function captureClaudeCliUsageText(timeoutMs = 12_000): Promise<string> {

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Upgrade or pin a Claude CLI version known to render the 'current session' usage label; check `claude --version`.
  2. Capture raw output with --raw-cli (quota-probe) and inspect the actual label text to see what changed.
  3. Run `claude` interactively and issue /usage to confirm the panel renders as expected on this host.
  4. If the label legitimately changed, the parser's canonicalQuotaLabel mapping needs updating upstream.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const windows = parseClaudeCliUsageText(rawText);
} catch (err) {
  if (err.message === "Could not parse Claude CLI usage output.") {
    // log rawText for diagnosis, fall back to OAuth quota, do not crash the run
  }
  throw err;
}

Prevention

When it happens

Trigger: captureClaudeCliUsageText returned output that usageOutputLooksComplete accepted (it passed the loose completeness check), but the section parser found no 'current session' label. Happens when the CLI rendered a partial or differently-formatted usage panel, or when label text changed in a new Claude CLI version.

Common situations: A Claude CLI version that renamed/restructured the usage panel labels; ANSI/terminal cleanup stripping label text; output from a non-interactive locale that changes 'current session' wording; a partial render that fooled usageOutputLooksComplete.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/28c99a3becae40f2. Report an issue: GitHub.