Skip to content

✨ feat(agent-management): paginate searchAgent with real totals + wire 8 packages into CI#15448

Merged
AmAzing129 merged 3 commits into
canaryfrom
feat/search-agent-pagination
Jun 4, 2026
Merged

✨ feat(agent-management): paginate searchAgent with real totals + wire 8 packages into CI#15448
AmAzing129 merged 3 commits into
canaryfrom
feat/search-agent-pagination

Conversation

@AmAzing129

Copy link
Copy Markdown
Contributor

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

None — driven by a production conversation analysis (tpc_99aDrZmGT4ln): a user with 281 agents (137 non-virtual) asked the assistant to clean up their agents, and the searchAgent tool could never see beyond 20 of them while claiming the list was complete.

🔀 Description of Change

Commit 1 — searchAgent pagination & honest totals (lobe-agent-management)

The tool silently clamped limit to 20 (a limit: 50 request returned 20 with no signal), had no pagination despite the DB layer supporting offset, and reported totalCount as the returned page length — so the model concluded "20 is the API max" and proposed an incomplete cleanup (7 of the user's actual 19 untitled agents).

  • AgentModel: extract shared where-builder, add countAgents (same conditions as queryAgents); new countAgents TRPC procedure + client service method
  • Server tool runtime & AgentManagerRuntime (both execution paths): pass offset through, report real totals, and append explicit notes:
    • Found 137 agents in your workspace, showing 1-20: instead of Found 20 agents:
    • cap notice when the requested limit exceeds 20
    • next-page hint (call searchAgent with offset=20) when more workspace agents exist
    • out-of-range offsets explained (No agents at offset 200; only 37 agents match) instead of a false "No agents found"
  • Manifest: new offset param (workspace agents only; marketplace stays first-page), pagination documented
  • SearchAgentState: totalCount now means the real total; new hasMore / offset fields (render layer unaffected — it only reads agents)

Commit 2 — CI wiring for 8 orphaned package suites

An audit found 8 packages with test:coverage scripts that were never added to the CI PACKAGES allowlist, so their suites never ran:

Package State Action
agent-gateway-client / device-gateway-client / device-identity / eval-dataset-parser already green added to list
agent-manager-runtime suite unrunnable (no vitest config/scripts) wired in commit 1, added to list
eval-rubric / fetch-sse unrunnable: fell back to root vitest config whose setup/aliases break outside src/ minimal package configs added
heterogeneous-agents 1 assertion drifted (labels registry gained amp/hermes/openclaw/opencode — unnoticed precisely because not in CI) assertion updated

The codecov upload step reuses the same PACKAGES variable and probes for lcov files, so no further workflow changes are needed.

🧪 How to Test

  • Tested locally

  • Added/updated tests

  • No tests needed

  • packages/database agent model: 114 passed (4 new countAgents cases)

  • agent-manager-runtime: 29 passed (8 searchAgents cases incl. pagination/cap/out-of-range)

  • New server runtime suite serverRuntimes/__tests__/agentManagement.test.ts: 9 passed

  • lambda agent router: 12 passed

  • All 8 CI-wired packages verified with the exact CI command: bun run --filter <pkg> test:coverage

  • bun run type-check: 53 pre-existing errors on clean canary, 53 on this branch (zero introduced)

📝 Additional Information

  • Marketplace results are intentionally not offset-paged (the discover API is page-based and the tool only fetches page 1); the source: "all" next-page hint directs the model to source: "user" for pagination.
  • Follow-up debt (≈25 packages with test files but no test wiring at all, plus a CI guard to prevent recurrence) is tracked in a separate Linear issue.

…ap notice

The searchAgent tool silently clamped limit to 20 with no pagination and
reported totalCount as the returned page size, so models (and users) could
never discover agents beyond the 20 most recently updated ones.

- AgentModel: extract shared where builder, add countAgents (same
  conditions as queryAgents)
- lambda router + client agent service: expose countAgents
- server tool runtime & AgentManagerRuntime: pass offset through, report
  real totals (workspace + marketplace), emit explicit notes when the
  requested limit is capped and when more pages exist, explain
  out-of-range offsets instead of claiming no matches
- manifest: add offset param, document pagination
- agent-manager-runtime: add vitest config + test scripts (suite was
  previously unrunnable), repair stale store mocks
An audit found 8 packages carrying test:coverage scripts that were never
added to the CI PACKAGES allowlist, so their suites never ran:

- agent-gateway-client, device-gateway-client, device-identity,
  eval-dataset-parser: already green, added as-is
- eval-rubric, fetch-sse: had no package-level vitest config, so vitest
  fell back to the root config whose setup/aliases break outside src/ —
  added minimal configs
- heterogeneous-agents: one assertion drifted (labels registry gained
  amp/hermes/openclaw/opencode) with nobody noticing — updated
- agent-manager-runtime: wired in the previous commit

All 8 verified locally with the exact CI command
(bun run --filter <pkg> test:coverage).

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @AmAzing129, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Jun 4, 2026 2:26am

Request Review

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. feature:agent Assistant/Agent configuration and behavior feature:agent-builder Agent builder labels Jun 3, 2026
@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.88%. Comparing base (72ea0f9) to head (28a6d53).

Additional details and impacted files
@@            Coverage Diff            @@
##           canary   #15448     +/-   ##
=========================================
  Coverage   70.87%   70.88%             
=========================================
  Files        3223     3252     +29     
  Lines      319680   321863   +2183     
  Branches    33835    35150   +1315     
=========================================
+ Hits       226589   228163   +1574     
- Misses      92915    93520    +605     
- Partials      176      180      +4     
Flag Coverage Δ
app 61.62% <94.54%> (+0.04%) ⬆️
database 92.50% <100.00%> (+<0.01%) ⬆️
packages/agent-manager-runtime 49.69% <95.74%> (?)
packages/agent-runtime 80.48% <ø> (ø)
packages/builtin-tool-lobe-agent 18.52% <ø> (ø)
packages/context-engine 84.17% <ø> (ø)
packages/conversation-flow 91.29% <ø> (ø)
packages/device-gateway-client 89.68% <ø> (?)
packages/eval-dataset-parser 95.15% <ø> (?)
packages/eval-rubric 76.11% <ø> (?)
packages/fetch-sse 85.57% <ø> (?)
packages/file-loaders 87.89% <ø> (ø)
packages/memory-user-memory 74.99% <ø> (ø)
packages/model-bank 99.99% <ø> (ø)
packages/model-runtime 84.51% <ø> (ø)
packages/prompts 72.49% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/types 35.36% <ø> (ø)
packages/utils 88.77% <ø> (ø)
packages/web-crawler 88.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 68.48% <ø> (ø)
Services 54.57% <33.33%> (-0.02%) ⬇️
Server 71.98% <98.07%> (+0.10%) ⬆️
Libs 57.01% <ø> (ø)
Utils 81.44% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…alCount fallback

Codecov flagged 3 uncovered lines in the patch: the searchAgents catch
block (2 misses) and the totalCount ?? items.length fallback (1 partial).
Add the missing failure-path and fallback tests on both execution paths
(client AgentManagerRuntime + server tool runtime).
@AmAzing129 AmAzing129 merged commit 54e1b59 into canary Jun 4, 2026
35 checks passed
@AmAzing129 AmAzing129 deleted the feat/search-agent-pagination branch June 4, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:agent Assistant/Agent configuration and behavior feature:agent-builder Agent builder size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant