You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ c := New(
67
67
```
68
68
69
69
### Error Hierarchy
70
-
`errors.go` defines `APIError` as the base struct with `StatusCode`, `Code`, `Message`, `Details`. Each HTTP status gets a wrapper type (`NotFoundError`, `RateLimitError`, etc.) that embeds `APIError`. All error types implement `Error()` and `Unwrap()` for `errors.Is`/`errors.As` compatibility:
70
+
`errors.go` defines `APIError` as the base struct with `StatusCode`, `Code`, `Message`, `Details`. Each HTTP status gets a wrapper type (`NotFoundError`, `RateLimitError`, etc.) that embeds `APIError`. Subtypes inherit `Error()`via embedding (only `RateLimitError` overrides it to append retry info) and implement`Unwrap()` for `errors.Is`/`errors.As` compatibility:
-**Do not change**: `APIError.Error()` format string — tests assert exact string output
146
146
-**Do not change**: JSON struct tags — they match the daemon's API contract
147
147
-**Do not change**: `Unwrap()` implementations — `errors.As` depends on them for type matching
148
-
-**Safe to extend**: add new error types by creating a struct embedding `APIError`, adding to `parseAPIError` switch, and implementing`Error()` +`Unwrap()`
148
+
-**Safe to extend**: add new error types by creating a struct embedding `APIError` (which promotes `Error()`), adding to `parseAPIError` switch, and implementing `Unwrap()`
149
149
-**Safe to extend**: add new client methods by following the `get()`/`post()` delegation pattern
150
150
-**When adding streaming endpoints**: follow `ChatStream` pattern — set `Accept: text/event-stream`, check status before wrapping in `newStreamReader`
151
151
-**Concurrency**: any new mutable state on `Agent` must be protected by `a.mu`
0 commit comments