{"record":{"id":"33403c27fa65d4c8","repo":"charmbracelet/crush","slug":"failed-to-start-agent-processing-stream-w","errorCode":null,"errorMessage":"failed to start agent processing stream: %w","messagePattern":"failed to start agent processing stream: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/app/app.go","lineNumber":364,"sourceCode":"\n\t// Automatically approve all permission requests for this non-interactive\n\t// session.\n\tapp.Permissions.AutoApproveSession(sess.ID)\n\n\t// Report session identity to herdr.\n\tapp.ReportCurrentSession(sess.ID)\n\n\ttype response struct {\n\t\tresult *fantasy.AgentResult\n\t\terr    error\n\t}\n\tdone := make(chan response, 1)\n\n\tgo func(ctx context.Context, sessionID, prompt string) {\n\t\tresult, err := app.AgentCoordinator.Run(ctx, sess.ID, prompt)\n\t\tif err != nil {\n\t\t\tdone <- response{\n\t\t\t\terr: fmt.Errorf(\"failed to start agent processing stream: %w\", err),\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tdone <- response{\n\t\t\tresult: result,\n\t\t}\n\t}(ctx, sess.ID, prompt)\n\n\tmessageEvents := app.Messages.Subscribe(ctx)\n\tmessageReadBytes := make(map[string]int)\n\tvar printed bool\n\n\tdefer func() {\n\t\tif progress && stderrTTY {\n\t\t\t_, _ = fmt.Fprintf(os.Stderr, ansi.ResetProgressBar)\n\t\t}\n\n\t\t// Always print a newline at the end. If output is a TTY this will","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/app/app.go#L346-L382","documentation":"The non-interactive run starts the agent in a goroutine via app.AgentCoordinator.Run; if Run returns an error (stream could not even start — provider auth, request build failure, cancelled context), the goroutine pushes a wrapped response with this message. It means the agent never produced a successful processing stream.","triggerScenarios":"AgentCoordinator.Run fails immediately: missing/invalid API key for the selected provider, unknown model, request construction error, or ctx already cancelled when the goroutine runs.","commonSituations":"Missing ANTHROPIC_API_KEY/OPENAI_API_KEY in non-interactive (CI) environments; model override pointing at a provider with no credentials; rate/quota exhausted on first request; context deadline exceeded before the request started.","solutions":["Export the required provider API key in the environment","Verify the selected/overridden model matches a configured provider","Re-run with SLOG_LEVEL=debug to see the wrapped provider error","Check network/proxy access from CI to the provider endpoint"],"exampleFix":"// before\ncrush run \"task\" // provider key not set in CI\n// after\nexport ANTHROPIC_API_KEY=\"sk-ant-...\"\ncrush run \"task\"","handlingStrategy":"validation","validationCode":"if os.Getenv(\"ANTHROPIC_API_KEY\") == \"\" && os.Getenv(\"OPENAI_API_KEY\") == \"\" {\n\treturn errors.New(\"no provider API key set\")\n}\nif ctx.Err() != nil {\n\treturn fmt.Errorf(\"context already done: %w\", ctx.Err())\n}","typeGuard":null,"tryCatchPattern":"err := app.RunNonInteractive(ctx, w, prompt, \"\", \"\", true, \"\", false)\nif err != nil && strings.Contains(err.Error(), \"failed to start agent processing stream\") {\n\treturn fmt.Errorf(\"check provider credentials/model: %w\", err)\n}","preventionTips":["Export provider API keys in CI before running headless commands","Verify model/provider pairs resolve (`crush models`) before invoking","Never pass an already-cancelled or unbounded context without a timeout"],"tags":["go","llm-provider","streaming","authentication"],"backgroundTag":"llm-request-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}