feat: improve Agent Control MCP activity endpoint with count headers
Enhance the get_agent_activity tool to provide better context about the activity list: - Add activity count headers showing "X of Y activities" - Remove raw format option, always use curated format for consistency - Simplify implementation by removing unnecessary format branching - Respect limit parameter to show most recent N activities This makes it clearer to users when they're viewing a subset of activities versus the full list. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,6 @@ import type {
|
|||||||
import {
|
import {
|
||||||
AgentPermissionRequestPayloadSchema,
|
AgentPermissionRequestPayloadSchema,
|
||||||
AgentPermissionResponseSchema,
|
AgentPermissionResponseSchema,
|
||||||
AgentTimelineItemPayloadSchema,
|
|
||||||
AgentSnapshotPayloadSchema,
|
AgentSnapshotPayloadSchema,
|
||||||
serializeAgentSnapshot,
|
serializeAgentSnapshot,
|
||||||
} from "../messages.js";
|
} from "../messages.js";
|
||||||
@@ -642,57 +641,49 @@ export async function createAgentMcpServer(
|
|||||||
{
|
{
|
||||||
title: "Get Agent Activity",
|
title: "Get Agent Activity",
|
||||||
description:
|
description:
|
||||||
"Return recent agent timeline entries. Default response is a curated summary; raw timeline entries are available via format='raw'.",
|
"Return recent agent timeline entries as a curated summary.",
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
agentId: z.string(),
|
agentId: z.string(),
|
||||||
format: z.enum(["curated", "raw"]).optional().default("curated"),
|
|
||||||
limit: z
|
limit: z
|
||||||
.number()
|
.number()
|
||||||
.optional()
|
.optional()
|
||||||
.describe("Optional limit for raw entries (most recent first)."),
|
.describe("Optional limit for number of activities to include (most recent first)."),
|
||||||
},
|
},
|
||||||
outputSchema: {
|
outputSchema: {
|
||||||
agentId: z.string(),
|
agentId: z.string(),
|
||||||
format: z.enum(["curated", "raw"]),
|
|
||||||
updateCount: z.number(),
|
updateCount: z.number(),
|
||||||
currentModeId: z.string().nullable(),
|
currentModeId: z.string().nullable(),
|
||||||
content: z.string(),
|
content: z.string(),
|
||||||
updates: z
|
|
||||||
.array(AgentTimelineItemPayloadSchema)
|
|
||||||
.nullable()
|
|
||||||
.describe("Timeline entries when format='raw'."),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async ({ agentId, format = "curated", limit }) => {
|
async ({ agentId, limit }) => {
|
||||||
const timeline = agentManager.getTimeline(agentId);
|
const timeline = agentManager.getTimeline(agentId);
|
||||||
const snapshot = agentManager.getAgent(agentId);
|
const snapshot = agentManager.getAgent(agentId);
|
||||||
|
|
||||||
if (format === "curated") {
|
const activitiesToCurate = limit
|
||||||
return {
|
? timeline.slice(-limit)
|
||||||
content: [],
|
: timeline;
|
||||||
structuredContent: ensureValidJson({
|
|
||||||
agentId,
|
const curatedContent = curateAgentActivity(activitiesToCurate);
|
||||||
format: "curated" as const,
|
const totalCount = timeline.length;
|
||||||
updateCount: timeline.length,
|
const shownCount = activitiesToCurate.length;
|
||||||
currentModeId: snapshot?.currentModeId ?? null,
|
|
||||||
content: curateAgentActivity(timeline),
|
let countHeader: string;
|
||||||
updates: null,
|
if (limit && shownCount < totalCount) {
|
||||||
}),
|
countHeader = `Showing ${shownCount} of ${totalCount} ${totalCount === 1 ? 'activity' : 'activities'} (limited to ${limit})`;
|
||||||
};
|
} else {
|
||||||
|
countHeader = `Showing all ${totalCount} ${totalCount === 1 ? 'activity' : 'activities'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const entries = limit
|
const contentWithCount = `${countHeader}\n\n${curatedContent}`;
|
||||||
? timeline.slice(-limit).reverse()
|
|
||||||
: timeline;
|
|
||||||
return {
|
return {
|
||||||
content: [],
|
content: [],
|
||||||
structuredContent: ensureValidJson({
|
structuredContent: ensureValidJson({
|
||||||
agentId,
|
agentId,
|
||||||
format: "raw" as const,
|
|
||||||
updateCount: timeline.length,
|
updateCount: timeline.length,
|
||||||
currentModeId: snapshot?.currentModeId ?? null,
|
currentModeId: snapshot?.currentModeId ?? null,
|
||||||
content: "",
|
content: contentWithCount,
|
||||||
updates: entries,
|
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user