wavetermdev/waveterm · error

chat not found: %s

Error message

chat not found: %s

What it means

Returned when the referenced Anthropic chat id is not present in the chat store during message lookup.

Source

Thrown at pkg/aiusechat/anthropic/anthropic-convertmessage.go:875

			argsBytes, err := json.Marshal(argsInput)
			if err != nil {
				continue
			}
			return &uctypes.AIFunctionCallInput{
				CallId:      block.ID,
				Name:        block.Name,
				Arguments:   string(argsBytes),
				ToolUseData: block.ToolUseData,
			}
		}
	}
	return nil
}

func UpdateToolUseData(chatId string, toolCallId string, toolUseData uctypes.UIMessageDataToolUse) error {
	chat := chatstore.DefaultChatStore.Get(chatId)
	if chat == nil {
		return fmt.Errorf("chat not found: %s", chatId)
	}
	for _, genMsg := range chat.NativeMessages {
		chatMsg, ok := genMsg.(*anthropicChatMessage)
		if !ok {
			continue
		}
		for i, block := range chatMsg.Content {
			if block.Type != "tool_use" || block.ID != toolCallId {
				continue
			}
			updatedMsg := &anthropicChatMessage{
				MessageId: chatMsg.MessageId,
				Usage:     chatMsg.Usage,
				Role:      chatMsg.Role,
				Content:   slices.Clone(chatMsg.Content),
			}
			updatedMsg.Content[i].ToolUseData = &toolUseData
			aiOpts := &uctypes.AIOptsType{

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the chatId matches one registered in chatstore.DefaultChatStore (create/register the chat first)
  2. Check the call ordering so the chat is not removed before UpdateToolUseData runs
  3. Log/store the chat ID at creation time and reuse the exact value

Example fix

// before
err := anthropic.UpdateToolUseData(chatId, toolCallId, data) // chat never created
// after
if chatstore.DefaultChatStore.Get(chatId) != nil {
    err = anthropic.UpdateToolUseData(chatId, toolCallId, data)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if chatstore.DefaultChatStore.Get(chatId) == nil {
    return fmt.Errorf("chat %s is not registered", chatId)
}

Try / catch

if err := anthropic.UpdateToolUseData(chatId, toolCallId, data); err != nil && strings.HasPrefix(err.Error(), "chat not found") {
    // recreate chat or skip update
    return nil
}

Prevention

When it happens

Trigger: Calling UpdateToolUseData(chatId, toolCallId, data) where DefaultChatStore.Get(chatId) returns nil — the chat was never registered, was already removed, or the ID string is wrong.

Common situations: Using a chat ID from a different process/session, calling after RemoveChat/chat store reset, typos in the ID, or a race where the chat is deleted before the update.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/2289cdfdab9b514a. Report an issue: GitHub.