charmbracelet/crush · error

failed to clear session agent queued prompts: %w

Error message

failed to clear session agent queued prompts: %w

What it means

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.

Source

Thrown at internal/client/proto.go:447

	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)
	}
	return nil
}

// GetAgentInfo retrieves the agent status for a workspace.
func (c *Client) GetAgentInfo(ctx context.Context, id string) (*proto.AgentInfo, error) {
	rsp, err := c.get(ctx, fmt.Sprintf("/workspaces/%s/agent", id), nil, nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get agent status: %w", err)
	}
	defer rsp.Body.Close()
	if err := checkStatus(rsp); err != nil {
		return nil, fmt.Errorf("failed to get agent status: %w", err)
	}

View on GitHub (pinned to 7944b8e522)

Solutions

  1. Confirm the server is running and the base URL is correct
  2. Validate workspace and session IDs
  3. Retry the clear operation once the connection is restored
  4. Inspect errors.Unwrap output for the transport cause
Defensive patterns

Strategy: retry

Validate before calling

if wsID == "" || sessionID == "" { return errors.New("clear queue: workspace and session IDs required") }
if err := ctx.Err(); err != nil { return err }

Type guard

func isTransportFailure(err error) bool {
	var ne net.Error
	return errors.As(err, &ne) || errors.Is(err, context.Canceled)
}

Try / catch

if err := client.ClearAgentSessionQueuedPrompts(ctx, wsID, sid); err != nil && isTransportFailure(err) {
	// safe to retry: idempotent clear
}

Prevention

When it happens

Trigger: 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.

Common situations: Attempting to clear the queue after the agent/server shut down; wrong session ID; transient network failure during AgentClearQueue.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29). Data as JSON: /api/errors/e7225506b3057acd. Report an issue: GitHub.