Skip to content

Windows: claude-code / claude_agent_sdk providers can't spawn the CLI — system prompt passed as argv exceeds the 32,767-char command-line limit (os error 206) #5044

Description

@edewveall-dev

Summary

On Windows, routing chat through either Claude CLI provider (claude-code:<model> or claude_agent_sdk) fails on every turn because the harness system prompt is passed as a single command-line argument. The resulting command line exceeds Windows' 32,767-character CreateProcess limit, so the spawn fails before the CLI ever runs.

Problem

Environment: Windows 11 Home build 26200, OpenHuman beta v0.61.8 (official installer, desktop), Claude Code CLI v2.1.156 at C:\Users\<user>\.local\bin\claude.exe (the CLI works fine when invoked directly from a shell, both interactive and claude -p).

Steps to reproduce:

  1. On Windows, install the Claude Code CLI and sign in.
  2. Set chat_provider = "claude-code:claude-sonnet-5" in config.toml (or connect the Claude Code provider in the LLM settings UI).
  3. Send any chat message.
  4. Every turn fails; the UI shows the generic "Something went wrong" toast.

Expected: the turn is routed through the local Claude Code CLI.

Actual: the daemon log shows the spawn failing with the underlying OS error:

WRN [journal] run failed error=model error: model error: openhuman provider chat failed: failed to spawn `claude`: The filename or extension is too long. (os error 206)

With chat_provider = "claude_agent_sdk" the same failure occurs, but the log drops the OS error (the anyhow source isn't printed, which made this much harder to diagnose):

WRN [journal] run failed error=model error: model error: openhuman provider chat failed: failed to spawn claude binary 'C:\Users\<user>\.local\bin\claude.exe'

os error 206 (ERROR_FILENAME_EXCED_RANGE) is what CreateProcess returns when the command line exceeds 32,767 UTF-16 characters.

Solution (suspected cause + proposed fix)

  • src/openhuman/inference/provider/claude_code/driver.rs builds argv with --append-system-prompt <system prompt> — the full tinyagents harness system prompt (log shows tools=78 on a plain chat turn) goes into one argv entry. Windows argv is a flat command-line string capped at 32,767 chars; macOS/Linux allow ~1–2 MB, which is why this only breaks on Windows.
  • src/openhuman/inference/provider/claude_agent_sdk/subprocess.rs passes the entire composed message via -p <full_message> argv — same wall.
  • Diagnostic confirmation: substituting the configured binary with C:\Windows\System32\cmd.exe fails identically, proving the args (not the binary) are the problem.

Proposed fix: deliver the system prompt out-of-band on Windows — the claude-code driver already streams messages over stdin as stream-json, so the system prompt could ride the same channel, or be written to a temp file referenced via the CLI's settings mechanisms — keeping argv short. Independent quick win: print the full error chain ({:#}) when spawn fails in claude_agent_sdk/subprocess.rs so the OS error isn't swallowed.

Acceptance criteria

  • Repro gone — a chat turn routed through claude-code:<model> completes on Windows 11 with a harness system prompt larger than 32 KB.
  • Regression safety — coverage for argv length on Windows spawn paths (or system prompt delivered via stdin/file on all platforms).
  • Spawn errors logged with sourcefailed to spawn log lines include the underlying io::Error / OS error code.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions