Skip to content

feat(plugin): add session request hook#37549

Open
rekram1-node wants to merge 3 commits into
v2from
port-plugins
Open

feat(plugin): add session request hook#37549
rekram1-node wants to merge 3 commits into
v2from
port-plugins

Conversation

@rekram1-node

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

Copy link
Copy Markdown
Collaborator

Summary

  • add Effect and Promise ctx.session.hook("request", ...) APIs for mutable model headers and JSON bodies
  • transform native HTTP and final WebSocket request payloads before authentication and signing
  • bridge cached AI SDK models with request-local transforms while preserving concurrent Session isolation
  • apply Session request hooks to normal steps, title generation, and automatic/manual compaction

Simplifications

  • share the AI request JSON type with the plugin contract instead of duplicating it
  • preserve the original WebSocket encoding path when no hook is registered
  • resolve only the effective agent for manual compaction instead of loading full instruction/plugin context
  • preserve upstream compaction cost tracking while carrying hook identity

Tests

  • cd packages/plugin && bun typecheck
  • cd packages/ai && bun typecheck && bun test (331 passed, 29 skipped)
  • cd packages/core && bun typecheck
  • focused Core suites (156 passed)
  • full Core suite (1338 passed, 6 skipped, 1 environment-only failure from user plugins in ~/.config/opencode/plugin)

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