fix: callsites to list conversation messages (#1311)

This commit is contained in:
Christina Tong
2026-03-09 16:15:40 -07:00
committed by GitHub
parent a57cf84e03
commit f5d6f095a6
3 changed files with 8 additions and 7 deletions

View File

@@ -474,23 +474,24 @@ export async function getResumeData(
const retrievedMessages = await client.messages.retrieve(lastInContextId); const retrievedMessages = await client.messages.retrieve(lastInContextId);
// Fetch message history for backfill through the default conversation route. // Fetch message history for backfill through the default conversation route.
// Default conversation is represented by the agent id at the conversations endpoint. // Default conversation uses the "default" sentinel plus agent_id as a query param.
// Wrapped in try/catch so backfill failures don't crash the CLI (e.g., older servers // Wrapped in try/catch so backfill failures don't crash the CLI (e.g., older servers
// may not support this pattern) // may not support this pattern)
if (includeMessageHistory && isBackfillEnabled()) { if (includeMessageHistory && isBackfillEnabled()) {
try { try {
const messagesPage = await client.conversations.messages.list( const messagesPage = await client.conversations.messages.list(
agent.id, "default",
{ {
limit: BACKFILL_PAGE_LIMIT, limit: BACKFILL_PAGE_LIMIT,
order: "desc", order: "desc",
agent_id: agent.id,
}, },
); );
messages = sortChronological(messagesPage.getPaginatedItems()); messages = sortChronological(messagesPage.getPaginatedItems());
if (process.env.DEBUG) { if (process.env.DEBUG) {
console.log( console.log(
`[DEBUG] conversations.messages.list(${agent.id}) returned ${messages.length} messages`, `[DEBUG] conversations.messages.list(default, agent_id=${agent.id}) returned ${messages.length} messages`,
); );
} }
} catch (backfillError) { } catch (backfillError) {

View File

@@ -243,11 +243,11 @@ export function ConversationSelector({
if (!afterCursor) { if (!afterCursor) {
try { try {
const defaultMessages = await client.conversations.messages.list( const defaultMessages = await client.conversations.messages.list(
// Default conversation is represented by the agent id at the conversations endpoint. "default",
agentId,
{ {
limit: 20, limit: 20,
order: "desc", order: "desc",
agent_id: agentId,
}, },
); );
const defaultMsgItems = defaultMessages.getPaginatedItems(); const defaultMsgItems = defaultMessages.getPaginatedItems();

View File

@@ -159,12 +159,12 @@ export async function runMessagesSubcommand(argv: string[]): Promise<number> {
return 1; return 1;
} }
// Default conversation is represented by the agent id at the conversations endpoint. const response = await client.conversations.messages.list("default", {
const response = await client.conversations.messages.list(agentId, {
limit: parseLimit(parsed.values.limit, 20), limit: parseLimit(parsed.values.limit, 20),
after: parsed.values.after, after: parsed.values.after,
before: parsed.values.before, before: parsed.values.before,
order, order,
agent_id: agentId,
}); });
const messages = response.getPaginatedItems() ?? []; const messages = response.getPaginatedItems() ?? [];