Skip to content

feat(providers): add TokenRouter provider integration and tests (v1.2… - #19

Merged
Foshati merged 1 commit into
mainfrom
feat/tokenrouter-provider
Aug 7, 2026
Merged

feat(providers): add TokenRouter provider integration and tests (v1.2…#19
Foshati merged 1 commit into
mainfrom
feat/tokenrouter-provider

Conversation

@Foshati

@Foshati Foshati commented Aug 7, 2026

Copy link
Copy Markdown
Owner

….51)

Summary by CodeRabbit

  • New Features

    • Added TokenRouter as a supported model provider.
    • Added TokenRouter configuration options, including API key, proxy, and smoke-test model settings.
    • Added TokenRouter support to the administration interface.
    • Added support for reasoning controls, tool-enabled requests, and configurable output limits.
  • Documentation

    • Updated provider documentation with TokenRouter details and an example model.
  • Chores

    • Incremented the project version to 1.2.51.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

TokenRouter is added as an OpenAI-compatible provider. The change adds configuration, catalog registration, request-profile behavior, admin metadata, documentation, version 1.2.51, and automated tests.

Changes

TokenRouter integration

Layer / File(s) Summary
Provider registration and configuration
.env.example, src/codefa/config/..., src/codefa/api/admin_static/admin.js, README.md, pyproject.toml
TokenRouter receives API key and proxy settings, a default API base URL, provider catalog metadata, admin UI metadata, documented provider entries, and the version update.
OpenAI profile and provider validation
src/codefa/providers/openai_chat/profiles.py, tests/providers/..., tests/contracts/...
The TokenRouter profile maps reasoning effort, replays reasoning content, validates extra fields, and sets output-token defaults. Tests cover initialization, request conversion, reasoning disablement, runtime registration, and provider order.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Settings
  participant PROVIDER_CATALOG
  participant OpenAIChatProvider
  participant TokenRouterAPI
  Settings->>PROVIDER_CATALOG: Resolve tokenrouter settings and endpoint
  PROVIDER_CATALOG->>OpenAIChatProvider: Create configured provider
  OpenAIChatProvider->>OpenAIChatProvider: Apply tokenrouter profile and request mapping
  OpenAIChatProvider->>TokenRouterAPI: Send OpenAI-compatible request
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding TokenRouter provider integration and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tokenrouter-provider

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Foshati
Foshati merged commit 7b199de into main Aug 7, 2026
5 of 6 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/codefa/providers/openai_chat/profiles.py (1)

347-360: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Verify TokenRouter’s request and response contract.

This profile emits reasoning_effort values from _LOW_MEDIUM_HIGH, uses "none" to disable reasoning, applies ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS, and selects ReasoningReplayMode.REASONING_CONTENT. The supplied tests only inspect locally built request dictionaries. They do not prove that TokenRouter accepts these fields or returns the expected reasoning field for the selected model. Confirm the live contract and add a recorded request/response fixture if no existing coverage provides this guarantee. TokenRouter publicly describes the gateway as OpenAI-compatible, but that does not establish these provider-specific fields. (tokenrouter.com)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/codefa/providers/openai_chat/profiles.py` around lines 347 - 360, Verify
the TokenRouter contract for the profile’s reasoning_effort values, disabled
value, max-token default, and REASONING_CONTENT response mapping. Update the
"tokenrouter" OpenAIChatProfile only if the live API contract differs, and add a
recorded request/response fixture covering the selected model when existing
tests do not validate these fields end to end.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/codefa/providers/openai_chat/profiles.py`:
- Around line 347-360: Verify the TokenRouter contract for the profile’s
reasoning_effort values, disabled value, max-token default, and
REASONING_CONTENT response mapping. Update the "tokenrouter" OpenAIChatProfile
only if the live API contract differs, and add a recorded request/response
fixture covering the selected model when existing tests do not validate these
fields end to end.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a1f34ece-a391-4e19-8c69-3506758391e9

📥 Commits

Reviewing files that changed from the base of the PR and between 6848bc4 and 5ea0bd2.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .env.example
  • README.md
  • pyproject.toml
  • src/codefa/api/admin_static/admin.js
  • src/codefa/config/provider_catalog.py
  • src/codefa/config/settings.py
  • src/codefa/providers/openai_chat/profiles.py
  • tests/contracts/test_provider_catalog_order.py
  • tests/providers/test_provider_runtime.py
  • tests/providers/test_tokenrouter.py

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