Skip to content

feat(opencode): V2 agent.pre-system waterfall alongside V1 transform - #77

Merged
filipeforattini merged 1 commit into
mainfrom
feat/agent-pre-system-shim
Aug 21, 2026
Merged

feat(opencode): V2 agent.pre-system waterfall alongside V1 transform#77
filipeforattini merged 1 commit into
mainfrom
feat/agent-pre-system-shim

Conversation

@filipeforattini

@filipeforattini filipeforattini commented Aug 21, 2026

Copy link
Copy Markdown

Fourth V1→V2 shim in the series (#70 #72 #75 #76). Adds SessionEvent.Agent.PreSystem (live waterfall event, type session.next.agent.pre_system) carrying { agent, sessionID, messageID, system } and wires EventV2Bridge.waterfall into the agent generate dispatch next to the existing V1 plugin.trigger('experimental.chat.system.transform', ...).

What this PR does

  • Adds Agent.PreSystem as a sibling to Agent.PreStep, carrying the system prompt payload.
  • The agent generate dispatch now runs a waterfall with a single listener that delegates to the V1 trigger so existing plugins keep working unchanged.
  • Listeners return { system } to rewrite the system prompt; throwing short-circuits the generate.
  • EventV2Bridge joins the Agent layer's deps so the generate function's new service requirement propagates cleanly.
  • cli/cmd/agent.ts provisions the EventV2Bridge service when running the generate effect locally.

Out of scope

  • permission.request for permission.ask (emit)
  • experimental.session.compacting / experimental.compaction.autocontinue / experimental.text.complete (all emit)
  • Full agent loop decomposition (turn flow as events)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Adds `SessionEvent.Agent.PreSystem` (live waterfall event, type `session.next.agent.pre_system`) carrying `{ agent, sessionID, messageID, system }` and wires `EventV2Bridge.waterfall` into the agent generate dispatch next to the existing V1 `plugin.trigger('experimental.chat.system.transform', ...)`.

The waterfall currently has a single listener that delegates to the V1 trigger so existing plugins keep working. Listeners return `{ system }` to rewrite the system prompt; throwing short-circuits the generate. Same shim pattern as #70 #72 #75 #76. `EventV2Bridge` joins the Agent layer's deps so the generate function's new service requirement propagates cleanly; `cli/cmd/agent.ts` provisions the service when running the generate effect locally.
@filipeforattini
filipeforattini merged commit 3f59431 into main Aug 21, 2026
4 of 7 checks passed
@filipeforattini
filipeforattini deleted the feat/agent-pre-system-shim branch August 21, 2026 12:01
filipeforattini added a commit that referenced this pull request Aug 21, 2026
Adds `SessionEvent.Text.Complete` (live waterfall event, type `session.next.text.complete`) carrying `{ sessionID, messageID, partID, text }` and wires `EventV2Bridge.waterfall` into the text-complete dispatch next to the existing V1 `plugin.trigger('experimental.text.complete', ...)`.

The waterfall currently has a single listener that delegates to the V1 trigger so existing plugins keep working. Listeners return `{ text }` to transform the final text; throwing short-circuits the text part. Same shim pattern as #70 #72 #75 #76 #77 #78 #79.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant