coder / coder/internal

Tasks: API: Add pagination and granular message control to logs endpoint

Open
#1,247 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Problem

The task logs API (`GET /api/v2/tasks/{user}/{task}/logs`) currently returns the entire conversation history. This is not ideal for tasks with long-running conversations:

- Large response payloads for tasks with hundreds of messages
- No way to fetch specific message ranges
- Inefficient for clients that only need recent messages or want to implement infinite scroll

## Current Behavior

The API returns all messages in a single response:

```json
{
"logs": [...], // All messages
"snapshot": false,
"total_count": 250
}
```

When a task is paused (post-implementation of pause/resume functionality), it returns the last 10 messages from the snapshot:

```json
{
"logs": [...], // Last 10 messages
"snapshot": true,
"snapshot_at": "2025-01-18T10:00:00Z",
"total_count": 10
}
```

## Proposed Enhancement

Add pagination support to the logs endpoint. The exact implementation will depend on the message model after ACP integration, which may introduce more granular message types, status updates, and metadata beyond the current large text blocks.

Pagination should follow coderd's existing patterns (using `limit`, `offset`, and `after_id` query parameters as defined in `codersdk.Pagination`).

Key considerations:

- With ACP, messages may be split into multiple granular events rather than 500-line text blocks
- The message structure and metadata may evolve significantly
- Pagination design should accommodate future message model changes

## Context

Raised during RFC review for Task Start/Pause/Resume Lifecycle. Deferred from Beta/GA as it's an enhancement rather than blocking issue.

## Acceptance Criteria

- [ ] Design pagination approach that accommodates future ACP message model changes
- [ ] Works for both active tasks (live logs) and paused tasks (snapshots)
- [ ] Follows coderd's existing pagination patterns
- [ ] Document pagination behavior
- [ ] Update CLI if needed to support fetching message ranges

## Related

- RFC: Task Start/Pause/Resume Lifecycle
- Future: ACP integration for message-level control

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.