{"record":{"id":"e7225506b3057acd","repo":"charmbracelet/crush","slug":"failed-to-clear-session-agent-queued-prompts-w","errorCode":null,"errorMessage":"failed to clear session agent queued prompts: %w","messagePattern":"failed to clear session agent queued prompts: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/proto.go","lineNumber":447,"sourceCode":"\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to get session agent queued prompts: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn 0, fmt.Errorf(\"failed to get session agent queued prompts: status code %d\", rsp.StatusCode)\n\t}\n\tvar count int\n\tif err := json.NewDecoder(rsp.Body).Decode(&count); err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to decode session agent queued prompts: %w\", err)\n\t}\n\treturn count, nil\n}\n\n// ClearAgentSessionQueuedPrompts clears the queued prompts for a session.\nfunc (c *Client) ClearAgentSessionQueuedPrompts(ctx context.Context, id string, sessionID string) error {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/agent/sessions/%s/prompts/clear\", id, sessionID), nil, nil, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to clear session agent queued prompts: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"failed to clear session agent queued prompts: status code %d\", rsp.StatusCode)\n\t}\n\treturn nil\n}\n\n// GetAgentInfo retrieves the agent status for a workspace.\nfunc (c *Client) GetAgentInfo(ctx context.Context, id string) (*proto.AgentInfo, error) {\n\trsp, err := c.get(ctx, fmt.Sprintf(\"/workspaces/%s/agent\", id), nil, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get agent status: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif err := checkStatus(rsp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get agent status: %w\", err)\n\t}","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/proto.go#L429-L465","documentation":"ClearAgentSessionQueuedPrompts POSTs to /workspaces/{id}/agent/sessions/{sessionID}/prompts/clear and wraps any c.post transport error with this message. The request failed before a status could be checked; the underlying cause is wrapped.","triggerScenarios":"Calling ClearAgentSessionQueuedPrompts when the server is unreachable, the workspace/session IDs form an invalid path, the context is canceled, or the connection breaks mid-request.","commonSituations":"Attempting to clear the queue after the agent/server shut down; wrong session ID; transient network failure during AgentClearQueue.","solutions":["Confirm the server is running and the base URL is correct","Validate workspace and session IDs","Retry the clear operation once the connection is restored","Inspect errors.Unwrap output for the transport cause"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if wsID == \"\" || sessionID == \"\" { return errors.New(\"clear queue: workspace and session IDs required\") }\nif err := ctx.Err(); err != nil { return err }","typeGuard":"func isTransportFailure(err error) bool {\n\tvar ne net.Error\n\treturn errors.As(err, &ne) || errors.Is(err, context.Canceled)\n}","tryCatchPattern":"if err := client.ClearAgentSessionQueuedPrompts(ctx, wsID, sid); err != nil && isTransportFailure(err) {\n\t// safe to retry: idempotent clear\n}","preventionTips":["Treat clear as idempotent and retry on transport errors","Validate IDs before calls","Keep the connection alive for long sessions","Log the unwrapped cause for diagnosis"],"tags":["network","http-client","agent"],"backgroundTag":"http-request-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}