Skip to content

feat(plugin): add session request hook - #39764

Merged
rekram1-node merged 5 commits into
v2from
session-request-hook
Jul 31, 2026
Merged

feat(plugin): add session request hook#39764
rekram1-node merged 5 commits into
v2from
session-request-hook

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • expose session.request on the Effect and Promise plugin boundaries
  • allow plugins to mutate final outgoing native LLM URLs, HTTP headers, and serialized request bodies
  • invoke the hook after native request serialization and authentication
  • pass the callback as process-local LLMClient execution options rather than storing runtime behavior in the Schema-backed LLMRequest

Scope

  • URL, headers, and body are mutable; method is readonly
  • the hook currently applies only to native @opencode-ai/ai HTTP transports
  • AI SDK providers continue to use the existing aisdk.sdk and aisdk.language integration hooks
  • native WebSocket messages are not represented as HTTP requests by this hook

Validation

  • bun typecheck in packages/ai, packages/core, and packages/plugin
  • bun test test/compile.test.ts in packages/ai
  • bun test test/aisdk.test.ts test/plugin-hooks.test.ts in packages/core

@rekram1-node

Copy link
Copy Markdown
Collaborator Author

AI SDK support is intentionally deferred from this PR. An initial implementation used AsyncLocalStorage to bridge per-session callbacks into cached AI SDK providers, but we removed it to keep this hook explicit and native-only. We may revisit AI SDK final-request interception later with a dedicated design around its existing aisdk.sdk / aisdk.language hooks or request-bound provider factories.

@rekram1-node
rekram1-node merged commit 98229d4 into v2 Jul 31, 2026
6 of 7 checks passed
@rekram1-node
rekram1-node deleted the session-request-hook branch July 31, 2026 02:11
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