Skip to content

[FEATURE]: Plugin hook to intercept and override LLM call parameters (llm.request.before) #45764

Closed

Description

@muyakoub

Feature hasn't been suggested before.

  • 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.

Activity

  1. github-actions commented on Aug 27, 2026

    @github-actions
    Contributor

    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.
  2. muyakoub commented on Aug 27, 2026

    @muyakoub
    Author

    #35408 proposes a superset of this hook as part of the V2 architecture. If that lands, this request would be covered.

  3. neriousy commented on Oct 22, 2026

    @neriousy
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions