anomalyco / anomalyco/opencode
[FEATURE]: Plugin hook to intercept and override LLM call parameters (llm.request.before)
@kitlangton is already working on this.
Since Aug 27, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.