Uh oh!
There was an error while loading. Please reload this page.
feat(plugin): add stream.delta and stream.aborted hooks - #14741
feat(plugin): add stream.delta and stream.aborted hooks#14741marcusquinn wants to merge 1 commit into
Conversation
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found:
This looks like a duplicate. PR #14727 likely covers the same implementation for adding stream hooks to the plugin system. |
marcusquinn
commented
Feb 23, 2026
Re: failing checks — the two red checks are unrelated to this PR:
All checks relevant to this PR pass: typecheck, unit tests, e2e (linux), nix-eval, compliance, and standards. |
ba509c7 to
9fa611bComparemarcusquinn
commented
Feb 23, 2026
CI re-run #4: Same The last 3 runs on All PR-relevant checks pass: typecheck, unit tests, e2e (linux), nix-eval, compliance, standards. Requesting maintainer merge with admin override, as this PR cannot pass the Windows e2e gate that is also broken on |
7151569 to
0725ba7Comparemarcusquinn
commented
Feb 23, 2026
All code-related checks pass (typecheck, unit, e2e linux, nix-eval, pr-standards). The |
23ff222 to
aba111cComparemarcusquinn
commented
Feb 23, 2026
CI Status NoteThe two failing checks are both caused by a single flaky Windows Playwright e2e test ( Passing (6/8): nix-eval, check-standards, check-compliance, typecheck, unit (linux), e2e (linux) The stream hooks implementation doesn't touch any UI/prompt/mention code. Happy to rebase if needed, but this looks like a pre-existing flaky test. |
4250447 to
23905beCompareaa58e91 to
a83fcdfComparemarcusquinn
commented
Feb 24, 2026
CI Status NoteThe two failing checks (
Evidence: The last 5 CI runs on
This PR is ready to merge once the upstream Windows test issue is resolved, or if a maintainer can merge with admin privileges. |
marcusquinn
commented
Feb 24, 2026
CI StatusAll checks relevant to this PR pass:
The The Ready for maintainer merge (admin bypass of the Windows test failure). |
marcusquinn
commented
Feb 24, 2026
CI StatusAll checks relevant to this PR pass:
The two failing checks are pre-existing upstream issues unrelated to this PR:
Verified by checking the last 10 Ready to merge once a maintainer bypasses the failing Windows checks or the upstream Windows test infrastructure is fixed. |
marcusquinn
commented
Feb 24, 2026
CI StatusAll code-related checks pass:
The only failure is unit (windows) — 47 tests failing due to pre-existing Windows CI flakiness:
These failures are unrelated to this PR's changes (stream hooks in Rebased on latest |
e8bbd51 to
0d45668Comparemarcusquinn
commented
Feb 24, 2026
Rebased onto latest The remaining This PR is ready to merge once the Windows test gate is addressed upstream. |
marcusquinn
commented
Feb 24, 2026
CI StatusAll code-quality checks pass: unit (linux), typecheck, nix-eval, check-compliance, check-standards. The only failure is This PR is rebased on latest |
marcusquinn
commented
Feb 24, 2026
CI Status: Pre-existing Windows test failures (not caused by this PR)The
This PR changes only 3 files ( The |
56d950c to
2b2145cComparemarcusquinn
commented
Feb 24, 2026
Merge blocked by pre-existing |
fc577af to
d4857c8Comparemarcusquinn
commented
Feb 24, 2026
CI is blocked by pre-existing |
39ee0b4 to
b7e6040Comparemarcusquinn
commented
Feb 25, 2026
Ready for review — CI fully greenThe Windows CI failures that were blocking this PR are now resolved in v1.2.11 (path normalization, EBUSY cleanup, Bun 1.3.10 upgrade). All 9/9 checks pass:
The PR adds @adamdotdevin — would appreciate a review when you get a chance. |
778bf91 to
815bfb4Comparemarcusquinn
commented
Feb 25, 2026
Rebased onto latest |
Mark t1305 and t1306 as complete — upstream PR anomalyco/opencode#14741 is open with all 9/9 CI checks passing and MERGEABLE status. Add task brief documenting the implementation, acceptance criteria, and completion evidence.
Mark t1305 and t1306 as complete — upstream PR anomalyco/opencode#14741 is open with all 9/9 CI checks passing and MERGEABLE status. Add task brief documenting the implementation, acceptance criteria, and completion evidence.
ualtinok
commented
Mar 5, 2026
Hey! Thanks for this — stream-level observability is definitely needed. I've been working on a related feature that targets a slightly different problem: transforming the delta before it reaches the UI, rather than just observing it. Our use case: Our context management system tags messages with The key difference: Your Here's what our hook signature looks like: "assistant.message.delta"?: (input: {sessionID: string
messageID: string
partID: string
delta: string // raw chunk from LLMaccumulated: string // text so far},output: {delta: string},// mutate to transform display)=>Promise<void>We also added a few hot-path protections since this fires on every single chunk:
Would you be open to extending the output shape to include a output: {delta: string,abort: boolean,reason: string}That way one hook serves both observation/abort AND transformation. The hook fires before display, so:
Happy to collaborate on converging these — the |
marcusquinn
commented
Mar 6, 2026
A few more things building on @ualtinok's points: Hook ordering: +1 on firing before Zero-plugin overhead: Strongly agree on the Retry cleanup: When Test coverage: The current tests verify
|
tspython
commented
Apr 4, 2026
What's the status on this? I'd like this to become part of opencode. |
marcusquinn
commented
Apr 24, 2026
Status update
@ualtinok — to close the loop: agree with fire-before-display and the @tspython — ready and waiting on review. No technical blockers. @adamdotdevin — a first-pass review would be much appreciated when you get a chance. Happy to refine on feedback. aidevops.sh v3.10.2 plugin for OpenCode v1.14.24 with claude-opus-4-7 spent 18m and 23,206 tokens on this with the user in an interactive session. Overall, 60d 15h since this issue was created. |
bglusman
commented
May 5, 2026
I came here after researching whether OpenCode could support an oh-my-pi-style "time traveling stream rewriting" workflow as a plugin rather than a fork. This PR appears to be the core primitive needed for that. The important use case for us is not a built-in rules engine; it is enabling plugins to:
That lines up closely with The review comments above about firing before display, a Is there a maintainer-preferred shape for this hook now that the plugin API has evolved, or would a refreshed version of this PR still be welcome? |
Add two new hooks to the plugin system for real-time stream observation and abort control: - stream.delta: fires on every text-delta, reasoning-delta, and tool-input-delta event, allowing plugins to observe streaming content and optionally abort the stream - stream.aborted: fires after a stream is aborted by a delta hook, allowing plugins to decide whether to retry with optional corrective context injected into the conversation Implementation: - StreamAbortedError class for clean abort signaling - Hook calls in all three delta cases (text, reasoning, tool-input) - Catch block handles StreamAbortedError before generic error path - Retry logic with max 3 attempts and optional message injection - Zero new TypeScript errors introduced Use cases: TTSR (Time-To-Stream Rules), content filtering, real-time monitoring, pattern detection, self-correcting agents.
815bfb4 to
883eeedComparemarcusquinn
commented
May 5, 2026
Refreshed this PR against latest Updates included:
CI should re-run on commit aidevops.sh v3.14.69 plugin for OpenCode v1.14.39 with gpt-5.5 spent 7m and 226,268 tokens on this with the user in an interactive session. |
rekram1-node
commented
May 15, 2026
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes#14740
Type of change
What does this PR do?
Adds two plugin hooks for real-time stream observation:
stream.delta— fires ontext-delta,reasoning-delta, andtool-input-delta. Plugins can setoutput.abort = trueto cancel the stream.stream.aborted— fires after abort. Plugins can setoutput.retry = truewith optionalinjectMessageto retry with corrective context.The implementation adds
Plugin.trigger("stream.delta", ...)calls in the three delta cases inprocessor.ts, aStreamAbortedErrorclass for clean abort signaling, and catch-block handling with retry logic (max 3 attempts).This extends the existing
experimental.text.completepattern to cover streaming, which currently has no plugin observability.How did you verify your code works?
bun test test/session/stream-hooks.test.ts— 11 tests pass coveringStreamAbortedError, hook input/output shapes, and retry loop behaviorbun turbo typecheck— zero new errors across all 12 packagesbun test test/session/— all 120 existing session tests still passScreenshots / recordings
N/A — no UI changes.
Checklist