Skip to content

feat!: replace OpenRouter with OpenAI Responses - #217

Merged
QueryPlanner merged 1 commit into
mainfrom
claude/blacki-reasoning-traces-turns-fc7f1d
Nov 13, 2026
Merged

QueryPlanner merged 1 commit into
mainfrom
claude/blacki-reasoning-traces-turns-fc7f1d

Conversation

@QueryPlanner

Copy link
Copy Markdown
Owner

What

Blacki now calls OpenAI's Responses API directly, through its own ADK adapter, and OpenRouter is removed. Each model output item (reasoning, message, function call) is stored on its ADK part and sent back unchanged to the same model. Encrypted reasoning therefore carries across tool calls and survives restarts. Every request sets store: false.

Why

  • Reasoning was lost between tool calls. The OpenRouter adapter sent back only the reasoning summary text and dropped the encrypted reasoning, so the model restarted its reasoning after every tool call.
  • GPT-6 tool calling relied on undocumented behaviour. OpenAI documents it only on the Responses API, and through OpenRouter's Chat Completions it worked only via conversion OpenRouter doesn't document.
  • ADK's own adapter doesn't fix it. OpenAIResponsesLlm drops reasoning on replay (OpenAIResponsesLlm drops reasoning items between tool calls (never replayed or chained) google/adk-python#8110) and would need an ADK upgrade from 2.5.0.

The plan is in openspec/changes/replace-openrouter-with-openai-responses/. A subagent reviewed it before implementation, and its findings are included.

How

  • New adapter: models/openai_responses.py, with openai_request.py and openai_response.py for translation and openai_items.py for the stored-item contract. It handles streaming and non-streaming calls.
  • Replay goes only to the exact requested model id, and drops orphaned reasoning items.
  • Rejected reasoning: if OpenAI rejects replayed reasoning, the call is retried once without it, and replay stops for that session. The session is identified by an HMAC label set by the override plugin, which is never sent to OpenAI.
  • Model catalog: models/catalog.py lists gpt-6-luna, gpt-6.1-terra, gpt-6.1-sol and gpt-6-astra, with prices read from OpenAI's model pages. /model and /thinking use it, and legacy openrouter/openai/<id> values are still accepted.
  • Costs: the ledger records estimates from catalog prices (cost_kind=estimate, cost_source=catalog_price).
  • Compaction: a new summarizer stores only text, runs at the lowest effort, and has its cost recorded.
  • Privacy:
    • commentary-phase text is kept out of replies;
    • encrypted reasoning is redacted from debug logs;
    • ADK's legacy full-content span capture is forced off;
    • OpenAI metadata is stripped before any request to native Gemini.
  • Removed: the OpenRouter modules, tests, settings, systemd and workflow secret wiring. Docs and the changelog are updated.

Tests

  • uv run ruff format: 270 files left unchanged
  • uv run ruff check: all checks passed
  • uv run mypy .: no issues in 270 source files
  • uv run pytest --cov=src: 2887 passed, 1 skipped, 100.00% coverage
  • uv run --group docs mkdocs build --strict: built with no warnings
  • actionlint on docker-publish.yml
  • openspec validate --strict on the change
  • ADK 2.5.0 behaviour is pinned with real ADK code: kept event parts, part_metadata persistence in SQLite, and adk- id clearing
  • Live smoke test against OpenAI with gpt-6.1-terra at effort high, through the real factory, streaming and DatabaseSessionService. Each request after the first replayed the earlier reasoning items before their function calls, including after a simulated restart. Answers were correct, and there was one estimated ledger row per call (5 calls).
  • Rollback check: the pre-change OpenRouter request builder reads sessions written by the new adapter, and no new metadata leaks into its requests.

Breaking Changes

  • OPENAI_API_KEY replaces OPENROUTER_API_KEY.
  • ROOT_AGENT_MODEL takes a catalog id. openrouter/openai/<id> is still accepted; any other openrouter/... value fails at startup.
  • The publish workflow needs a new OPENAI_API_KEY GitHub Actions secret before deploying.
  • Without zero data retention approved for the OpenAI organization, OpenAI keeps abuse-monitoring logs for up to 30 days.

Related Issues

🤖 Generated with Claude Code

- Add an ADK model adapter over OpenAI's Responses API
- Store raw output items on ADK parts and replay them unchanged
- Always send store=false; keep encrypted reasoning in sessions
- Retry once without reasoning when OpenAI rejects it
- Add a static GPT-6 catalog for /model, /thinking and pricing
- Record estimated costs from catalog prices in the ledger
- Use a text-only compaction summarizer at low effort
- Keep commentary out of replies and secrets out of logs
- Remove the OpenRouter adapter, settings and deploy secret
- Add the OpenSpec change with specs, design and tasks

BREAKING CHANGE: OPENAI_API_KEY replaces OPENROUTER_API_KEY and
ROOT_AGENT_MODEL takes OpenAI model ids such as gpt-6.1-terra.
Legacy openrouter/openai/<id> values are still accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QueryPlanner
QueryPlanner merged commit 4b1bea3 into main Nov 13, 2026
3 checks passed
@QueryPlanner
QueryPlanner deleted the claude/blacki-reasoning-traces-turns-fc7f1d branch November 13, 2026 05:48
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