fix: migrate default conversation API usage to SDK 1.7.11 pattern (#1256)

Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
cthomas
2026-03-03 22:48:49 -08:00
committed by GitHub
parent a44c16edc7
commit 4111c546d3
18 changed files with 116 additions and 110 deletions

View File

@@ -85,7 +85,7 @@ describe("discoverFallbackRunIdForResume", () => {
makeRunsListClient(runsList),
{
conversationId: "default",
resolvedConversationId: "agent-test",
resolvedConversationId: "default",
agentId: "agent-test",
requestStartedAtMs: Date.parse("2026-02-27T11:00:00.000Z"),
},
@@ -93,7 +93,7 @@ describe("discoverFallbackRunIdForResume", () => {
expect(candidate).toBe("run-agent-fallback");
expect(calls).toEqual([
{ conversation_id: "agent-test", agent_id: undefined },
{ conversation_id: "default", agent_id: undefined },
{ conversation_id: undefined, agent_id: "agent-test" },
]);
});

View File

@@ -7,7 +7,7 @@
* 3. Pagination fields (next_before, has_more)
* 4. Timing fields presence
* 5. Error path — client throws → error envelope returned
* 6. Default conversation passes agent ID to conversations.messages.list
* 6. Default conversation passes conversation_id="default" with agent_id query
* 7. Explicit conversation uses conversations.messages.list
*
* No network. No CLI subprocess. No process.stdout.
@@ -56,7 +56,7 @@ const BASE_CTX: BootstrapHandlerSessionContext = {
// ─────────────────────────────────────────────────────────────────────────────
describe("bootstrap_session_state routing", () => {
test("default conversation passes agent ID to conversations.messages.list", async () => {
test("default conversation passes default + agent_id to conversations.messages.list", async () => {
const { client, convListSpy } = makeClient([
{ id: "msg-1", type: "user_message" },
]);
@@ -70,9 +70,11 @@ describe("bootstrap_session_state routing", () => {
expect(convListSpy).toHaveBeenCalledTimes(1);
// Verify agent ID is passed as the conversation_id
const callArgs = (convListSpy.mock.calls[0] as unknown[])[0];
expect(callArgs).toBe("agent-test-123");
const callArgs = convListSpy.mock.calls[0] as unknown[];
expect(callArgs[0]).toBe("default");
expect((callArgs[1] as { agent_id?: string }).agent_id).toBe(
"agent-test-123",
);
});
test("named conversation uses conversations.messages.list", async () => {

View File

@@ -105,7 +105,7 @@ describe("handleListMessages — routing (which API is called)", () => {
}
});
test("omitted conversation_id + session on default → calls conversations.messages.list with agent ID", async () => {
test("omitted conversation_id + session on default → calls conversations.messages.list with default + agent_id", async () => {
const { client, convListSpy } = makeClient([{ id: "msg-default-1" }]);
const resp = await handleListMessages({
@@ -117,11 +117,13 @@ describe("handleListMessages — routing (which API is called)", () => {
});
expect(convListSpy).toHaveBeenCalledTimes(1);
expect(convListSpy.mock.calls[0]?.[0]).toBe("agent-def");
expect(convListSpy.mock.calls[0]?.[0]).toBe("default");
const opts = convListSpy.mock.calls[0]?.[1] as { agent_id?: string };
expect(opts.agent_id).toBe("agent-def");
expect(resp.response.subtype).toBe("success");
});
test("explicit agent_id + session default → conversations path uses request agent_id", async () => {
test("explicit agent_id + session default → conversations path uses request agent_id query", async () => {
const { client, convListSpy } = makeClient([]);
await handleListMessages({
@@ -132,7 +134,9 @@ describe("handleListMessages — routing (which API is called)", () => {
client,
});
expect(convListSpy.mock.calls[0]?.[0]).toBe("agent-override");
expect(convListSpy.mock.calls[0]?.[0]).toBe("default");
const opts = convListSpy.mock.calls[0]?.[1] as { agent_id?: string };
expect(opts.agent_id).toBe("agent-override");
});
});
@@ -176,12 +180,13 @@ describe("handleListMessages — API call arguments", () => {
client,
});
// Default conversation resolves to agent ID
expect(convListSpy.mock.calls[0]?.[0]).toBe("agent-1");
expect(convListSpy.mock.calls[0]?.[0]).toBe("default");
const opts = convListSpy.mock.calls[0]?.[1] as {
agent_id?: string;
limit: number;
order: string;
};
expect(opts.agent_id).toBe("agent-1");
expect(opts.limit).toBe(50);
expect(opts.order).toBe("desc");
});
@@ -216,8 +221,12 @@ describe("handleListMessages — API call arguments", () => {
client,
});
expect(convListSpy.mock.calls[0]?.[0]).toBe("agent-1");
const opts = convListSpy.mock.calls[0]?.[1] as { before?: string };
expect(convListSpy.mock.calls[0]?.[0]).toBe("default");
const opts = convListSpy.mock.calls[0]?.[1] as {
agent_id?: string;
before?: string;
};
expect(opts.agent_id).toBe("agent-1");
expect(opts.before).toBe("msg-cursor-agents");
});

View File

@@ -192,28 +192,29 @@ describe("list_messages routing — resolveListMessagesRoute", () => {
/**
* Case C: no conversation_id in request, session is on the default conversation.
* Resolves to conversations API with agent ID as the conversation_id
* (server accepts agent-* IDs for agent-direct messaging).
* Keeps conversation_id="default" and passes agent_id separately.
*/
test("C — omitted conversation_id + session default → conversations API with session agentId", () => {
test("C — omitted conversation_id + session default → conversations API with default + session agentId", () => {
const route = resolveListMessagesRoute(
{}, // no conversation_id
"default", // session is on default conversation
SESSION_AGENT,
);
expect(route.kind).toBe("conversations");
expect(route.conversationId).toBe(SESSION_AGENT);
expect(route.conversationId).toBe("default");
expect(route.agentId).toBe(SESSION_AGENT);
});
test("C — explicit agent_id in request + session default → uses request agentId", () => {
test("C — explicit agent_id in request + session default → uses request agentId query", () => {
const route = resolveListMessagesRoute(
{ agent_id: "agent-override-id" },
"default",
SESSION_AGENT,
);
expect(route.kind).toBe("conversations");
expect(route.conversationId).toBe("default");
// Request's agent_id takes priority over session agent when on default conv
expect(route.conversationId).toBe("agent-override-id");
expect(route.agentId).toBe("agent-override-id");
});
test("C — no conversation_id, no agent_id, session default → falls back to session agentId", () => {
@@ -223,7 +224,8 @@ describe("list_messages routing — resolveListMessagesRoute", () => {
"agent-session-fallback",
);
expect(route.kind).toBe("conversations");
expect(route.conversationId).toBe("agent-session-fallback");
expect(route.conversationId).toBe("default");
expect(route.agentId).toBe("agent-session-fallback");
});
/**