Repository navigation
feat(core): tag session http hooks with request kind - #47214
Merged
Merged
Conversation
Session http.request and http.response hooks now carry a `kind` field
("session" | "compaction" | "title" | "generate") identifying which
flow issued the request. Plugins previously had to infer purpose from
the agent ID, which could not distinguish generate from the loop and
coupled hooks to hidden agent names.
The GitHub Copilot plugin switches its X-Interaction-Type classification
to the new field.
rekram1-node
force-pushed
the
session-hooks
branch
from
September 4, 2026 04:38
3524fda to
3c14385
Compare
This was referenced Sep 4, 2026
rekram1-node
added a commit
that referenced
this pull request
Sep 7, 2026
Compaction runs with the session agent; request hooks distinguish it by kind since #47214, so the fake agent had no consumers left.
rekram1-node
added a commit
that referenced
this pull request
Sep 9, 2026
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
added a commit
that referenced
this pull request
Sep 9, 2026
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.
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
Adds a
kindfield to thesession.http.requestandsession.http.responseplugin hooks identifying which Session flow issued the request:"session"— agent loop step (runner/llm.ts)"compaction"— checkpoint summary (compaction.ts)"title"— title generation (title.ts)"generate"— transientSession.generate(generate.ts)Previously plugins inferred purpose from
event.agent(e.g.agent === "title"), which coupled them to hidden agent IDs and could not distinguishSession.generatefrom the loop at all.kindis a required field onPrepareInput, so every caller ofSessionModelRequest.preparemust declare its flow.The GitHub Copilot plugin switches its
X-Interaction-Typeclassification tokind.Naming follows Codex's per-request
request_kind(turn | prewarm | compaction | memory), which is the closest analogue: per-request, delivered to hooks, distinct from thread-levelsource/ownership.Scope
Deliberately limited to the HTTP hooks.
context,model.request, andretryare unchanged; a follow-up will introduce asession.requesthook for model/variant/sampling mutation and foldmodel.requestinto it.Tests
session-model-request-hooks.test.tsdrivespreparefor all four kinds and asserts both HTTP hooks observe the correctkind.kind, not agent, and thatgeneratestays unclassified.