Fix ClaudeOR: direct OpenRouter API call#14
Open
kaypeter87 wants to merge 3 commits into
Open
Conversation
claude --print returns empty responses when routed through OpenRouter's Anthropic-compatible endpoint. This replaces the CLI subprocess with a direct HTTP call to OpenRouter's /v1/chat/completions API using Python stdlib (urllib), which also unlocks non-Anthropic models. The approach is stateless (no session resume), so council R2 naturally falls back to exec mode with full context. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Background tasks (e.g. council_ask) return a task_id immediately while work continues in an asyncio task. That background task was calling ctx.info() per line of subprocess output, which tags every notification with the originating request_id via FastMCP's send_log_message. By then the tool call had already been responded to, so every notification referenced a stale request_id — combined with the flood from 3-5 parallel streaming agents, this caused clients to drop the stdio transport mid-deliberation. Route background notifications through a new send_mcp_log helper that calls session.send_log_message directly (no related_request_id), and drop the per-line notification in _read_stream_lines (output is still captured in task.output_lines). Refactor Council.notify to use the same helper, which also fixes its silent exception swallowing and missing asyncio.shield.
Claude Code's MCP client (and any spec-conformant client) drops the stdio transport on receipt of a progress notification carrying a progressToken it didn't opt into via the request's _meta.progressToken. Council.notify was hardcoding progress_token="owlex-council" and emitting a notifications/progress message on every milestone, so every council_ask call disconnected the server within milliseconds of the tool returning. Remove the send_progress_notification call and the progress parameter entirely; log messages (which don't require a token) already carry the same milestone info through send_mcp_log. If progress reporting is re-added later it must read the progressToken from the originating request's _meta instead of fabricating one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
claude --printreturns empty responses through OpenRouter's Anthropic-compatible endpoint, making ClaudeOR unusable in council deliberation/v1/chat/completionsAPI via a standalone Python script (claudeor_api.py, stdlib only — no new dependencies)Changes
owlex/agents/claudeor_api.py— standalone script that reads prompt from stdin, calls OpenRouter, prints response to stdoutowlex/agents/claudeor.py— runner now spawnspython3 claudeor_api.pyinstead ofclaude --print. Stateless (no session resume), so council R2 falls back to exec mode with full context automaticallyTest plan
claudeor_api.pytested standalone — returns correct response from OpenRoutercouncil_askwith ClaudeOR participating (requires MCP server restart)🤖 Generated with Claude Code