--- kind: task slug: ai-assisted-agent-builder title: Generate structured agent drafts with AI plan_slug: workspace-communications epic_slug: agent-participation status: ready priority: P1 tenant_id: global owner: unassigned cursor_todo_id: null updated_at: "2026-09-25" --- # Task summary Use the Agents-tab composer to turn a natural-language request into a validated structured draft that can be refined conversationally or through direct field edits. ## Description In Agents mode, prompts such as “Create an agent that triages failed convoy runs and asks before retrying” start a builder conversation rather than a normal workspace chat. The server returns a typed agent-draft proposal: identity, purpose, instructions, capabilities, requested tools, invocation/context policy, model role, harness route, budget, and unresolved questions. Users can refine the draft conversationally, edit fields directly, and save a private draft. Permission approval, sandbox testing, installation, and activation are handled by a dependent review task. Generated configuration never silently grants tools, selects plaintext credentials, publishes, or activates an agent. ## Subtasks - [ ] Define a versioned zod schema for agent-builder requests, clarifying questions, structured draft patches, warnings, and save readiness. - [ ] Add a workspace-authorized streaming builder endpoint/service that uses model routing rather than a hard-coded provider. - [ ] Reuse the shared composer shell with Agents-specific placeholder text, examples, attachments policy, and submit handling. - [ ] Add prompt-injection boundaries, requested-tool validation, budget caps, audit logging, and malformed-model-output tests. - [ ] Define the follow-on UI contract for transcript, structured editing, revision history, and private-draft save/resume without implementing persistence in this task. ## Owner or assignee `unassigned` ## Status `ready` ## Estimation `L` ## Acceptance criteria - [ ] Natural-language requests produce zod-validated structured drafts or clarifying questions, never unvalidated persisted configuration. - [ ] The builder requests a model role/capability and works through the existing provider/harness abstraction. - [ ] Initial requests and conversational refinements produce ordered clarification/draft-patch events with deterministic base revisions. - [ ] Generated requested tools, activation, channel access, and workspace publication remain unapproved fields and cannot take effect in this task. - [ ] This service does not persist, publish, activate, or execute an agent; UI editing and private-draft persistence are a follow-on task. - [ ] `pnpm lint && pnpm type-check && pnpm test` pass. ## Links to related Epic / Plan - Epic: `./Epic-agent-participation.md` - Plan: `../Plan-workspace-communications.md`