Skip to content

Fix: inference-parser misses /chat/completions from /v1-less proxies (opencode, litellm) - #823

Open
msteinder wants to merge 1 commit into
mainfrom
fix/inference-parser-vless-paths
Open

Fix: inference-parser misses /chat/completions from /v1-less proxies (opencode, litellm)#823
msteinder wants to merge 1 commit into
mainfrom
fix/inference-parser-vless-paths

Conversation

@msteinder

@msteinder msteinder commented Aug 30, 2026

Copy link
Copy Markdown
Member

Why

OpenAI-compatible proxies such as litellm (used by opencode) post to /chat/completions without the /v1 prefix. The OnRequest dispatch switch in inference-parser only matched /v1/chat/completions and /v1/completions, so these requests fell through to the default: return Continue arm — pctx.Extensions.Inference was never populated and abctl showed for model, method, and token counts on every opencode request.

Observed before the fix:

9    14:13:56.91   out   │┌ req   —    —                    ete-litellm.ai-mode…
9    14:13:59.27   out   │└ resp  —    —    200  2.36s       ete-litellm.ai-mode…

What changed

authbridge/authlib/plugins/inferenceparser/plugin.go

  • Extended the OnRequest switch case to also match /chat/completions and /completions.

authbridge/authlib/plugins/inferenceparser/plugin_test.go

  • Added TestInferenceParser_VlessPath_ChatCompletions and TestInferenceParser_VlessPath_Completions.

No changes to OnResponse or OnResponseFrame — the default branch there already routes to the OpenAI parsers, which is correct.

Testing

$ cd authbridge/authlib && go test ./plugins/inferenceparser/...
ok  github.com/rossoctl/cortex/authbridge/authlib/plugins/inferenceparser

Verified end-to-end: opencode requests through authbridge-proxy --demo now show model, token counts, and method in abctl.

Related issue(s)

Fixes #822

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Summary by CodeRabbit

  • Bug Fixes
    • Added support for OpenAI-compatible /chat/completions and /completions endpoints without the /v1 prefix.
    • Requests through compatible proxies are now correctly parsed, including model details and action tracking.

OpenAI-compatible proxies (e.g. litellm used by opencode) post to
/chat/completions without the /v1 prefix. The OnRequest dispatch switch
only matched /v1/chat/completions and /v1/completions, so requests fell
through to the default arm and pctx.Extensions.Inference was never
populated — resulting in missing model, token counts, and method fields
in abctl session views.

Extend the switch to also match /chat/completions and /completions.
No changes to OnResponse or OnResponseFrame — the default branch there
already routes to the OpenAI parsers.

Add two tests: TestInferenceParser_VlessPath_ChatCompletions and
TestInferenceParser_VlessPath_Completions.

Fixes #822

Signed-off-by: steinder <steinder@us.ibm.com>
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 430ff944-b13b-46c3-b1e0-c94f6351ec9a

📥 Commits

Reviewing files that changed from the base of the PR and between cb8bceb and 4bcb677.

📒 Files selected for processing (2)
  • authbridge/authlib/plugins/inferenceparser/plugin.go
  • authbridge/authlib/plugins/inferenceparser/plugin_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The inference parser now handles OpenAI-compatible /chat/completions and /completions paths without the /v1 prefix. Tests verify inference metadata, model extraction, and parser continuation.

Changes

OpenAI endpoint support

Layer / File(s) Summary
Unversioned endpoint dispatch and validation
authbridge/authlib/plugins/inferenceparser/plugin.go, authbridge/authlib/plugins/inferenceparser/plugin_test.go
The request parser accepts unversioned chat and completion paths. Tests verify parsed models, inference extensions, action state, and Continue results.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 4bcb6

The change enables metadata extraction for two additional compatible completion paths using the existing parsing behavior, with no change to authorization, routing, or request handling. No actionable merge-blocking risk remains.

Suggested reviewers: huang195, ibrahim2595

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the inference-parser fix for /v1-less OpenAI-compatible proxy paths. It is concise and directly related to the primary change.
Linked Issues check ✅ Passed The changes satisfy issue #822 by adding /chat/completions and /completions to OnRequest path matching. The added tests verify inference parsing for both paths, including model capture and action stat…
Out of Scope Changes check ✅ Passed All code and test changes directly support issue #822. No unrelated or out-of-scope changes are present.
Full details: Linked Issues check

Explanation

The changes satisfy issue #822 by adding /chat/completions and /completions to OnRequest path matching. The added tests verify inference parsing for both paths, including model capture and action status.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/inference-parser-vless-paths

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New/ToDo

Development

Successfully merging this pull request may close these issues.

Fix: inference-parser misses /chat/completions requests from OpenAI-compatible proxies (opencode, litellm)

2 participants