[BUG] ListTasks is not sorted by last update time, newest first

Open Beginner friendly
#3,789 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, sql
Domain
database

Research direction

Start in go/core/internal/database/agent_tasks.go around L45-52, where ListTasks builds the page cursor and the ORDER BY t.position, t.id query. Read how the cursor tuple is constructed and used for pagination, then change both the ordering and cursor to (t.status_timestamp, t.id) with descending status timestamp. Done means the most recently updated task is returned first and pagination remains consistent across pages; run the relevant database tests if present.

Written by the indexing model from the issue text.

Description

📋 Prerequisites
  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software (checked against main at e8cd153)
  • I have tried to clear cache/cookies or used incognito mode (if ui-related)
  • I can consistently reproduce this issue
🎯 Affected Service(s)

Controller (A2A gateway)

🚦 Impact/Severity

Minor

🐛 Bug Description

ListTasks orders tasks by history position (agent_tasks.go L52, ORDER BY t.position, t.id). A2A 1.0.1 §3.1.4 says tasks MUST be sorted by last update time in descending order.

🔄 Steps To Reproduce
  1. Create two tasks in one context, then update the first one again.
  2. Call ListTasks for that context.
🤔 Expected Behavior

The most recently updated task comes first.

📱 Actual Behavior

The oldest task comes first.

🔍 Additional Context

The page cursor is also (t.position, t.id) (L45-48), so the cursor has to move to (t.status_timestamp, t.id) together with an ORDER BY t.status_timestamp DESC, t.id; changing only the ORDER BY breaks pagination. §3.1.4 names the status timestamp as the sort key.

Dominant language
Go
Stars
4.5k
Forks
937
Avg merge
1d 10h
Merged PRs (30d)
150

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kagent-dev/kagent

All issues in kagent-dev/kagent

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.