charmbracelet/crush · error
failed to summarize session: status code %d
Error message
failed to summarize session: status code %d
What it means
Thrown by Client.AgentSummarizeSession when the server responded to POST /workspaces/{id}/agent/sessions/{sessionID}/summarize with a status code other than 200. The response body is not inspected, so any server-side failure (bad session id, agent not initialized, internal error, auth rejection) surfaces as this status-code error. Reached via AgentSummarize.
Source
Thrown at internal/client/proto.go:571
if rsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to get session agent info: status code %d", rsp.StatusCode)
}
var info proto.AgentSession
if err := json.NewDecoder(rsp.Body).Decode(&info); err != nil {
return nil, fmt.Errorf("failed to decode session agent info: %w", err)
}
return &info, nil
}
// AgentSummarizeSession requests a session summarization.
func (c *Client) AgentSummarizeSession(ctx context.Context, id string, sessionID string) error {
rsp, err := c.post(ctx, fmt.Sprintf("/workspaces/%s/agent/sessions/%s/summarize", id, sessionID), nil, nil, nil)
if err != nil {
return fmt.Errorf("failed to summarize session: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to summarize session: status code %d", rsp.StatusCode)
}
return nil
}
// InitiateAgentProcessing triggers agent initialization on the server.
func (c *Client) InitiateAgentProcessing(ctx context.Context, id string, interactive bool) error {
body := jsonBody(proto.AgentInitRequest{Interactive: interactive})
rsp, err := c.post(ctx, fmt.Sprintf("/workspaces/%s/agent/init", id), nil, body, http.Header{"Content-Type": []string{"application/json"}})
if err != nil {
return fmt.Errorf("failed to initiate session agent processing: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to initiate session agent processing: status code %d", rsp.StatusCode)
}
return nil
}
View on GitHub (pinned to 7944b8e522)
Solutions
- Log the actual rsp status on the server side or re-issue the request with curl to see the response body and identify the exact status.
- Verify the workspace id and sessionID are valid and the session still exists.
- Ensure the agent was initialized (InitiateAgentProcessing) before requesting summarization.
- Check authentication/token validity if the status is 401/403; check server logs if 500.
Example fix
// before: only the numeric status is known
if err := client.AgentSummarize(ctx, wsID, sessionID); err != nil {
return err
}
// after: validate session exists first and surface the status
sess, err := client.GetSession(ctx, wsID, sessionID)
if err != nil {
return fmt.Errorf("cannot summarize missing session: %w", err)
}
if err := client.AgentSummarize(ctx, wsID, sessionID); err != nil {
return fmt.Errorf("summarize failed for session %s (status in error): %w", sessionID, err)
} Defensive patterns
Strategy: validation
Validate before calling
// Validate ids before requesting summarization
if wsID == "" || sessionID == "" {
return errors.New("workspace and session ids are required")
}
if _, err := client.GetSession(ctx, wsID, sessionID); err != nil {
return fmt.Errorf("session %s not summarizable: %w", sessionID, err)
} Type guard
func isStatusCodeError(err error) bool {
return strings.Contains(err.Error(), "status code ")
}
func statusCodeOf(err error) int {
var code int
fmt.Sscanf(err.Error(), "failed to summarize session: status code %d", &code)
return code
} Try / catch
err := client.AgentSummarize(ctx, wsID, sessionID)
if err != nil {
switch statusCodeOf(err) {
case 401, 403:
return reauthAndRetry(ctx, wsID, sessionID)
case 404:
return ErrSessionNotFound
default:
return fmt.Errorf("summarize rejected by server: %w", err)
}
} Prevention
- Verify the session exists (GetSession) before summarizing
- Initialize the agent first (InitiateAgentProcessing) — summarization depends on agent state
- Refresh auth tokens proactively to avoid 401/403
- Capture server-side logs to map non-200 statuses to root causes
When it happens
Trigger: Calling AgentSummarizeSession with a sessionID that no longer exists (404), before the agent has been initialized (4xx/5xx), with an invalid workspace id, when the server lacks permission/auth for the operation (401/403), or when the server's summarization backend errors out (500).
Common situations: Client and server out of sync after the session was deleted elsewhere; API base URL misconfigured so the request hits the wrong route (404); auth token expired (401); server bug or overloaded LLM provider causing 500 during summarization.
Related errors
- request failed with status code: %d
- failed to initiate session agent processing: status code %d
- failed to get messages: status code %d
- unexpected status code: %d
- failed to refresh MCP tools: status code %d
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/21f092ea0cf3f557.
Report an issue: GitHub.