Skip to content

fix(claude-cli): await completion to fix empty analysis on ingest#308

Open
DrElchapo wants to merge 1 commit into
nashsu:mainfrom
DrElchapo:fix/claude-cli-await-completion
Open

fix(claude-cli): await completion to fix empty analysis on ingest#308
DrElchapo wants to merge 1 commit into
nashsu:mainfrom
DrElchapo:fix/claude-cli-await-completion

Conversation

@DrElchapo
Copy link
Copy Markdown

Problem

When using the Claude Code CLI provider, ingest always produces stub pages with "(Analysis not available)" even though the CLI works correctly in the terminal.

Root cause: streamClaudeCodeCli() resolves its Promise immediately after invoke(\"claude_cli_spawn\") returns — before the claude subprocess emits any tokens. The ingest pipeline checks the analysis buffer while the CLI is still running, finds it empty, and writes a stub.

Same race that was fixed for the Codex CLI transport in #238.

Fix

  • Add a completion Promise that resolves only inside finishWith(), then await completion after spawn — matching the pattern from the Codex CLI fix
  • Track emittedToken flag; surface a clear error when CLI exits 0 but produces no content, instead of silently writing a stub
  • Guard pre-aborted and abort-during-spawn races (same pattern as Codex CLI)

Test

Ingest with Claude Code CLI provider now reaches Step 2/2 and writes real wiki pages (entities, concepts, source summary) instead of stubs.

Fixes #292

streamClaudeCodeCli() was resolving its Promise immediately after
invoke('claude_cli_spawn') returned — before the claude subprocess
emitted any tokens. The ingest pipeline checked the analysis buffer
while the CLI was still running, found it empty, and wrote a stub
with '(Analysis not available)'.

Same race that was fixed for the Codex CLI transport in nashsu#238.

Fix:
- Add a completion Promise that resolves only inside finishWith(),
  then await completion after spawn
- Track emittedToken flag; surface a clear error when CLI exits 0
  but produces no content, instead of silently writing a stub
- Guard pre-aborted and abort-during-spawn races

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can not support open code cli (local)

2 participants