responseErrorResult converts a codersdk.Response into a structured tool result. We return these via toolResponse rather than NewTextErrorResponse because the fantasy/chatprompt pipeline flattens IsError content into a single string and drops validation details.
(resp codersdk.Response)
| 41 | // NewTextErrorResponse because the fantasy/chatprompt pipeline flattens |
| 42 | // IsError content into a single string and drops validation details. |
| 43 | func responseErrorResult(resp codersdk.Response) map[string]any { |
| 44 | message := resp.Message |
| 45 | if message == "" { |
| 46 | message = "request failed" |
| 47 | } |
| 48 | |
| 49 | result := map[string]any{ |
| 50 | "error": message, |
| 51 | } |
| 52 | if resp.Detail != "" { |
| 53 | result["detail"] = resp.Detail |
| 54 | } |
| 55 | if len(resp.Validations) > 0 { |
| 56 | result["validations"] = resp.Validations |
| 57 | } |
| 58 | return result |
| 59 | } |
| 60 | |
| 61 | func latestWorkspaceBuildAndJob( |
| 62 | ctx context.Context, |
no outgoing calls
no test coverage detected