wavetermdev/waveterm · error

creating new chat: %w

Error message

creating new chat: %w

What it means

When `wsh ai` is invoked with --new (aiNewBlockFlag), it sends a WaveAIAddContextCommand RPC to create a new AI chat block before adding context. If that RPC fails (route unreachable, server error, timeout), aiRun wraps the cause with "creating new chat: %w".

Source

Thrown at cmd/wsh/cmd/wshcmd-ai.go:179

	}

	tabId := os.Getenv("WAVETERM_TABID")
	if tabId == "" {
		return fmt.Errorf("WAVETERM_TABID environment variable not set")
	}

	route := wshutil.MakeTabRouteId(tabId)

	if aiNewBlockFlag {
		newChatData := wshrpc.CommandWaveAIAddContextData{
			NewChat: true,
		}
		err := wshclient.WaveAIAddContextCommand(RpcClient, newChatData, &wshrpc.RpcOpts{
			Route:   route,
			Timeout: rpcTimeout,
		})
		if err != nil {
			return fmt.Errorf("creating new chat: %w", err)
		}
	}

	for _, file := range allFiles {
		contextData := wshrpc.CommandWaveAIAddContextData{
			Files: []wshrpc.AIAttachedFile{file},
		}
		err := wshclient.WaveAIAddContextCommand(RpcClient, contextData, &wshrpc.RpcOpts{
			Route:   route,
			Timeout: rpcTimeout,
		})
		if err != nil {
			return fmt.Errorf("adding file %s: %w", file.Name, err)
		}
	}

	if aiMessageFlag != "" || aiSubmitFlag {
		finalContextData := wshrpc.CommandWaveAIAddContextData{

View on GitHub (pinned to a4447c1563)

Solutions

  1. Confirm Wave Terminal is running and the tab referenced by WAVETERM_TABID still exists.
  2. Re-run the command from a fresh Wave terminal block to get a current WAVETERM_TABID.
  3. Inspect the wrapped cause (%w) in the message for the root RPC failure (timeout, no connection, etc.) and address it.
  4. Retry the command — transient IPC/busy states usually resolve on a second attempt.
Defensive patterns

Strategy: retry

Try / catch

err := wshclient.WaveAIAddContextCommand(RpcClient, data, opts)
if err != nil {
    if errors.Is(err, context.DeadlineExceeded) { /* retry with longer timeout */ }
    return fmt.Errorf("creating new chat: %w", err)
}

Prevention

When it happens

Trigger: Running `wsh ai --new ...` where the WaveAIAddContextCommand RPC fails: the target tab route no longer exists (tab closed), the Wave app is not running/hung, or the RPC exceeded the rpcTimeout.

Common situations: The tab identified by WAVETERM_TABID was closed between session start and command execution; Wave terminal was restarted so the route id is stale; network/connection to the wsh server dropped; slow machine caused RPC timeout.

Related errors


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