anomalyco / anomalyco/opencode

feat: inject session_id for OpenRouter session grouping

Open
#40,017 0 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 1, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Problem

OpenRouter supports session-level grouping via a session_id field in the request body. This allows upstream providers to attribute and group requests by session, which is useful for analytics, billing, and debugging across multi-turn conversations.

Currently, opencode does not pass session_id to OpenRouter requests, so all requests from the same conversation are ungrouped at the provider level.

Proposed solution

Inject session_id into the request extraBody when the model API provider is @openrouter/ai-sdk-provider. This leverages the existing extraBody mechanism in the AI SDK to pass the field through without requiring provider-specific request restructuring.

Scope

  • packages/opencode/src/provider/transform.ts — add extraBody.session_id for OpenRouter models
  • packages/opencode/test/provider/transform.test.ts — test coverage

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.