wavetermdev/waveterm · error

adding context: %w

Error message

adding context: %w

What it means

The final step of `wsh ai` sends the composed message/submit flags as one WaveAIAddContextCommand RPC. If that RPC fails, aiRun wraps it as "adding context: %w". This is the send-the-prompt step of the CLI.

Source

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

			Route:   route,
			Timeout: rpcTimeout,
		})
		if err != nil {
			return fmt.Errorf("adding file %s: %w", file.Name, err)
		}
	}

	if aiMessageFlag != "" || aiSubmitFlag {
		finalContextData := wshrpc.CommandWaveAIAddContextData{
			Text:   aiMessageFlag,
			Submit: aiSubmitFlag,
		}
		err := wshclient.WaveAIAddContextCommand(RpcClient, finalContextData, &wshrpc.RpcOpts{
			Route:   route,
			Timeout: rpcTimeout,
		})
		if err != nil {
			return fmt.Errorf("adding context: %w", err)
		}
	}

	return nil
}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Ensure Wave Terminal is running and the target tab is still open, then retry.
  2. Re-run inside a fresh Wave terminal block to refresh WAVETERM_TABID.
  3. Check the wrapped cause for timeout vs. route-not-found and increase availability of the Wave app.
  4. Retry the command after transient load subsides.
Defensive patterns

Strategy: retry

Try / catch

err := wshclient.WaveAIAddContextCommand(RpcClient, finalContextData, opts)
if err != nil {
    // inspect %w cause; retry once if route/timeout related
}

Prevention

When it happens

Trigger: `wsh ai --message "..."` and/or --submit where the final WaveAIAddContextCommand fails: stale/invalid tab route, Wave app unresponsive, or RPC timeout exceeded.

Common situations: Wave Terminal busy or hung when submitting the message; tab closed mid-operation; message sent from outside the live Wave session so the route is gone.

Related errors


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