Skip to content

test: model OpenCode's real base headers in the plugin harness - #852

Merged
rynfar merged 1 commit into
mainfrom
test/plugin-headers-model-real-base
Aug 31, 2026
Merged

test: model OpenCode's real base headers in the plugin harness#852
rynfar merged 1 commit into
mainfrom
test/plugin-headers-model-real-base

Conversation

@rynfar

@rynfar rynfar commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Problem

The V1 plugin harness returned only the plugin's chat.headers accumulator. OpenCode 1.18.11 builds the actual request in three stages:

  1. native headers, including x-session-affinity and X-Session-Id;
  2. model.headers;
  3. plugin output, spread last.

Testing only stage 3 can make an identity change look effective when OpenCode's native affinity header still keeps the request keyed. PR #845 was the concrete example.

Changes

  • Invoke the V1 hook with its real empty output object.
  • Compose native, model, and plugin headers in actual wire order.
  • Keep the non-Anthropic plugin-output assertion exact while proving native headers remain.
  • Resolve final V1 headers through a real Hono request and pin the exact keys for build, title, summary, and compaction.
  • Use the same real proxy boundary for existing V2 header rewrites:
    • title and summary resolve to no adapter key;
    • primary and compaction requests retain the base key;
    • ordinary subagents receive #agent scope.
  • Remove the V2 fake-context Reflect.apply workaround.
  • Add no production code and no forbidden casts or suppression directives.

Validation

Exact head: 38d7e6702a3903b971d20515a6e60c4a6255eef7

  • npm test: 3,122 passed, 1 skipped, 0 failed
  • focused V1/V2/session-key tests: 59 passed, 0 failed
  • npm run typecheck
  • npm run build
  • npm pack --dry-run --json
  • git diff --check origin/main...HEAD
  • added-line audit: no as any, as unknown as, @ts-ignore, or @ts-expect-error

Two independent read-only reviews found no remaining blocker after the exact merge-stage and proxy-boundary repairs.

The V1 plugin harness previously returned only the plugin's header
contribution. OpenCode 1.18.11 also supplies x-session-affinity and
X-Session-Id, then applies model headers and plugin headers, so the old harness
could make a no-op identity change appear effective.

Invoke the V1 hook with its real empty output object, compose native, model, and
plugin headers in wire order, and assert the exact session keys Meridian
derives through real Hono requests. Keep the non-Anthropic plugin output
assertion strong while proving that OpenCode's native headers remain.

Use the same real proxy boundary for V2's existing realistic header rewrites.
Pin detached title and summary requests to no adapter key, primary and
compaction requests to the base key, and subagents to scoped keys.
@rynfar
rynfar force-pushed the test/plugin-headers-model-real-base branch from 41064cf to 38d7e67 Compare August 31, 2026 01:01
@rynfar
rynfar merged commit 58e3b78 into main Aug 31, 2026
9 of 10 checks passed
@rynfar
rynfar deleted the test/plugin-headers-model-real-base branch August 31, 2026 03:39
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