Skip to content

fix: keep the native question tool working in ordinary sessions - #18

Closed
syn7xx wants to merge 1 commit into
malhashemi:mainfrom
syn7xx:fix/native-question-form
Closed

syn7xx wants to merge 1 commit into
malhashemi:mainfrom
syn7xx:fix/native-question-form

Conversation

@syn7xx

@syn7xx syn7xx commented Oct 5, 2026

Copy link
Copy Markdown

Fixes #17.

What and why

With the plugin loaded, the built-in question tool stopped rendering in the parent/main client window: the form was emitted but the option list never appeared, so the session hung. Reproducible in an ordinary session with no Workflow running — merely having the plugin connected was enough.

Root cause: the plugin wrapped the built-in question tool with ctx.tool.transform → editor.update("question", …). On OpenCode 2.0.23 that makes form.created fire without a location. A location-scoped client (every ordinary session) then drops the form, so the options never render. Even a no-op update triggered it; editor.update("bash", …) and editor.add(…) did not.

The fix stops transforming question globally:

  • adds a dedicated workflow_question tool that routes a Unit's questions through the Run's broker (broker-routed, so the answer reaches whatever surface is watching — TUI, web, or any RPC client — instead of a blocking native form);
  • in the context hook, hides workflow_question outside Unit sessions and hides the native question inside Units;
  • pushes a QUESTION_INSTRUCTION to Units and allows workflow_question / denies question in ENGINE_UNIT_RULES;
  • drops the now-unneeded execute.after fallback hook.

Ordinary sessions keep the untouched native question, so its form renders with the full location.

How I tested it

  • bun run check — format, lint, typecheck, 292 tests, 0 fail.
  • Live, through a symlinked checkout plugin on a real OpenCode 2.0.23 (Linux):
    • ordinary session: the native question tool renders its options in the TUI ("1. Red / 2. Blue / 3. Type your own answer"); form.created carries location={directory:"/tmp/wf-repro"}.
    • headless Unit: workflow_question reports nobody available and the Unit proceeds (COLOUR=none).
    • attached Unit: answering the broker interaction via replyInteraction returns the answer (COLOUR=Blue).

Checklist

  • The title follows Conventional Commits (fix:)
  • bun run check passes
  • Protocol changes are additive and the schemas are regenerated (bun run schemas — no diff)
  • Docs (README, skill, protocol) updated if behavior or options changed

Transforming the built-in `question` tool (`editor.update("question", ...)`)
made OpenCode 2.0.23 emit `form.created` without a `location`, so a
location-scoped client — every ordinary session — dropped the form and the
option list never rendered; the session hung waiting for an answer.

Stop touching `question` globally. Add a dedicated `workflow_question` tool
that routes a Unit's questions to the Run's broker, hide it outside Unit
sessions and hide the native `question` inside them via the `context` hook,
and tell Units to ask through it. Units now never raise a blocking native
form.
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.

question tool: options never render when no surface is attached (form not created, session hangs)

1 participant