{"record":{"id":"a24492ae6fb1529d","repo":"wavetermdev/waveterm","slug":"adding-context-w","errorCode":null,"errorMessage":"adding context: %w","messagePattern":"adding context: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-ai.go","lineNumber":206,"sourceCode":"\t\t\tRoute:   route,\n\t\t\tTimeout: rpcTimeout,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"adding file %s: %w\", file.Name, err)\n\t\t}\n\t}\n\n\tif aiMessageFlag != \"\" || aiSubmitFlag {\n\t\tfinalContextData := wshrpc.CommandWaveAIAddContextData{\n\t\t\tText:   aiMessageFlag,\n\t\t\tSubmit: aiSubmitFlag,\n\t\t}\n\t\terr := wshclient.WaveAIAddContextCommand(RpcClient, finalContextData, &wshrpc.RpcOpts{\n\t\t\tRoute:   route,\n\t\t\tTimeout: rpcTimeout,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"adding context: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":188,"sourceCodeEnd":212,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-ai.go#L188-L212","documentation":"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.","triggerScenarios":"`wsh ai --message \"...\"` and/or --submit where the final WaveAIAddContextCommand fails: stale/invalid tab route, Wave app unresponsive, or RPC timeout exceeded.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := wshclient.WaveAIAddContextCommand(RpcClient, finalContextData, opts)\nif err != nil {\n    // inspect %w cause; retry once if route/timeout related\n}","preventionTips":["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."],"tags":["rpc","wsh","ai"],"backgroundTag":"rpc-call-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}