charmbracelet/crush · error
failed to get session agent queued prompts: status code %d
Error message
failed to get session agent queued prompts: status code %d
What it means
GetAgentSessionQueuedPrompts requires HTTP 200; any other status becomes this error carrying the numeric code. The server was reached but rejected the queued-prompts query.
Source
Thrown at internal/client/proto.go:434
return fmt.Errorf("failed to refresh MCP resources: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to refresh MCP resources: status code %d", rsp.StatusCode)
}
return nil
}
// GetAgentSessionQueuedPrompts retrieves the number of queued prompts for a
// session.
func (c *Client) GetAgentSessionQueuedPrompts(ctx context.Context, id string, sessionID string) (int, error) {
rsp, err := c.get(ctx, fmt.Sprintf("/workspaces/%s/agent/sessions/%s/prompts/queued", id, sessionID), nil, nil)
if err != nil {
return 0, fmt.Errorf("failed to get session agent queued prompts: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return 0, fmt.Errorf("failed to get session agent queued prompts: status code %d", rsp.StatusCode)
}
var count int
if err := json.NewDecoder(rsp.Body).Decode(&count); err != nil {
return 0, fmt.Errorf("failed to decode session agent queued prompts: %w", err)
}
return count, nil
}
// ClearAgentSessionQueuedPrompts clears the queued prompts for a session.
func (c *Client) ClearAgentSessionQueuedPrompts(ctx context.Context, id string, sessionID string) error {
rsp, err := c.post(ctx, fmt.Sprintf("/workspaces/%s/agent/sessions/%s/prompts/clear", id, sessionID), nil, nil, nil)
if err != nil {
return fmt.Errorf("failed to clear session agent queued prompts: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to clear session agent queued prompts: status code %d", rsp.StatusCode)
}View on GitHub (pinned to 7944b8e522)
Solutions
- Handle 404 by treating the session as gone and stopping polling
- Refresh authentication on 401/403
- Check server logs for 5xx details
- Retry transient 5xx with backoff
Defensive patterns
Strategy: try-catch
Validate before calling
if sessionID == "" { return errors.New("session ID required") }
// optionally check the session still exists via a session list call first Type guard
func statusCodeFrom(err error) int {
var code int
pattern := "failed to get session agent queued prompts: status code %d"
if _, e := fmt.Sscanf(err.Error(), pattern, &code); e == nil { return code }
return 0
} Try / catch
n, err := client.GetAgentSessionQueuedPrompts(ctx, wsID, sid)
if err != nil {
if statusCodeFrom(err) == http.StatusNotFound {
return 0, nil // session gone; stop polling
}
return 0, err
} Prevention
- Handle 404 as terminal for the polling loop
- Refresh tokens proactively during long agent runs
- Retry only 5xx with backoff
- Keep client/server versions in sync
When it happens
Trigger: GET returns 404 because the session ID no longer exists, 401/403 on expired auth, or 5xx from a server-side agent failure.
Common situations: Polling a session that was deleted concurrently; token expiry during a long agent run; agent endpoint disabled on the server.
Related errors
- failed to clear session agent queued prompts: status code %d
- unexpected status code: %d
- request failed with status code: %d
- failed to refresh MCP tools: status code %d
- failed to read MCP resource: status code %d
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/4081ec5de1cf4834.
Report an issue: GitHub.