[PR #12715] Add LLM boundary hooks for request/response #14335

Closed
opened 2026-02-16 18:19:08 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12715

State: closed
Merged: No


What does this PR do?

Adds three plugin hooks at the LLM boundary: llm.request.before, llm.stream.chunk, and llm.response.after.
They run immediately before a provider request is sent, and immediately after a response chunk/result is received, enabling last‑mile masking and first‑mile unmasking without affecting opencode internal processing.

Changes are minimal and scoped to:

  • plugin hook types
  • LLM.stream (pre‑send + per‑chunk hook)
  • Agent.generate (streamObject + generateObject hooks)

How did you verify your code works?

Manual test in my fork with a masking plugin:

  • verified masking only happens right before request is sent
  • verified unmasking happens before opencode processes streamed chunks
  • verified non‑stream responses are unmasked at the boundary
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12715 **State:** closed **Merged:** No --- ### What does this PR do? Adds three plugin hooks at the LLM boundary: `llm.request.before`, `llm.stream.chunk`, and `llm.response.after`. They run immediately before a provider request is sent, and immediately after a response chunk/result is received, enabling last‑mile masking and first‑mile unmasking without affecting opencode internal processing. Changes are minimal and scoped to: - plugin hook types - `LLM.stream` (pre‑send + per‑chunk hook) - `Agent.generate` (streamObject + generateObject hooks) ### How did you verify your code works? Manual test in my fork with a masking plugin: - verified masking only happens right before request is sent - verified unmasking happens before opencode processes streamed chunks - verified non‑stream responses are unmasked at the boundary
yindo added the pull-request label 2026-02-16 18:19:08 -05:00
yindo closed this issue 2026-02-16 18:19:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14335