You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Plugin hook to intercept and override LLM call parameters (llm.request.before) #45764
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Currently, plugins can hook into tool execution, shell environment, session compaction, and various UI/file events — but there is no way to intercept the parameters sent to the LLM before the request is made.
Use case: Automatic model routing based on message content. For example, routing build tasks, log analysis, or scan requests to a specific model (e.g. a faster/cheaper/specialized one), while using the default model for everything else — without the user having to manually switch models.
Requested hook:
"llm.request.before": async (input, output) => {
// input.params.messages — read-only view of the messages array
// input.params.model — currently selected model
// output.params.model — override the model
// output.params.messages — optionally mutate messages
}
Why this can't be done today:
chat.params (or equivalent) is not a supported hook — output is undefined when an unknown hook name is used, causing a runtime crash.
There is no other hook that exposes the model or messages before the LLM call.
Expected behavior: The hook fires once per LLM request, receives the full params (model + messages), and allows the plugin to override output.params.model (and optionally output.params.messages) before the request is dispatched.
This issue might be a duplicate of an existing issue. Please check:
[FEATURE]: Add V2 model-context plugin hook #35408: Proposes a scoped V2 plugin hook ("model-context hook") invoked once per provider turn before LLM dispatch, allowing plugins to mutate the model, messages, tools, and other context — which is a superset of the llm.request.before hook requested here.
Partly done: plugins have a context hook that runs before each model call and can change the system prompt, messages, options and tools (packages/plugin/src/effect/session.ts). The model itself is still read-only there. Changing the model for a request is tracked in #50729 and #35408, so closing this in favor of those.
Activity
github-actions commentedon Aug 27, 2026
This issue might be a duplicate of an existing issue. Please check:
llm.request.beforehook requested here.muyakoub commentedon Aug 27, 2026
#35408 proposes a superset of this hook as part of the V2 architecture. If that lands, this request would be covered.
neriousy commentedon Oct 22, 2026
Partly done: plugins have a
contexthook that runs before each model call and can change the system prompt, messages, options and tools (packages/plugin/src/effect/session.ts). The model itself is still read-only there. Changing the model for a request is tracked in #50729 and #35408, so closing this in favor of those.