Commit f9fc8e0
authored
The TypeScript SDK's `SDKResultErrorSchema` defines `errors:
z.array(z.string())` on error result messages (subtypes:
`error_during_execution`, `error_max_turns`, `error_max_budget_usd`,
`error_max_structured_output_retries`). This array contains diagnostic
strings explaining why the CLI exited with an error.
The Python SDK's `ResultMessage` dataclass was missing this field, so
when the CLI emitted error results with an `errors` array, the data was
silently dropped. SDK users had no way to programmatically access error
diagnostics from non-zero CLI exits.
## Changes
- Add `errors: list[str] | None = None` to the `ResultMessage` dataclass
in `types.py`
- Extract the `errors` field from JSON in the message parser
(`message_parser.py`)
- Add regression tests verifying:
- Error result messages with `errors` array are correctly parsed
- Success result messages have `errors` defaulting to `None`
- The `errors` field defaults to `None` when absent (backward
compatible)
## Testing
All 45 message parser tests pass, including 2 new tests for this change.
1 parent dec0ecb commit f9fc8e0
3 files changed
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
| 918 | + | |
918 | 919 | | |
919 | 920 | | |
920 | 921 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
| 828 | + | |
828 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
0 commit comments