feat(chat-workflow): port task + ask_user_question composite tools (PR 7)

Merged
SW
6mo ago
+644-29

Summary

Completes the open-agents tool surface — the agent now has all 11 tools.

`ask_user_question` — client-side tool

Schema mirrors open-agents verbatim. No server `execute`: streamText halts after emitting the tool-call because there's no result to feed back; the chat UI renders the question component, collects answers, submits them in the next workflow request's messages. No WDK pause/resume hook needed — natural workflow boundary handles the pause.

`task` — subagent delegation

Slim port of open-agents' multi-type `SUBAGENT_REGISTRY` → one generic subagent. Runs sub-`streamText` with a curated tool set matching open-agents' `executor`: `read, write, edit, grep, glob, bash`.

Recursion guard (matches open-agents): subagent tool set explicitly excludes `task`, `ask_user_question`, `skill`, `todo_write`, `web_fetch`. Open-agents' three subagent types (executor, explorer, design) all curate their own minimal tool sets and never include `task` — subagents are leaves of the agent tree.

Wire-up

  • `AgentContext` gains `modelId?: string` so the subagent uses the same model as its parent.
  • Handler populates `modelId` in context from `chat.model_id` or platform default.
  • `buildAgentTools` registers both new tools unconditionally; `skill` stays conditional on non-empty catalog.

Quirk to note

api's AI SDK (`6.0.0-beta.122`) calls `toModelOutput(output)` directly, not `toModelOutput({ output })` as open-agents' newer `6.0.165` does. `askUserQuestionTool` uses the direct signature.

Verification

  • 9 askUserQuestion tests + 6 taskTool tests + updated buildAgentTools = 20 new tests; suite 3075/3075 pass
  • Lint clean
  • Production build succeeds
  • E2E preview verification running

🤖 Generated with Claude Code


Summary by cubic

Adds task and ask_user_question, completing the 11‑tool surface. Subagents now inherit the parent model via a durable context, and task uses a non‑empty prompt to avoid NoOutputGeneratedError.

  • New Features

    • ask_user_question (client-side): schema mirrors open-agents; no server execute; UI gathers answers next turn; toModelOutput formats answers or declines.
    • task: runs a subagent with only read, write, edit, grep, glob, bash; excludes task, ask_user_question, skill, todo_write, web_fetch; 30‑step cap; returns a concise summary; passes a non‑empty prompt.
    • buildAgentTools now registers task and ask_user_question by default; skill stays conditional.
  • Refactors

    • Aligned AgentContext with open‑agents: adds model: LanguageModel and optional subagentModel; introduced DurableAgentContext for workflow inputs; runAgentStep constructs gateway(modelId) and attaches it to experimental_context.
    • Added getMainModel and getSubagentModel; the subagent now defaults to the parent model (override via subagentModel), replacing the previous hardcoded model.
    • Extracted buildSubagentTools for the subagent’s executor tool set.

Summary by CodeRabbit

  • New Features
    • Agents can now pause execution and ask users questions through the chat interface, with support for structured multi-choice responses
    • Agents can delegate focused work to subagents for specialized task execution
    • Expanded agent toolset from 9 to 11 available tools, enabling more sophisticated interactions

Review Change Stack