feat(plugin): add session title hook and request options bag - #47663
Open
rekram1-node wants to merge 7 commits into
Open
feat(plugin): add session title hook and request options bag#47663rekram1-node wants to merge 7 commits into
rekram1-node wants to merge 7 commits into
Conversation
Session request hooks now 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, and it no longer opts out of context hooks through a flag: prepare dispatches on the request kind.
Callers no longer tell prepare which hook to run. SessionModelRequest exposes primary, compaction, generate, and title; each runs the hook that shapes its flow and the request kind follows from the entry. The contextHooks flag, contextAgentID, and kind parameter are gone from the input, which is flat now. Single-use helpers are inlined into the shared lowering step.
Compaction runs with the session agent; request hooks distinguish it by kind since #47214, so the fake agent had no consumers left.
Setting result on the session.title event skips the model request.
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.