You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The prompt session hook does not carry the agent id, so a plugin that needs to route per agent cannot identify which agent is running at the point where routing can still be changed.
prompt is the earliest hook, and the only one where the session model is not yet frozen — context and model.request both declare readonly model. So prompt is the only place a plugin could redirect a turn to another model.
Today, working around this requires reading session.agent (see #54895) — which is possible — but the agent field on the event itself would be more direct.
Thanks for the clear write-up! To restate the request: the prompt hook event (SessionPrompt) should include readonly agent: Agent.ID. prompt is the earliest hook and the last point before the turn's model is fixed, so a plugin routing by agent could identify the agent there without calling ctx.session.get({ sessionID }) first. That workaround does work in the meantime, as you noted.
I checked the current code and SessionPrompt in @opencode/plugin still has no agent field, while context and model.request do carry it. Maintainers will consider adding it.
I'd like to work on this. I propose adding readonly agent: Agent.ID to both SessionPrompt interfaces, populating it during prompt preparation, and adding regression tests. This only exposes agent identity, without changing model selection or routing. Could you approve this scope and assign it to @56wj? I'll wait for design approval before opening a PR.
The proposed scope is right. Please add readonly agent: Agent.ID to both SessionPrompt interfaces, fill it while the prompt is prepared, and cover it with a regression test.
This should only expose the agent identity. It should not change model selection or routing. Assigning it to @56wj is fine. A PR with that scope is welcome.
Activity
opencode-agent commentedon Oct 12, 2026
Thanks for the clear write-up! To restate the request: the
prompthook event (SessionPrompt) should includereadonly agent: Agent.ID.promptis the earliest hook and the last point before the turn's model is fixed, so a plugin routing by agent could identify the agent there without callingctx.session.get({ sessionID })first. That workaround does work in the meantime, as you noted.I checked the current code and
SessionPromptin@opencode/pluginstill has noagentfield, whilecontextandmodel.requestdo carry it. Maintainers will consider adding it.Related issues:
session.get()doesn't expose the session model (the other half of this routing use case)56wj commentedon Oct 14, 2026
I'd like to work on this. I propose adding readonly agent: Agent.ID to both SessionPrompt interfaces, populating it during prompt preparation, and adding regression tests. This only exposes agent identity, without changing model selection or routing. Could you approve this scope and assign it to @56wj? I'll wait for design approval before opening a PR.
osrt91 commentedon Oct 14, 2026
The proposed scope is right. Please add
readonly agent: Agent.IDto bothSessionPromptinterfaces, fill it while the prompt is prepared, and cover it with a regression test.This should only expose the agent identity. It should not change model selection or routing. Assigning it to @56wj is fine. A PR with that scope is welcome.