{"record":{"id":"1c9990d9bc97ea23","repo":"charmbracelet/crush","slug":"failed-to-get-agent-status-w","errorCode":null,"errorMessage":"failed to get agent status: %w","messagePattern":"failed to get agent status: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/proto.go","lineNumber":460,"sourceCode":"\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}\n\tvar info proto.AgentInfo\n\tif err := json.NewDecoder(rsp.Body).Decode(&info); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode agent status: %w\", err)\n\t}\n\treturn &info, nil\n}\n\n// UpdateAgent triggers an agent model update on the server.\nfunc (c *Client) UpdateAgent(ctx context.Context, id string) error {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/agent/update\", id), nil, nil, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to update agent: %w\", err)\n\t}","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/proto.go#L442-L478","documentation":"GetAgentInfo GETs /workspaces/{id}/agent and wraps any c.get transport error with 'failed to get agent status'. This is the connectivity/path failure case; the original error is wrapped and retrievable. waitForAgent callers see this on every failed poll attempt.","triggerScenarios":"Calling GetAgentInfo when the server is down, the workspace ID is invalid, DNS/proxy fails, or the context is canceled while polling for agent readiness.","commonSituations":"waitForAgent retry loop during server startup when the endpoint is not yet listening; wrong port in client config; network flake.","solutions":["Wait and retry — during waitForAgent this is usually transient startup","Confirm the server address/port configuration","Check the workspace ID is correct","Inspect the wrapped cause for the specific transport error"],"exampleFix":"// before\ninfo, err := client.GetAgentInfo(ctx, wsID)\n// after\ninfo, err := client.GetAgentInfo(ctx, wsID)\nif err != nil {\n\tif ctx.Err() != nil { return nil, ctx.Err() }\n\ttime.Sleep(pollInterval) // transient during waitForAgent\n}","handlingStrategy":"retry","validationCode":"if wsID == \"\" { return errors.New(\"workspace ID required for GetAgentInfo\") }\nif err := ctx.Err(); err != nil { return err }","typeGuard":"func isAgentPollTransient(err error) bool {\n\tvar ne net.Error\n\treturn errors.As(err, &ne) || errors.Is(err, context.DeadlineExceeded)\n}","tryCatchPattern":"info, err := client.GetAgentInfo(ctx, wsID)\nif err != nil {\n\tif isAgentPollTransient(err) && attempts < maxAttempts {\n\t\ttime.Sleep(pollInterval)\n\t\tcontinue\n\t}\n\treturn nil, err\n}","preventionTips":["Use bounded retries with backoff in waitForAgent loops","Verify server address/port before polling","Check ctx cancellation to avoid retrying forever","Log the unwrapped cause once, not per retry"],"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"}