{"record":{"id":"912414a492046b5d","repo":"charmbracelet/crush","slug":"failed-to-get-session-agent-queued-prompts-w","errorCode":null,"errorMessage":"failed to get session agent queued prompts: %w","messagePattern":"failed to get session agent queued prompts: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/proto.go","lineNumber":430,"sourceCode":"\t\t\tName string `json:\"name\"`\n\t\t}{Name: name}),\n\t\thttp.Header{\"Content-Type\": []string{\"application/json\"}})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to refresh MCP resources: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"failed to refresh MCP resources: status code %d\", rsp.StatusCode)\n\t}\n\treturn nil\n}\n\n// GetAgentSessionQueuedPrompts retrieves the number of queued prompts for a\n// session.\nfunc (c *Client) GetAgentSessionQueuedPrompts(ctx context.Context, id string, sessionID string) (int, error) {\n\trsp, err := c.get(ctx, fmt.Sprintf(\"/workspaces/%s/agent/sessions/%s/prompts/queued\", id, sessionID), nil, nil)\n\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}","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/proto.go#L412-L448","documentation":"GetAgentSessionQueuedPrompts performs GET /workspaces/{id}/agent/sessions/{sessionID}/prompts/queued and wraps any transport error from c.get with this message. It fires when the request never completes successfully at the HTTP layer, with the cause wrapped for inspection.","triggerScenarios":"Calling GetAgentSessionQueuedPrompts with an unreachable server, malformed workspace or session ID producing a bad path, canceled context, or connection reset during c.get.","commonSituations":"Session already ended/cleaned up server-side while the client still polls; wrong workspace ID; network interruption in long-running polling loops (AgentQueuedPrompts).","solutions":["Verify server availability and base URL","Check both workspace ID and session ID are valid and URL-escaped","Stop polling once the session is known to be closed","Inspect the wrapped error for the transport root cause"],"exampleFix":"// before\nn, err := client.GetAgentSessionQueuedPrompts(ctx, wsID, sessionID)\n// after\nn, err := client.GetAgentSessionQueuedPrompts(ctx, url.PathEscape(wsID), url.PathEscape(sessionID))\nif err != nil {\n\treturn 0, fmt.Errorf(\"poll queue: %w\", err)\n}","handlingStrategy":"retry","validationCode":"if sessionID == \"\" || wsID == \"\" { return errors.New(\"workspace and session IDs required\") }\nif err := ctx.Err(); err != nil { return err }","typeGuard":"func isNetworkErr(err error) bool {\n\tvar ne net.Error\n\treturn errors.As(err, &ne) || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, context.DeadlineExceeded)\n}","tryCatchPattern":"n, err := client.GetAgentSessionQueuedPrompts(ctx, wsID, sid)\nif err != nil && isNetworkErr(err) {\n\ttime.Sleep(backoff)\n\treturn client.GetAgentSessionQueuedPrompts(ctx, wsID, sid)\n}","preventionTips":["Stop polling when the session is known to be closed","Use timeouts on polling contexts","Escape path parameters","Verify server health before entering poll loops"],"tags":["network","http-client","polling"],"backgroundTag":"http-request-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}