code-yeongyu / code-yeongyu/senpi

Builtin compaction omits x-opencode-session for opencode providers → 400 MissingSessionID

Open
#1,523 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
429
Forks
98
Avg merge
5h 3m
Merged PRs (30d)
526

Description

## Symptom

Any session running an opencode-backed model (for example, `opencode-go/muse-spark`) fails blocking compaction with:

```text
Compaction rejected: compaction generator failed: OpenAI API error (400) {"type":"MissingSessionID","message":"Error from provider (Console Go): Request is missing x-opencode-session ..."}
```

## Root cause

`generateSummaryMessage` in `src/core/extensions/builtin/compaction/speculative-summary.ts` streams via `modelRuntime`/`compat` using only `auth`/`transformHeaders` headers and never merges provider attribution headers, unlike the normal turn path (`sdk.ts` `transformHeaders` -> `mergeProviderAttributionHeaders`). Therefore no `x-opencode-session` reaches Console Go.

`createOpenAiRemoteCompactionHeaders` in `openai-remote-model.ts` also only forwards `sessionId` for `openai-codex-responses`.

## Evidence

A diagnostic run showed provider `opencode-go`, API `openai-responses`, base URL host `opencode.ai`, and a session ID present, but final headers without `x-opencode-session`. After merging attribution headers and directly setting the header, compaction succeeded: the header was present and the session compacted cleanly.

## Suggested fix direction

Merge `mergeProviderAttributionHeaders` into the compaction summary request headers (guard for `settingsManager` being unavailable in that context), or set `x-opencode-session` directly for opencode providers. Happy to submit a PR if maintainers agree on the direction.

## Environment

- omo-ai 5.0.0-0.beta.50 / senpi 2026.9.9
- Windows x64
- `opencode-go/muse-spark-1.3-contributor` session

Contributor guide

Open the contributing guide

Research direction

Start in src/core/extensions/builtin/compaction/speculative-summary.ts at generateSummaryMessage, then compare its request-header flow with sdk.ts and mergeProviderAttributionHeaders. Also inspect createOpenAiRemoteCompactionHeaders in openai-remote-model.ts; done means blocking compaction for an opencode provider sends x-opencode-session and no longer returns MissingSessionID.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.