Skip to content

fix(agent): cap list tool page sizes - #557

Merged
BaaRai merged 2 commits into
BaaRai:mainfrom
Coff0xc:fix/agent-list-cap
Nov 26, 2026
Merged

BaaRai merged 2 commits into
BaaRai:mainfrom
Coff0xc:fix/agent-list-cap

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

list_worker_traces, list_assets, and list_untested_assets only filled in a default when the model omitted the limit. A large limit was used as a slice capacity or as the SQL page size, and a large page number overflowed the offset.

The limit and page size now stop at 100, matching list_facts. The page number stops at 10000 and the offset stops at 1000000. An ids list is still returned in full.

go test -count=1 -run TestClampToolLimit ./agent/ passed.

A model-supplied limit on list_worker_traces, list_assets, and
list_untested_assets was only defaulted. A huge value became a slice
capacity or a SQL page size. Clamp the limit and page size to 100, and
bound the page number and offset.
@5P34R

5P34R commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Review notes

This fixes the real crash: a huge limit reached make(..., 0, limit) at agent/tools.go:2538. Two changes are needed so the agent isn't silently short-changed.

Required:

  • list_assets returns only count and assets (agent/tools_insert.go:617-620). A request for limit:500 now returns 100 rows that look like the complete set. Please return the effective limit, or a has_more/clamped flag.
  • list_worker_traces has no offset parameter and reads 500 rows (agent/tools.go:2533). Capping it at 100 makes traces 101–500 unreachable. Capping at 500, the fetch size, avoids that.

The tests cover the clamp helpers but not the tool outputs.

@BaaRai
BaaRai force-pushed the fix/agent-list-cap branch from dbb9671 to 0de239f Compare November 26, 2026 22:24
BaaRai added a commit to Coff0xc/ARTEX-contrib that referenced this pull request Nov 26, 2026
@BaaRai
BaaRai force-pushed the fix/agent-list-cap branch from 0de239f to 32835a1 Compare November 26, 2026 22:40
BaaRai added a commit to Coff0xc/ARTEX-contrib that referenced this pull request Nov 26, 2026
@BaaRai
BaaRai force-pushed the fix/agent-list-cap branch from 32835a1 to 54190be Compare November 26, 2026 22:56
BaaRai added a commit to Coff0xc/ARTEX-contrib that referenced this pull request Nov 26, 2026
@BaaRai
BaaRai force-pushed the fix/agent-list-cap branch from 54190be to 17e3687 Compare November 26, 2026 23:14
@BaaRai
BaaRai merged commit f7505c0 into BaaRai:main Nov 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants