Skip to content

Tasks: Return log snapshot from logs endpoint when paused #1254

Closed
coder/coder
#21771

Description

@mafredri

Repo: coder/coder

Scope: Modify task logs endpoint to return stored snapshot when task is paused.

Changes:

  • Modify GET /api/v2/tasks/{user}/{task}/logs in coderd/aitasks.go
  • Check workspace status first
  • If task is active: fetch live logs from AgentAPI and return normalized logs (existing behavior)
  • If task is paused:
    • query task_snapshots
    • decode stored wrapper {"format":"agentapi","data":...}
    • normalize decoded AgentAPI payload into the same log entry schema used for live logs
    • add snapshot: true and snapshot_at
  • Add snapshot (bool), snapshot_at (timestamp), total_count (int) fields to response

Files:

  • coderd/aitasks.go
  • codersdk/aitasks.go

Acceptance criteria:

  • Live logs returned when workspace running
  • Stored snapshot returned when task is paused
  • Response includes snapshot: true and snapshot_at when returning snapshot
  • Returns empty logs response when no snapshot available
  • total_count equals the number of messages returned in the response

Dependencies:

References:

Activity

  1. added theissue type on Jan 15, 2026
  2. self-assigned this
    on Jan 21, 2026
  3. added a commit that references this issue on Jan 30, 2026
    21eabb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions