Skip to content

Tasks: Server-side input queue for auto-resume #1272

@mafredri

Description

@mafredri

Repo: coder/coder

Scope: Allow /send to accept messages for paused tasks, queue them, and deliver asynchronously.

Note: Consider ACP (Agent Communication Protocol) impact before implementation. ACP standardization may influence message queue design and delivery mechanism.

Changes:

  • Create task_pending_inputs table:
    • id UUID PRIMARY KEY
    • task_id UUID REFERENCES tasks(id)
    • content TEXT NOT NULL
    • status TEXT NOT NULL DEFAULT 'pending'
    • created_at TIMESTAMPTZ NOT NULL
    • delivered_at TIMESTAMPTZ
    • error TEXT
  • Modify /send to accept messages for paused tasks
  • Return 202 Accepted with message ID for queued messages
  • Background worker: trigger workspace start, poll for ready, deliver message, update status
  • Handle failures (build fails, delivery fails) with appropriate status updates

Benefits beyond auto-resume (per RFC):

  • Solves Terraform env var length limits for long prompts
  • Unifies initial prompt + follow-up delivery path
  • Enables prompt modification until task starts
  • Enables prebuilds for tasks

Files:

  • New migration for task_pending_inputs table
  • coderd/aitasks.go (modified send handler)
  • New background worker or integration with existing job system

Acceptance criteria:

  • /send to paused task returns 202 and queues message
  • Workspace automatically starts
  • Message delivered when workspace ready
  • Failure states handled gracefully with status tracking
  • Direct API consumers no longer need orchestration logic

Dependencies:

  • GA phase complete
  • ACP (Agent Communication Protocol) evaluation (does not block, but may influence design)

References:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions