feat(agents): add last-used tracking to identify stale agents#2627
Open
JonasJesus42 wants to merge 1 commit intomainfrom
Open
feat(agents): add last-used tracking to identify stale agents#2627JonasJesus42 wants to merge 1 commit intomainfrom
JonasJesus42 wants to merge 1 commit intomainfrom
Conversation
Derive agent last-used timestamps from monitoring_logs to help identify stale/unused agents that clutter the organization. Backend: - Add getLastUsedByVirtualMcpIds to MonitoringStorage (GROUP BY + MAX) - New MONITORING_AGENT_LAST_USED MCP tool with input validation (max 500 IDs) Frontend: - useAgentLastUsed hook in mesh-sdk (stable query key via sorted IDs) - Agents page: "Last used" column, usage filter (Recently used/Stale/Never) - Agents page: "never used" count in header stats - Home: sort "Recently used agents" by actual usage instead of updated_at Made-with: Cursor
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Contributor
Release OptionsShould a new version be published when this PR is merged? React with an emoji to vote on the release type:
Current version: Deployment
|
Contributor
There was a problem hiding this comment.
1 issue found across 11 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/mesh/src/web/components/home/agents-list.tsx">
<violation number="1" location="apps/mesh/src/web/components/home/agents-list.tsx:152">
P2: Cap the number of agent IDs sent to useAgentLastUsed (the tool rejects more than 500). Otherwise orgs with >500 agents will hit validation errors and this query will fail.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| agent.id !== null && !isDecopilot(agent.id), | ||
| ); | ||
|
|
||
| const agentIds = nonDecopilotAgents.map((a) => a.id); |
Contributor
There was a problem hiding this comment.
P2: Cap the number of agent IDs sent to useAgentLastUsed (the tool rejects more than 500). Otherwise orgs with >500 agents will hit validation errors and this query will fail.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/web/components/home/agents-list.tsx, line 152:
<comment>Cap the number of agent IDs sent to useAgentLastUsed (the tool rejects more than 500). Otherwise orgs with >500 agents will hit validation errors and this query will fail.</comment>
<file context>
@@ -140,12 +144,29 @@ function AgentsListContent() {
+ agent.id !== null && !isDecopilot(agent.id),
+ );
+
+ const agentIds = nonDecopilotAgents.map((a) => a.id);
+ const lastUsedMap = useAgentLastUsed(agentIds);
+
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Derive agent last-used timestamps from monitoring_logs to help identify stale/unused agents that clutter the organization.
Backend:
Frontend:
Made-with: Cursor
What is this contribution about?
Screenshots/Demonstration
How to Test
Migration Notes
Review Checklist
Summary by cubic
Adds last-used tracking for agents derived from
monitoring_logsto help surface stale or never-used agents. Updates the Agents page and Home to display and sort by real usage.MonitoringStorage.getLastUsedByVirtualMcpIdscomputes last-used per agent.MONITORING_AGENT_LAST_USED(max 500 IDs).useAgentLastUsedhook inpackages/mesh-sdk(sorted IDs for stable key, 60s cache).updated_at).Written for commit 28263df. Summary will update on new commits.