mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-07 00:44:49 +00:00
fix(subagents): cover persistence and naming edge cases
This commit is contained in:
@@ -94,6 +94,7 @@ function createManagedAgent(overrides: ManagedAgentOverrides = {}): ManagedAgent
|
||||
historyPrimed: true,
|
||||
lastUserMessageAt: now,
|
||||
attention: { requiresAttention: false },
|
||||
dismissedProviderSubagentIds: new Set(),
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -134,6 +135,7 @@ describe("toStoredAgentRecord", () => {
|
||||
it("captures lifecycle metadata, config, and persistence", () => {
|
||||
const agent = createManagedAgent({
|
||||
currentModeId: "focus",
|
||||
dismissedProviderSubagentIds: new Set(["native-child"]),
|
||||
persistence: {
|
||||
provider: "claude",
|
||||
sessionId: "persist-2",
|
||||
@@ -155,6 +157,7 @@ describe("toStoredAgentRecord", () => {
|
||||
expect(record.updatedAt).toBe(agent.updatedAt.toISOString());
|
||||
expect(record.lastActivityAt).toBe(agent.updatedAt.toISOString());
|
||||
expect(record.lastUserMessageAt).toBe(agent.lastUserMessageAt?.toISOString());
|
||||
expect(record.dismissedProviderSubagentIds).toEqual(["native-child"]);
|
||||
expect(record.persistence).toEqual({
|
||||
provider: "claude",
|
||||
sessionId: "persist-2",
|
||||
|
||||
@@ -126,6 +126,7 @@ function createManagedAgent(overrides: ManagedAgentOverrides = {}): ManagedAgent
|
||||
lastUserMessageAt: overrides.lastUserMessageAt ?? core.now,
|
||||
lastUsage: overrides.lastUsage,
|
||||
lastError: overrides.lastError,
|
||||
dismissedProviderSubagentIds: overrides.dismissedProviderSubagentIds ?? new Set(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -267,6 +267,24 @@ describe("codex tool-call mapper", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses only the final segment of a subAgentActivity path outside the root namespace", () => {
|
||||
const item = mapCodexToolCallFromThreadItem({
|
||||
type: "subAgentActivity",
|
||||
id: "activity-external-path",
|
||||
kind: "started",
|
||||
agentThreadId: "child-thread-external-path",
|
||||
agentPath: "/tmp/native/investigator",
|
||||
});
|
||||
|
||||
expect(item).toMatchObject({
|
||||
detail: {
|
||||
type: "sub_agent",
|
||||
subAgentType: "investigator",
|
||||
description: "/tmp/native/investigator",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("does not fail a collabAgentToolCall from child error state alone", () => {
|
||||
const item = mapCodexToolCallFromThreadItem({
|
||||
type: "collabAgentToolCall",
|
||||
|
||||
@@ -993,7 +993,15 @@ function mapCollabAgentToolCallItem(
|
||||
function mapSubAgentActivityItem(
|
||||
item: z.infer<typeof CodexSubAgentActivityItemSchema>,
|
||||
): ToolCallTimelineItem {
|
||||
const nativeName = item.agentPath.replace(/^\/root(?:\/|$)/, "") || "Sub-agent";
|
||||
let nativeName = item.agentPath;
|
||||
if (nativeName === "/root") {
|
||||
nativeName = "";
|
||||
} else if (nativeName.startsWith("/root/")) {
|
||||
nativeName = nativeName.slice("/root/".length);
|
||||
} else if (nativeName.includes("/")) {
|
||||
nativeName = nativeName.slice(nativeName.lastIndexOf("/") + 1);
|
||||
}
|
||||
nativeName ||= "Sub-agent";
|
||||
return {
|
||||
type: "tool_call",
|
||||
callId: item.id,
|
||||
|
||||
Reference in New Issue
Block a user