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
- Ensure Wave Terminal is running and the target tab is still open, then retry.
- Re-run inside a fresh Wave terminal block to refresh WAVETERM_TABID.
- Check the wrapped cause for timeout vs. route-not-found and increase availability of the Wave app.
- 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
- Keep the Wave app responsive; avoid submitting while it is hung.
- Verify the target tab is still open before sending the message.
- Retry on transient timeouts.
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
- creating new chat: %w
- source cannot be blank
- nil wshrpc passed to wshclient
- adding file %s: %w
- publishing badge event: %v
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/a24492ae6fb1529d.
Report an issue: GitHub.