Skip to content

feat(http): X-Session-Id fallback + drop workspace suffix#72

Merged
manojp99 merged 1 commit into
mainfrom
feat/x-session-id-fallback
Jun 23, 2026
Merged

feat(http): X-Session-Id fallback + drop workspace suffix#72
manojp99 merged 1 commit into
mainfrom
feat/x-session-id-fallback

Conversation

@manojp99

Copy link
Copy Markdown
Collaborator

Summary

Changed

  • X-Session-Id header is now recognized as a fallback for the existing X-Client-Session-Id correlation mechanism (PR feat(http): session resume via X-Client-Session-Id; client-authoritative reconciliation #71). opencode and other Vercel AI SDK-based clients send X-Session-Id by default; amplifier-agent now picks it up automatically, so session-resume + client-authoritative reconciliation works for opencode with zero config. X-Client-Session-Id remains authoritative when both headers are present.

  • Workspace name is no longer suffixed with the client session id. Previously, X-Client-Session-Id: abc would route requests into workspaces/<base>-abc/. Now the workspace stays at <base> and per-client distinction is purely at the session_id level (workspaces/<base>/sessions/http-abc/). This keeps workspace-level hook state (context-intelligence, etc.) shared across all sessions of the same server process, where it belongs.

How we discovered this

Live traffic inspection of opencode 1.17.9 → amplifier-agent confirmed the following incoming headers:

x-session-affinity: ses_10dba803effekTqUujLAFyL9me   ← opencode's session id
x-session-id:       ses_10dba803effekTqUujLAFyL9me   ← opencode's session id (Vercel AI SDK)

opencode sends X-Session-Id (and X-Session-Affinity with the same value) automatically via the Vercel AI SDK's provider-utils. It does not send X-Client-Session-Id (our convention from PR #71), does not populate the OpenAI user field, and there's no plugin hook in opencode to mutate request headers.

A three-line server-side change reading X-Session-Id as a fallback unlocks the entire session-resume + client-reconciliation chain from PR #71 for every opencode user with zero config.

The workspace-suffix change is a follow-on cleanup: each opencode session creates its own sessions/http-<sid>/ directory, which is sufficient per-session distinction. Putting the sid in the workspace name was fragmenting workspace-level hook state (context-intelligence, hooks config) per opencode session — not what we want.

Changes

  • Reverted temporary DEBUG INCOMING instrumentation block from chat_completions.py
  • chat_completions.py: fallback header read + simplified workspace logic (no suffix)
  • test_reconciler.py: updated workspace slug assertion from test-ws-{sid}test-ws
  • test_session_id_fallback.py (new): 4 tests covering X-Session-Id-only, precedence, no-header fallback, and workspace-not-suffixed scenarios
  • CHANGELOG.md: documented both changes under [Unreleased] ### Changed

Test evidence

tests/http/test_reconciler.py::* — 8/8 passed
tests/http/test_session_id_fallback.py::* — 4/4 passed
tests/config/ + tests/http/ + tests/cli/ — 312 passed (1 pre-existing failure in test_provider_sources unrelated to this PR)

Hard constraints honored

  • X-Client-Session-Id clients continue to work identically — header takes precedence when both are set
  • Wire protocol unchanged — request, response, headers, body are all unmodified
  • CLI face untouched (single_turn.py, _runtime.py)

opencode sends X-Session-Id by default via Vercel AI SDK -- recognize
it as a fallback for X-Client-Session-Id so PR #71's session-resume
chain works for opencode with zero config.

Also drop the workspace-suffix mechanism. Per-client distinction is at
the session_id level; workspace stays at server-process scope so hook
state (context-intelligence) shares cleanly across client sessions.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@manojp99 manojp99 merged commit 81895ed into main Jun 23, 2026
2 of 3 checks passed
manojp99 added a commit that referenced this pull request Jun 23, 2026
Cuts v0.9.0 release with chat-completions session resume, client-authoritative
reconciliation, and zero-config opencode session continuity via X-Session-Id header.

See CHANGELOG.md [0.9.0] for details: PR #71, #72, #73.

Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-authored-by: Manoj Prabhakar Paidiparthy <mpaidiparthy@microsoft.com>
Co-authored-by: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
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