fix: skip agents.messages.reset in /clear for named conversations (#1209)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
cthomas
2026-02-27 15:48:02 -08:00
committed by GitHub
parent 1dd2281e2c
commit c5c4687dc4

View File

@@ -7736,12 +7736,16 @@ export default function App({
try {
const client = await getClient();
// Reset all messages on the agent (destructive operation)
await client.agents.messages.reset(agentId, {
add_default_initial_messages: false,
});
// Reset all messages on the agent only when in the default conversation.
// For named conversations, clearing just means starting a new conversation —
// there is no reason to wipe the agent's entire message history.
if (conversationIdRef.current === "default") {
await client.agents.messages.reset(agentId, {
add_default_initial_messages: false,
});
}
// Also create a new conversation since messages were cleared
// Create a new conversation
const conversation = await client.conversations.create({
agent_id: agentId,
isolated_block_labels: [...ISOLATED_BLOCK_LABELS],