Repository navigation
feat(plugin): add session title hook and request options bag - #47663
Merged
Merged
Conversation
rekram1-node
force-pushed
the
session-hooks-2
branch
from
September 9, 2026 05:31
1c27331 to
8068de2
Compare
Session request hooks share a base shape: sessionID, model, system, messages, and an options bag. The bag replaces the separate generation and providerOptions fields; typed keys are the protocol-neutral generation settings and any other key is passed to the protocol as a provider option. Core partitions them when it builds the request. Title generation gets its own hook. It is not an agent conversation, so the event carries no agent or tools. Setting result on the event skips the model request and uses that title. SessionModelRequest exposes one entry per session flow: primary, compaction, generate, and title. Each runs the hook that shapes its flow and sets the request kind, so callers no longer pass kind, contextHooks, or contextAgentID. Compaction requests report the session agent on every hook; kind distinguishes them since #47214, so the fake compaction agent had no consumers left.
rekram1-node
force-pushed
the
session-hooks-2
branch
from
September 9, 2026 15:54
8068de2 to
1631f66
Compare
A registered http.request or http.response hook no longer forces the request onto HTTP. WebSocket requests skip the hooks; the HTTP fallback the channel keeps still runs them.
This reverts commit 79f21ba.
This was referenced Sep 22, 2026
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First step of splitting session request hooks by request type (per discussion with dax: one hook per kind of LLM request, same shape). Follows #47214 / #47221.
Shared request shape
optionsreplacesgeneration+providerOptions. Typed keys (maxTokens,temperature, …) are the protocol-neutral generation settings; any other key (reasoningEffort,serviceTier, …) is passed to the protocol as a provider option. Core partitions byGenerationOptions.fieldswhen building theLLMRequest; the ai package is unchanged.New
session.titlehook. Title generation is not an agent conversation, so the event carries noagentortools. A configuredtitleagent still supplies the default system prompt and model as before — the hook just doesn't surface it as an agent.SessionModelRequesthas one entry per flow.primary,compaction,generate,title. Each entry runs the hook that shapes its flow and sets the request kind; callers no longer passkind,contextHooks, orcontextAgentID, and the input is flat. The compaction entry owns the identity split (context hook sees the session agent, request hooks seecompaction) until it gets its own hook. Single-use helpers inmodel-request.tsare inlined into the shared lowering step.modelstays read-only for now; mutable model needs a two-stage transcript render and will be its own PR.Unchanged:
contextstill fires for compaction andSession.generatein this PR; their own hooks come next, at which point the built-in system-prompt plugin registers oncompactiontoo for cache-prefix reuse.kindonmodel.request/http.*/retryis unchanged.Tests
titlehook fires (system/messages/options mutable, options split intogeneration+providerOptionson the request),contextdoes not.core,server,sdkupdated tooptions/ the new entries.Typecheck clean in
plugin,core,server,sdk.