Skip to content

feat: system prompt, streaming usage, stdin prompt & model updates#16

Open
smartchainark wants to merge 10 commits intoatalovesyou:mainfrom
smartchainark:main
Open

feat: system prompt, streaming usage, stdin prompt & model updates#16
smartchainark wants to merge 10 commits intoatalovesyou:mainfrom
smartchainark:main

Conversation

@smartchainark
Copy link

Summary

Consolidated improvements from our actively maintained fork. All changes are production-tested with OpenClaw.

Bug fixes

  • fix: include usage data in streaming SSE response — Final streaming chunk was missing usage (prompt_tokens, completion_tokens, total_tokens). Downstream consumers relying on token counts (e.g. session compaction) could not track consumption.
  • fix: handle undefined model in normalizeModelName — When rate limited, modelUsage can be {}, causing Object.keys({})[0] to return undefined and crash. (Credit: PR fix: handle undefined model in normalizeModelName to prevent crash on rate limits #7 by @wende)
  • fix: pass prompt via stdin to avoid E2BIG — Large prompts exceed OS argument size limit. stdin has no size limitation. (Credit: PR fix: pass prompt via stdin to avoid E2BIG error #12 by @kevinfealey)
  • fix: handle array content format — Support content as both string and array of content parts (OpenAI multi-part message format).

New features

  • feat: system prompt support — Extract system/developer messages and pass via --append-system-prompt flag instead of embedding in user prompt.
  • feat: Claude 4.5/4.6 model support — Add claude-opus-4-6, claude-sonnet-4-5, claude-max/* prefix, and opus-max/sonnet-max aliases. (Credit: PR feat: add support for Claude 4.5/4.6 models and claude-max prefix #10 by @jamshehan, model mapping portion)
  • feat: DEBUG_SUBPROCESS env var — Optional debug logging, replacing always-on console output.
  • feat: --dangerously-skip-permissions — For headless service mode.

Docs

  • Updated README with new models, OpenClaw config example, fork comparison table, restored original Cost Savings section.

Test plan

  • Streaming response includes usage data (curl test)
  • Non-streaming response works
  • System prompt correctly passed to Claude CLI
  • OpenClaw receives token counts and compaction works
  • stdin prompt delivery works (no E2BIG)
  • New model IDs resolve correctly

🤖 Generated with Claude Code

grassX1998 and others added 10 commits February 1, 2026 11:30
The OpenAI Chat Completions API allows message content to be either a
plain string or an array of content parts (e.g.
[{type: "text", text: "..."}]). When an upstream client sends array
content, the previous code passed it directly to template literals,
resulting in "[object Object]" being sent to Claude CLI.

Add extractContent() helper that normalises both string and array
formats into a single string, and update the OpenAIChatMessage type to
reflect the actual API spec.
Adds support for passing system messages to Claude Code CLI via the
--append-system-prompt flag. This enables OpenClaw agents to properly
send their identity, backstory, and instructions through the proxy.

Changes:
- Support both "system" and "developer" message roles (OpenAI spec)
- Extract system messages separately from conversation messages
- Pass system prompt via --append-system-prompt CLI flag
- Add optional tools parameter for future tool restriction support

This fixes the issue where OpenClaw system messages (containing agent
identity and configuration) were being ignored, causing Claude to
respond with its default identity instead of the configured persona.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add console.error logging for system prompt tracking
- Add --dangerously-skip-permissions flag for service operations
- Log assistant messages and results for debugging

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Replace all console.error calls with conditional debug() method
- Debug logging disabled by default, enabled via DEBUG_SUBPROCESS=true
- Add documentation in README troubleshooting section
- Keeps production logs clean while allowing detailed debugging when needed

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Without usage data in the final streaming chunk, downstream consumers
(e.g. OpenClaw compaction) cannot track token consumption, causing
sessions to grow unbounded and eventually hit context overflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When Claude CLI returns a rate limit response, modelUsage can be an
empty object causing Object.keys({})[0] to return undefined, which
crashes normalizeModelName.

Credit: PR atalovesyou#7 by @wende

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Large prompts (conversation history + system prompt) can exceed the OS
argument size limit, causing spawn() to fail with E2BIG. Passing via
stdin has no size limitation.

Credit: PR atalovesyou#12 by @kevinfealey

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add model mappings for claude-opus-4-6, claude-sonnet-4-5, and
claude-max/* provider prefix used by OpenClaw. Also add opus-max
and sonnet-max aliases.

Credit: PR atalovesyou#10 by @jamshehan (model mapping portion)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rebrand as actively maintained fork of atalovesyou/claude-max-api-proxy
- Document new models (Opus 4.6, Sonnet 4.5) and model aliases
- Add "What's Different" comparison table
- Add OpenClaw, Continue.dev, and Python client configuration examples
- Add LaunchAgent setup instructions
- Update architecture notes for stdin-based prompt delivery
- Credit community PR contributors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep original README content intact, only add fork-specific changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bwiedmann added a commit to bwiedmann/claude-max-api-proxy that referenced this pull request Feb 15, 2026
…e, stdin prompt & model updates

# Conflicts:
#	README.md
#	src/adapter/openai-to-cli.ts
#	src/subprocess/manager.ts
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>
chrisle added a commit to chrisle/claude-max-api-proxy that referenced this pull request Feb 27, 2026
Users can now send large prompts without E2BIG errors, use array-based
content format for multimodal support, properly handle system prompts,
and receive token usage data in streaming responses. Model names with
any provider prefix are now correctly normalized.

Changes:
- Fix array content serialization preventing [object Object] bugs
- Pass prompts via stdin to prevent E2BIG errors with large requests
- Add proper system prompt support via --append-system-prompt flag
- Include usage data in final streaming chunks
- Support any provider prefix in model names (claude-max/, etc.)
- Add CLAUDE_DANGEROUSLY_SKIP_PERMISSIONS env var for service mode
- Update to Claude 4.5/4.6 model support

Incorporates improvements from PRs atalovesyou#12, atalovesyou#13, atalovesyou#16, atalovesyou#24, atalovesyou#27 at
https://github.com/atalovesyou/claude-max-api-proxy
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.

3 participants