fix: reset conversation routing after /agents new agent creation (#1020)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -5369,6 +5369,19 @@ export default function App({
|
|||||||
// Update project settings with new agent
|
// Update project settings with new agent
|
||||||
await updateProjectSettings({ lastAgent: agent.id });
|
await updateProjectSettings({ lastAgent: agent.id });
|
||||||
|
|
||||||
|
// New agents always start on their default conversation route.
|
||||||
|
// Persist this explicitly so routing and resume state do not retain
|
||||||
|
// a previous agent's non-default conversation id.
|
||||||
|
const targetConversationId = "default";
|
||||||
|
settingsManager.setLocalLastSession(
|
||||||
|
{ agentId: agent.id, conversationId: targetConversationId },
|
||||||
|
process.cwd(),
|
||||||
|
);
|
||||||
|
settingsManager.setGlobalLastSession({
|
||||||
|
agentId: agent.id,
|
||||||
|
conversationId: targetConversationId,
|
||||||
|
});
|
||||||
|
|
||||||
// Build success message with hints
|
// Build success message with hints
|
||||||
const agentUrl = `https://app.letta.com/projects/default-project/agents/${agent.id}`;
|
const agentUrl = `https://app.letta.com/projects/default-project/agents/${agent.id}`;
|
||||||
const successOutput = [
|
const successOutput = [
|
||||||
@@ -5408,6 +5421,24 @@ export default function App({
|
|||||||
agent.llm_config.model
|
agent.llm_config.model
|
||||||
: (agent.llm_config.model ?? null);
|
: (agent.llm_config.model ?? null);
|
||||||
setCurrentModelHandle(agentModelHandle);
|
setCurrentModelHandle(agentModelHandle);
|
||||||
|
setConversationId(targetConversationId);
|
||||||
|
|
||||||
|
// Set conversation switch context for new agent switch
|
||||||
|
pendingConversationSwitchRef.current = {
|
||||||
|
origin: "agent-switch",
|
||||||
|
conversationId: targetConversationId,
|
||||||
|
isDefault: true,
|
||||||
|
agentSwitchContext: {
|
||||||
|
name: agent.name || agent.id,
|
||||||
|
description: agent.description ?? undefined,
|
||||||
|
model: agentModelHandle
|
||||||
|
? (await import("../agent/model")).getModelDisplayName(
|
||||||
|
agentModelHandle,
|
||||||
|
) || agentModelHandle
|
||||||
|
: "unknown",
|
||||||
|
blockCount: agent.blocks?.length ?? 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
// Reset context token tracking for new agent
|
// Reset context token tracking for new agent
|
||||||
resetContextHistory(contextTrackerRef.current);
|
resetContextHistory(contextTrackerRef.current);
|
||||||
|
|||||||
@@ -42,9 +42,30 @@ describe("bootstrap reminder reset wiring", () => {
|
|||||||
const anchorIndex = source.indexOf(anchor);
|
const anchorIndex = source.indexOf(anchor);
|
||||||
expect(anchorIndex).toBeGreaterThanOrEqual(0);
|
expect(anchorIndex).toBeGreaterThanOrEqual(0);
|
||||||
|
|
||||||
|
const windowStart = Math.max(0, anchorIndex - 2500);
|
||||||
const windowEnd = Math.min(source.length, anchorIndex + 5000);
|
const windowEnd = Math.min(source.length, anchorIndex + 5000);
|
||||||
const scoped = source.slice(anchorIndex, windowEnd);
|
const scoped = source.slice(windowStart, windowEnd);
|
||||||
expect(scoped).toContain("resetBootstrapReminderState();");
|
expect(scoped).toContain("resetBootstrapReminderState();");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("new-agent creation flow resets routing to default conversation", () => {
|
||||||
|
const appPath = fileURLToPath(
|
||||||
|
new URL("../../cli/App.tsx", import.meta.url),
|
||||||
|
);
|
||||||
|
const source = readFileSync(appPath, "utf-8");
|
||||||
|
|
||||||
|
const anchor = 'const inputCmd = "/new";';
|
||||||
|
const anchorIndex = source.indexOf(anchor);
|
||||||
|
expect(anchorIndex).toBeGreaterThanOrEqual(0);
|
||||||
|
|
||||||
|
const windowEnd = Math.min(source.length, anchorIndex + 8000);
|
||||||
|
const scoped = source.slice(anchorIndex, windowEnd);
|
||||||
|
|
||||||
|
expect(scoped).toContain('const targetConversationId = "default";');
|
||||||
|
expect(scoped).toContain("setConversationId(targetConversationId);");
|
||||||
|
expect(scoped).toContain("settingsManager.setLocalLastSession(");
|
||||||
|
expect(scoped).toContain("settingsManager.setGlobalLastSession({");
|
||||||
|
expect(scoped).toContain("conversationId: targetConversationId");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user