Skip to content

fix: handle array content, add model aliases, increase subprocess timeout#20

Open
Max-shipper wants to merge 1 commit intoatalovesyou:mainfrom
Max-shipper:fix/content-extraction-model-map-timeout
Open

fix: handle array content, add model aliases, increase subprocess timeout#20
Max-shipper wants to merge 1 commit intoatalovesyou:mainfrom
Max-shipper:fix/content-extraction-model-map-timeout

Conversation

@Max-shipper
Copy link

Summary

Three bug fixes addressing real failures observed in production use with claude-max-proxy.

Fix 1 — extractContentText() in src/adapter/openai-to-cli.ts

OpenAI-compatible providers (including Claude Code's own proxy routing) send content as an array of content blocks rather than a plain string:

[{"type": "text", "text": "Hello world"}]

Without handling this, messagesToPrompt() was interpolating the raw array into the prompt string, producing [object Object] and sending garbage to the CLI.

Changes:

  • Added extractContentText() helper that handles: string → passthrough, Array → filter type === "text" blocks and join with newline, null/undefined → empty string, anything else → String(content)
  • Widened the OpenAIChatMessage.content type in src/types/openai.ts to string | OpenAIContentBlock[] | null
  • Updated messagesToPrompt() to call extractContentText() for every message role

Fix 2 — MODEL_MAP additions in src/adapter/openai-to-cli.ts

The Claude 4-6 model generation IDs (claude-opus-4-6, claude-sonnet-4-6) were missing from MODEL_MAP. Any request specifying these IDs fell through to the default "opus", which worked for Opus but silently ignored Sonnet requests.

Added mappings:

"claude-opus-4-6"                    → "opus"
"claude-sonnet-4-6"                  → "claude-sonnet-4-6"
"claude-code-cli/claude-opus-4-6"    → "opus"
"claude-code-cli/claude-sonnet-4-6"  → "claude-sonnet-4-6"

Also extended ClaudeModel type to include "claude-sonnet-4-6" since the CLI accepts it as a full model ID (not just an alias).

Fix 3 — DEFAULT_TIMEOUT in src/subprocess/manager.ts

The 5-minute (300 000 ms) timeout was too short for agentic tasks that involve multiple tool calls — web searches, multi-step research, long code generation. These routinely run 8–12 minutes and were being killed mid-execution with a timeout error.

Increased to 15 minutes (900 000 ms) with an explanatory comment.

Test plan

  • Send a request with array content blocks; verify prompt is correctly extracted
  • Request with model: "claude-sonnet-4-6"; verify it routes to Sonnet, not Opus
  • Trigger a long agentic task (web search chain); verify it completes without timeout

🤖 Generated with Claude Code

…eout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
wende added a commit to wende/claude-max-api-proxy that referenced this pull request Feb 18, 2026
Triaged all 14 open PRs from atalovesyou/claude-max-api-proxy,
implemented the valuable fixes, and added end-to-end test coverage.

Changes:
- Fix normalizeModelName crash on undefined model (atalovesyou#7 regression)
- Pass prompt via stdin instead of CLI arg to avoid E2BIG (atalovesyou#12)
- Increase subprocess timeout from 5 to 15 minutes (atalovesyou#20)
- Add Claude 4.5/4.6 model IDs and claude-max/ prefix (atalovesyou#10, atalovesyou#20)
- Include usage data in final streaming SSE chunk (atalovesyou#16)
- Wrap subprocess logging with DEBUG_SUBPROCESS env check (atalovesyou#5, atalovesyou#16)
- Strip CLAUDECODE env var from subprocesses (own fix)
- Add e2e test suite (7 tests covering health, models, completions)
wende added a commit to wende/claude-max-api-proxy that referenced this pull request Feb 18, 2026
Triaged all 14 open PRs from atalovesyou/claude-max-api-proxy,
implemented the valuable fixes, and added end-to-end test coverage.

Changes:
- Fix normalizeModelName crash on undefined model (atalovesyou#7 regression)
- Pass prompt via stdin instead of CLI arg to avoid E2BIG (atalovesyou#12)
- Increase subprocess timeout from 5 to 15 minutes (atalovesyou#20)
- Add Claude 4.5/4.6 model IDs and claude-max/ prefix (atalovesyou#10, atalovesyou#20)
- Include usage data in final streaming SSE chunk (atalovesyou#16)
- Wrap subprocess logging with DEBUG_SUBPROCESS env check (atalovesyou#5, atalovesyou#16)
- Strip CLAUDECODE env var from subprocesses (own fix)
- Add e2e test suite (7 tests covering health, models, completions)

Co-Authored-By: kevinfealey <10552286+kevinfealey@users.noreply.github.com>
Co-Authored-By: Max <257223904+Max-shipper@users.noreply.github.com>
Co-Authored-By: James Hansen <1359077+jamshehan@users.noreply.github.com>
Co-Authored-By: bitking <213560776+smartchainark@users.noreply.github.com>
Co-Authored-By: Alex Rudloff's AI Agents <258647843+alexrudloffBot@users.noreply.github.com>
Grivn added a commit to mnemon-dev/claude-max-api-proxy that referenced this pull request Feb 20, 2026
Fixes applied (from upstream PRs atalovesyou#7, atalovesyou#11, atalovesyou#12, atalovesyou#13, atalovesyou#17, atalovesyou#20):

- fix: normalizeModelName crash on undefined model (issue atalovesyou#21)
- fix: [object Object] serialization for array content parts
- fix: E2BIG error by passing prompt via stdin instead of CLI arg
- fix: ensureString on result.result to prevent non-string output
- feat: CLAUDE_DANGEROUSLY_SKIP_PERMISSIONS env var for headless mode
- feat: OPENCLAW_PROXY=1 env injection for hook isolation
- feat: model aliases for claude-*-4-5, claude-*-4-6 generations
- feat: claude-proxy/ provider prefix support
- feat: developer role support in message conversion
- perf: increase subprocess timeout from 5min to 15min

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant