everruns-core 0.40.0

Transport-neutral agent execution contracts for Everruns
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
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
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ag-ui.com/spec/1.0/schema.json",
  "title": "AG-UI Protocol",
  "description": "The machine-readable contract for the AG-UI protocol. Validating a document against this file validates it as an AG-UI event; every other definition is addressable by its own anchor, so this file's own address followed by #RunAgentInput names the request body. Addresses are written relative to $id rather than spelled out, so a frozen copy of this file describes itself rather than the draft it came from. Field names are camelCase because this describes the wire format rather than any language's idiom. Objects are exact: this file defines what exists in this version of the protocol, so a property it does not declare fails validation. Compatibility with newer minor versions is a behavioural rule for receivers, who tolerate what they do not recognise rather than rejecting it; a validator has no way to express tolerance, so that rule lives in the prose specification. How events may be ordered and whether a patch applies to the state it targets are behavioural rules for the same reason. Exactness has three kinds of exception: the compositional fragments — BaseEvent, Attributable, BaseMessage — which are open in themselves because the definitions composing them close the whole shape; objects that are open by meaning, because arbitrary keys are their data rather than unrecognised fields — metadata, activity content, a carried JSON Schema — and the JSON Patch operations, which stay open because RFC 6902 requires members an operation does not define to be ignored rather than rejected.",
  "$ref": "#/$defs/Event",
  "$defs": {
    "Event": {
      "$anchor": "Event",
      "description": "Any AG-UI event. Every member is normative: there is no optional tier and no event a consumer may decline to implement. Discriminated by the type property.",
      "oneOf": [
        { "$ref": "#/$defs/TextMessageStartEvent" },
        { "$ref": "#/$defs/TextMessageContentEvent" },
        { "$ref": "#/$defs/TextMessageEndEvent" },
        { "$ref": "#/$defs/TextMessageChunkEvent" },
        { "$ref": "#/$defs/ToolCallStartEvent" },
        { "$ref": "#/$defs/ToolCallArgsEvent" },
        { "$ref": "#/$defs/ToolCallEndEvent" },
        { "$ref": "#/$defs/ToolCallChunkEvent" },
        { "$ref": "#/$defs/ToolCallResultEvent" },
        { "$ref": "#/$defs/StateSnapshotEvent" },
        { "$ref": "#/$defs/StateDeltaEvent" },
        { "$ref": "#/$defs/MessagesSnapshotEvent" },
        { "$ref": "#/$defs/ActivitySnapshotEvent" },
        { "$ref": "#/$defs/ActivityDeltaEvent" },
        { "$ref": "#/$defs/RawEvent" },
        { "$ref": "#/$defs/CustomEvent" },
        { "$ref": "#/$defs/RunStartedEvent" },
        { "$ref": "#/$defs/RunFinishedEvent" },
        { "$ref": "#/$defs/RunErrorEvent" },
        { "$ref": "#/$defs/StepStartedEvent" },
        { "$ref": "#/$defs/StepFinishedEvent" },
        { "$ref": "#/$defs/ReasoningStartEvent" },
        { "$ref": "#/$defs/ReasoningMessageStartEvent" },
        { "$ref": "#/$defs/ReasoningMessageContentEvent" },
        { "$ref": "#/$defs/ReasoningMessageEndEvent" },
        { "$ref": "#/$defs/ReasoningMessageChunkEvent" },
        { "$ref": "#/$defs/ReasoningEndEvent" },
        { "$ref": "#/$defs/ReasoningEncryptedValueEvent" },
        { "$ref": "#/$defs/SubagentStartedEvent" },
        { "$ref": "#/$defs/SubagentFinishedEvent" },
        { "$ref": "#/$defs/SubagentErrorEvent" }
      ]
    },
    "EventType": {
      "$anchor": "EventType",
      "type": "string",
      "description": "The discriminator carried by every event.",
      "enum": [
        "TEXT_MESSAGE_START",
        "TEXT_MESSAGE_CONTENT",
        "TEXT_MESSAGE_END",
        "TEXT_MESSAGE_CHUNK",
        "TOOL_CALL_START",
        "TOOL_CALL_ARGS",
        "TOOL_CALL_END",
        "TOOL_CALL_CHUNK",
        "TOOL_CALL_RESULT",
        "STATE_SNAPSHOT",
        "STATE_DELTA",
        "MESSAGES_SNAPSHOT",
        "ACTIVITY_SNAPSHOT",
        "ACTIVITY_DELTA",
        "RAW",
        "CUSTOM",
        "RUN_STARTED",
        "RUN_FINISHED",
        "RUN_ERROR",
        "STEP_STARTED",
        "STEP_FINISHED",
        "REASONING_START",
        "REASONING_MESSAGE_START",
        "REASONING_MESSAGE_CONTENT",
        "REASONING_MESSAGE_END",
        "REASONING_MESSAGE_CHUNK",
        "REASONING_END",
        "REASONING_ENCRYPTED_VALUE",
        "SUBAGENT_STARTED",
        "SUBAGENT_FINISHED",
        "SUBAGENT_ERROR"
      ]
    },
    "BaseEvent": {
      "$anchor": "BaseEvent",
      "type": "object",
      "description": "The fields every event carries, whatever its type. Composed into each event definition rather than repeated, so a change here reaches every event at once.",
      "properties": {
        "type": {
          "$ref": "#/$defs/EventType",
          "description": "Which event this is. Each event definition narrows this to a single value."
        },
        "timestamp": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "When the event was created. Bounded to the range JSON numbers survive a round trip in, so the value a consumer reads is the value the producer wrote. Deliberately not a float. The unit is not constrained here, because it never has been stated normatively; every SDK that sets it in practice uses milliseconds since the Unix epoch, and a producer choosing another unit will be misread by consumers even though it validates. Nothing in the protocol computes with this value."
        },
        "rawEvent": {
          "not": { "type": "null" },
          "description": "The provider-native event this one was translated from, carried verbatim for debugging and for consumers that need detail the protocol does not model. Any JSON value."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this event."
        }
      },
      "required": ["type"]
    },
    "Attributable": {
      "$anchor": "Attributable",
      "type": "object",
      "description": "Composed into everything that can belong to a subagent's work: the events that describe content or progress, the message types, and each interrupt. Run-scoped events omit it — RUN_STARTED, RUN_FINISHED and RUN_ERROR describe the run itself and MESSAGES_SNAPSHOT is conversation-wide, so none of them can belong to one subagent. A tool call omits it too and inherits its containing message's attribution.",
      "properties": {
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The subagent invocation this belongs to. Absent means the parent agent produced it directly."
        }
      }
    },
    "SubagentRunId": {
      "$anchor": "SubagentRunId",
      "type": "string",
      "description": "An opaque handle for one subagent invocation, not a reusable name for a subagent definition: two invocations of the same subagent carry two different values. Named to mirror runId one level down, the way the subagent's name mirrors agentId."
    },
    "Metadata": {
      "$anchor": "Metadata",
      "type": "object",
      "description": "Extra information attached to an event, a message, a tool call, a tool, an interrupt or a resume entry. Open by key: any JSON value is allowed under a key, including null, because a null there is meaningful data. The object itself may be absent but is never null when present. The key ag-ui is reserved for the protocol's own use; reservation is by convention, since validating the shape of a key's value would contradict being open by key.",
      "additionalProperties": true
    },
    "State": {
      "$anchor": "State",
      "description": "Agent state. Any JSON value: the protocol carries state without interpreting it, so an object, an array, a string and a number are all valid."
    },
    "TextMessageRole": {
      "$anchor": "TextMessageRole",
      "type": "string",
      "description": "The roles a streamed text message may take. Excludes tool, which is carried by TOOL_CALL_RESULT rather than streamed as text.",
      "enum": ["developer", "system", "assistant", "user"]
    },
    "Role": {
      "$anchor": "Role",
      "type": "string",
      "description": "Every role a materialised message may have.",
      "enum": [
        "developer",
        "system",
        "assistant",
        "user",
        "tool",
        "activity",
        "reasoning"
      ]
    },
    "TextMessageStartEvent": {
      "$anchor": "TextMessageStartEvent",
      "type": "object",
      "description": "Opens a streamed text message. The content arrives as TEXT_MESSAGE_CONTENT events and the message closes with TEXT_MESSAGE_END.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_START" },
        "messageId": {
          "type": "string",
          "description": "Identifies the message this stream builds, and ties the later content and end events to it."
        },
        "role": {
          "$ref": "#/$defs/TextMessageRole",
          "default": "assistant",
          "description": "Who the message is from. An absent role means assistant; that meaning is normative and stated in the prose, because a validator treats a default as documentation rather than as behaviour."
        },
        "name": {
          "type": "string",
          "description": "An optional display name for the author, for providers that distinguish several participants in one role."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "TextMessageContentEvent": {
      "$anchor": "TextMessageContentEvent",
      "type": "object",
      "description": "Appends a fragment to a streamed text message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_CONTENT" },
        "messageId": {
          "type": "string",
          "description": "The message this fragment belongs to."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string: providers emit empty deltas as keep-alives and while a tool call is being decided, and rejecting them would kill runs that are working correctly."
        }
      },
      "required": ["type", "messageId", "delta"],
      "unevaluatedProperties": false
    },
    "TextMessageEndEvent": {
      "$anchor": "TextMessageEndEvent",
      "type": "object",
      "description": "Closes a streamed text message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_END" },
        "messageId": {
          "type": "string",
          "description": "The message being closed."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "TextMessageChunkEvent": {
      "$anchor": "TextMessageChunkEvent",
      "type": "object",
      "description": "A shorthand that stands in for a start, content and end sequence, for producers that cannot know in advance where a message begins. Every field is optional because a continuation chunk omits what has not changed; which message a field-less chunk continues is a sequence question the prose specification answers.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_CHUNK" },
        "messageId": {
          "type": "string",
          "description": "The message this chunk belongs to. Absent continues the message already open."
        },
        "role": {
          "$ref": "#/$defs/TextMessageRole",
          "description": "Who the message is from, on the chunk that opens it."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string."
        },
        "name": {
          "type": "string",
          "description": "An optional display name for the author."
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "ToolCallStartEvent": {
      "$anchor": "ToolCallStartEvent",
      "type": "object",
      "description": "Opens a tool call. The arguments arrive as TOOL_CALL_ARGS events and the call closes with TOOL_CALL_END.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_START" },
        "toolCallId": {
          "type": "string",
          "description": "Identifies the call, and ties the later args, end and result events to it."
        },
        "toolCallName": {
          "type": "string",
          "description": "Which tool is being called."
        },
        "parentMessageId": {
          "type": "string",
          "description": "The assistant message that holds this call. Absent means the producer did not attribute it to one."
        }
      },
      "required": ["type", "toolCallId", "toolCallName"],
      "unevaluatedProperties": false
    },
    "ToolCallArgsEvent": {
      "$anchor": "ToolCallArgsEvent",
      "type": "object",
      "description": "Appends a fragment of a tool call's arguments.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_ARGS" },
        "toolCallId": {
          "type": "string",
          "description": "The call these arguments belong to."
        },
        "delta": {
          "type": "string",
          "description": "A fragment of the arguments, which concatenate into the call's argument text — conventionally a JSON document, though the protocol does not validate it (see FunctionCall.arguments). Deliberately a string rather than parsed JSON: a fragment is not itself a document. May be the empty string."
        }
      },
      "required": ["type", "toolCallId", "delta"],
      "unevaluatedProperties": false
    },
    "ToolCallEndEvent": {
      "$anchor": "ToolCallEndEvent",
      "type": "object",
      "description": "Closes a tool call, meaning its arguments are complete.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_END" },
        "toolCallId": {
          "type": "string",
          "description": "The call being closed."
        }
      },
      "required": ["type", "toolCallId"],
      "unevaluatedProperties": false
    },
    "ToolCallChunkEvent": {
      "$anchor": "ToolCallChunkEvent",
      "type": "object",
      "description": "A shorthand that stands in for a tool call's start, args and end sequence. Every field is optional for the same reason as TEXT_MESSAGE_CHUNK.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_CHUNK" },
        "toolCallId": {
          "type": "string",
          "description": "The call this chunk belongs to. Absent continues the call already open."
        },
        "toolCallName": {
          "type": "string",
          "description": "Which tool is being called, on the chunk that opens it."
        },
        "parentMessageId": {
          "type": "string",
          "description": "The assistant message that holds this call."
        },
        "delta": {
          "type": "string",
          "description": "A fragment of the arguments. May be the empty string."
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "ToolCallResultEvent": {
      "$anchor": "ToolCallResultEvent",
      "type": "object",
      "description": "Carries what a tool returned. Mints a tool message rather than appending to an existing one, which is why it has its own messageId.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_RESULT" },
        "messageId": {
          "type": "string",
          "description": "The tool message this result becomes."
        },
        "toolCallId": {
          "type": "string",
          "description": "The call being answered."
        },
        "content": {
          "description": "What the tool returned: either plain text, or an ordered list of parts, exactly as on the tool message this event mints. A tool returning structured data serialises it into text; media travel as parts of their own.",
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "$ref": "#/$defs/ContentPart" } }
          ]
        },
        "role": {
          "const": "tool",
          "description": "Present only for symmetry with the message it mints; the value is fixed, so a producer may leave it out."
        }
      },
      "required": ["type", "messageId", "toolCallId", "content"],
      "unevaluatedProperties": false
    },
    "StateSnapshotEvent": {
      "$anchor": "StateSnapshotEvent",
      "type": "object",
      "description": "Replaces the agent state wholesale. Sent when a delta cannot express the change, or to resynchronise a consumer.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STATE_SNAPSHOT" },
        "snapshot": {
          "$ref": "#/$defs/State",
          "description": "The complete new state."
        }
      },
      "required": ["type", "snapshot"],
      "unevaluatedProperties": false
    },
    "StateDeltaEvent": {
      "$anchor": "StateDeltaEvent",
      "type": "object",
      "description": "Changes the agent state incrementally.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STATE_DELTA" },
        "delta": {
          "$ref": "#/$defs/JsonPatch",
          "description": "The change, as an RFC 6902 patch against the current state. Structural validity here does not mean the patch applies: a well-formed operation may point at a path that does not exist, which RFC 6902 leaves to the applier."
        }
      },
      "required": ["type", "delta"],
      "unevaluatedProperties": false
    },
    "MessagesSnapshotEvent": {
      "$anchor": "MessagesSnapshotEvent",
      "type": "object",
      "description": "The complete set of messages the producer owns, in order. Conversation-wide rather than a plain overwrite: a consumer may keep messages of its own that no producer tracks, so exactly how a snapshot reconciles with those is behavioural and belongs in the prose. Being conversation-wide it cannot belong to a single subagent, so it carries no attribution; it does establish which subagent owns each message it contains, through the messages themselves.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "MESSAGES_SNAPSHOT" },
        "messages": {
          "type": "array",
          "description": "The messages the producer is declaring, in order.",
          "items": { "$ref": "#/$defs/Message" }
        }
      },
      "required": ["type", "messages"],
      "unevaluatedProperties": false
    },
    "ActivitySnapshotEvent": {
      "$anchor": "ActivitySnapshotEvent",
      "type": "object",
      "description": "Reports structured progress that is not conversation content, such as a step a UI renders as its own widget.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "ACTIVITY_SNAPSHOT" },
        "messageId": {
          "type": "string",
          "description": "The activity message this describes."
        },
        "activityType": {
          "type": "string",
          "description": "What kind of activity this is. An open string: the set is the producer's, not the protocol's."
        },
        "content": {
          "type": "object",
          "description": "The activity's payload, open by key.",
          "additionalProperties": true
        },
        "replace": {
          "type": "boolean",
          "default": true,
          "description": "Whether this snapshot overwrites the activity's existing content. Absent means it does, and that meaning is normative; only an explicit false asks a consumer to leave what is already there. It does not ask for a merge — ACTIVITY_DELTA is how content is changed incrementally. What a consumer does with a non-overwriting snapshot is behavioural and belongs in the prose."
        }
      },
      "required": ["type", "messageId", "activityType", "content"],
      "unevaluatedProperties": false
    },
    "ActivityDeltaEvent": {
      "$anchor": "ActivityDeltaEvent",
      "type": "object",
      "description": "Changes an activity message's content incrementally.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "ACTIVITY_DELTA" },
        "messageId": {
          "type": "string",
          "description": "The activity message being changed."
        },
        "activityType": {
          "type": "string",
          "description": "What kind of activity this is."
        },
        "patch": {
          "$ref": "#/$defs/JsonPatch",
          "description": "The change, as an RFC 6902 patch against the activity's content."
        }
      },
      "required": ["type", "messageId", "activityType", "patch"],
      "unevaluatedProperties": false
    },
    "RawEvent": {
      "$anchor": "RawEvent",
      "type": "object",
      "description": "Passes a provider-native event through untranslated, for consumers that need detail the protocol does not model.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "RAW" },
        "event": {
          "description": "The provider's own event. Any JSON value, and required: an event whose only purpose is to carry this would say nothing without it."
        },
        "source": {
          "type": "string",
          "description": "Which provider or framework the event came from."
        }
      },
      "required": ["type", "event"],
      "unevaluatedProperties": false
    },
    "CustomEvent": {
      "$anchor": "CustomEvent",
      "type": "object",
      "description": "The protocol's extension point for an application's own events. Anything a consumer does with one is outside the protocol.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "CUSTOM" },
        "name": {
          "type": "string",
          "description": "What this custom event is. Required: without it a consumer cannot route the value."
        },
        "value": { "description": "The payload. Any JSON value, and required." }
      },
      "required": ["type", "name", "value"],
      "unevaluatedProperties": false
    },
    "RunStartedEvent": {
      "$anchor": "RunStartedEvent",
      "type": "object",
      "description": "Opens a run. Run-scoped, so it carries no subagent attribution.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "RUN_STARTED" },
        "threadId": {
          "type": "string",
          "description": "The conversation this run belongs to."
        },
        "runId": { "type": "string", "description": "Identifies this run." },
        "protocolVersion": {
          "type": "string",
          "description": "The protocol version this producer speaks, such as \"1.0\" — the producer's own version, not an echo of the input's, which is what makes the pair a negotiation: each side declares itself and the consumer sees a downgrade the moment it happens. Absent means a producer from before the protocol carried a version."
        },
        "parentRunId": {
          "type": "string",
          "description": "The run that spawned this one, when an agent invokes another agent as a separate run rather than as a subagent within one."
        },
        "input": {
          "$ref": "#/$defs/RunAgentInput",
          "description": "The request this run was started from, echoed back so a consumer that did not make the request can still see what the agent was asked."
        }
      },
      "required": ["type", "threadId", "runId"],
      "unevaluatedProperties": false
    },
    "RunFinishedEvent": {
      "$anchor": "RunFinishedEvent",
      "type": "object",
      "description": "Closes a run that did not fail. Run-scoped, so it carries no subagent attribution.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "RUN_FINISHED" },
        "threadId": {
          "type": "string",
          "description": "The conversation this run belongs to."
        },
        "runId": { "type": "string", "description": "The run being closed." },
        "result": {
          "not": { "type": "null" },
          "description": "The run's return value, if it has one. Any JSON value."
        },
        "outcome": {
          "$ref": "#/$defs/RunFinishedOutcome",
          "description": "Why the run ended. Absent means success, so every producer written before outcomes existed is already conformant."
        },
        "usage": {
          "type": "array",
          "description": "Token usage for the run, one entry per provider and model, so a run that invoked several models keeps them separate. A consumer that only wants totals sums across the entries. The run is the accounting boundary: usage covers every model call made within the run, calls made by its subagents included; an agent invoked as a separate run under parentRunId reports its own usage on its own terminal event; and a run that resumes an interrupted one reports only the calls it made itself, not the interrupted run's.",
          "items": { "$ref": "#/$defs/TokenUsage" }
        }
      },
      "required": ["type", "threadId", "runId"],
      "unevaluatedProperties": false
    },
    "RunErrorEvent": {
      "$anchor": "RunErrorEvent",
      "type": "object",
      "description": "Ends a run that failed. Run-scoped, so it carries no subagent attribution; a subagent that fails without ending the run reports SUBAGENT_ERROR instead.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "RUN_ERROR" },
        "message": {
          "type": "string",
          "description": "What went wrong, for a person to read."
        },
        "code": {
          "type": "string",
          "description": "A machine-readable error code. An open string: the protocol defines no vocabulary."
        },
        "usage": {
          "type": "array",
          "description": "Token usage accrued before the failure, for a run that completed one or more model calls before dying. Scoped as on RUN_FINISHED: the run's own calls, subagents included.",
          "items": { "$ref": "#/$defs/TokenUsage" }
        }
      },
      "required": ["type", "message"],
      "unevaluatedProperties": false
    },
    "StepStartedEvent": {
      "$anchor": "StepStartedEvent",
      "type": "object",
      "description": "Opens a named step within a run, for producers whose frameworks have a step concept worth surfacing.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STEP_STARTED" },
        "stepName": {
          "type": "string",
          "description": "The step's name. Identifies it: the matching STEP_FINISHED carries the same name."
        }
      },
      "required": ["type", "stepName"],
      "unevaluatedProperties": false
    },
    "StepFinishedEvent": {
      "$anchor": "StepFinishedEvent",
      "type": "object",
      "description": "Closes a named step.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STEP_FINISHED" },
        "stepName": {
          "type": "string",
          "description": "The step being closed."
        }
      },
      "required": ["type", "stepName"],
      "unevaluatedProperties": false
    },
    "ReasoningStartEvent": {
      "$anchor": "ReasoningStartEvent",
      "type": "object",
      "description": "Opens a span of reasoning. A span may contain several reasoning messages.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_START" },
        "messageId": {
          "type": "string",
          "description": "The span being opened."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageStartEvent": {
      "$anchor": "ReasoningMessageStartEvent",
      "type": "object",
      "description": "Opens a streamed reasoning message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_START" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message this stream builds."
        },
        "role": {
          "const": "reasoning",
          "description": "Fixed, and required rather than defaulted. The requirement is inherited from the SDKs rather than chosen."
        }
      },
      "required": ["type", "messageId", "role"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageContentEvent": {
      "$anchor": "ReasoningMessageContentEvent",
      "type": "object",
      "description": "Appends a fragment to a streamed reasoning message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_CONTENT" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message this fragment belongs to."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string."
        }
      },
      "required": ["type", "messageId", "delta"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageEndEvent": {
      "$anchor": "ReasoningMessageEndEvent",
      "type": "object",
      "description": "Closes a streamed reasoning message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_END" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message being closed."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageChunkEvent": {
      "$anchor": "ReasoningMessageChunkEvent",
      "type": "object",
      "description": "A shorthand that stands in for a reasoning message's start, content and end sequence.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_CHUNK" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message this chunk belongs to. Absent continues the one already open."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string."
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "ReasoningEndEvent": {
      "$anchor": "ReasoningEndEvent",
      "type": "object",
      "description": "Closes a span of reasoning.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_END" },
        "messageId": {
          "type": "string",
          "description": "The span being closed."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "ReasoningEncryptedValueEvent": {
      "$anchor": "ReasoningEncryptedValueEvent",
      "type": "object",
      "description": "Carries a provider's opaque, encrypted reasoning artefact, which a consumer stores and returns on a later turn without being able to read it.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_ENCRYPTED_VALUE" },
        "subtype": {
          "$ref": "#/$defs/ReasoningEncryptedValueSubtype",
          "description": "What kind of thing entityId names, which decides where the value is stored."
        },
        "entityId": {
          "type": "string",
          "description": "What the value belongs to: a message id or a tool call id, according to subtype."
        },
        "encryptedValue": {
          "type": "string",
          "description": "The provider's opaque artefact."
        }
      },
      "required": ["type", "subtype", "entityId", "encryptedValue"],
      "unevaluatedProperties": false
    },
    "ReasoningEncryptedValueSubtype": {
      "$anchor": "ReasoningEncryptedValueSubtype",
      "type": "string",
      "description": "Whether a REASONING_ENCRYPTED_VALUE belongs to a message or to a tool call.",
      "enum": ["tool-call", "message"]
    },
    "SubagentStartedEvent": {
      "$anchor": "SubagentStartedEvent",
      "type": "object",
      "description": "Announces that a subagent invocation has begun. Everything the subagent produces afterwards is attributed by carrying its subagentRunId, so a consumer can group the work without replaying the stream. Composed from BaseEvent alone rather than Attributable, because here subagentRunId identifies the subagent rather than attributing the event to one; attribution to an enclosing subagent is parentSubagentRunId.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "SUBAGENT_STARTED" },
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The invocation being announced."
        },
        "name": {
          "type": "string",
          "description": "The subagent's name, which is reusable across invocations, unlike subagentRunId."
        },
        "description": {
          "type": "string",
          "description": "What this subagent is for, for a consumer to display."
        },
        "parentSubagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The subagent invocation that spawned this one, for nested delegation. Absent means the parent agent spawned it directly."
        },
        "parentToolCallId": {
          "type": "string",
          "description": "The tool call that spawned this subagent, for the pattern where agents are exposed to a model as tools. Lets a consumer tie the subagent to the call without reading rawEvent."
        },
        "parentMessageId": {
          "type": "string",
          "description": "The message that held the spawning tool call."
        }
      },
      "required": ["type", "subagentRunId", "name"],
      "unevaluatedProperties": false
    },
    "SubagentFinishedEvent": {
      "$anchor": "SubagentFinishedEvent",
      "type": "object",
      "description": "Ends a subagent invocation's segment of this run, either because the work completed or because it is suspended awaiting outside input.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "SUBAGENT_FINISHED" },
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The invocation being closed."
        },
        "result": {
          "not": { "type": "null" },
          "description": "The subagent's return value, if it has one. Any JSON value, mirroring RUN_FINISHED.result."
        },
        "outcome": {
          "$ref": "#/$defs/SubagentFinishedOutcome",
          "description": "Why the segment ended. Absent means success. A suspended subagent is neither a success nor a failure, which is why saying so needs its own value rather than being inferred from a later interrupt."
        }
      },
      "required": ["type", "subagentRunId"],
      "unevaluatedProperties": false
    },
    "SubagentErrorEvent": {
      "$anchor": "SubagentErrorEvent",
      "type": "object",
      "description": "Reports that a subagent invocation failed. The run may continue: a parent agent is free to handle a failed subagent, which is why this is not RUN_ERROR.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "SUBAGENT_ERROR" },
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The invocation that failed."
        },
        "message": {
          "type": "string",
          "description": "What went wrong, for a person to read."
        },
        "code": {
          "type": "string",
          "description": "A machine-readable error code. An open string."
        }
      },
      "required": ["type", "subagentRunId", "message"],
      "unevaluatedProperties": false
    },
    "RunFinishedOutcome": {
      "$anchor": "RunFinishedOutcome",
      "description": "Why a run ended.",
      "oneOf": [
        { "$ref": "#/$defs/RunFinishedSuccessOutcome" },
        { "$ref": "#/$defs/RunFinishedInterruptOutcome" },
        { "$ref": "#/$defs/RunFinishedCancelledOutcome" }
      ]
    },
    "RunFinishedSuccessOutcome": {
      "$anchor": "RunFinishedSuccessOutcome",
      "type": "object",
      "description": "The run completed. Equivalent to an absent outcome. Closed like every other object, which is also what keeps it from carrying the suspended sibling's interrupts — a success with an interrupt still pending would be a contradiction, not an extension. A completed run may still have left frontend tool calls for the application to answer; pendingToolCallIds names them.",
      "properties": {
        "type": { "const": "success", "description": "Discriminator." },
        "pendingToolCallIds": {
          "type": "array",
          "description": "The tool calls this run started and left unanswered — no TOOL_CALL_RESULT in the run — for the application to answer in the next input's messages, in the order they were made. Absent or empty means the producer named none, and a consumer derives the list from the stream; otherwise it is the list, and it agrees with the stream. On the success outcome rather than the event because a run that stopped on a frontend tool call is a completed run: whether the application continues the thread is its own decision, so the producer reports what it knows and no more.",
          "items": {
            "type": "string",
            "description": "A tool call id, as carried by TOOL_CALL_START."
          }
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "RunFinishedInterruptOutcome": {
      "$anchor": "RunFinishedInterruptOutcome",
      "type": "object",
      "description": "The run is paused, waiting for something outside it. Resuming means starting a new run whose resume entries answer these interrupts.",
      "properties": {
        "type": { "const": "interrupt", "description": "Discriminator." },
        "interrupts": {
          "type": "array",
          "description": "What the run is waiting for. At least one: an interrupt outcome with nothing to answer would leave a consumer with nothing to do.",
          "minItems": 1,
          "items": { "$ref": "#/$defs/Interrupt" }
        }
      },
      "required": ["type", "interrupts"],
      "unevaluatedProperties": false
    },
    "RunFinishedCancelledOutcome": {
      "$anchor": "RunFinishedCancelledOutcome",
      "type": "object",
      "description": "The run was stopped before it completed, by whoever was running it, and did not fail. Neither success nor interrupt: nothing was produced as a result, and nothing is waited for, so the next run on the thread is an ordinary new run rather than a resume. Closed like its siblings: a cancelled run has no interrupts to carry. Named in the schema before 1.0 because an outcome a consumer does not recognise is stripped and read as success — a cancellation added later would reach every 1.0 consumer as a completed run.",
      "properties": {
        "type": { "const": "cancelled", "description": "Discriminator." }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "SubagentFinishedOutcome": {
      "$anchor": "SubagentFinishedOutcome",
      "description": "Why a subagent's segment of a run ended. Mirrors RunFinishedOutcome one level down.",
      "oneOf": [
        { "$ref": "#/$defs/SubagentFinishedSuccessOutcome" },
        { "$ref": "#/$defs/SubagentFinishedSuspendedOutcome" }
      ]
    },
    "SubagentFinishedSuccessOutcome": {
      "$anchor": "SubagentFinishedSuccessOutcome",
      "type": "object",
      "description": "The subagent completed its work. Equivalent to an absent outcome.",
      "properties": {
        "type": { "const": "success", "description": "Discriminator." }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "SubagentFinishedSuspendedOutcome": {
      "$anchor": "SubagentFinishedSuspendedOutcome",
      "type": "object",
      "description": "The subagent is paused awaiting outside input. Terminal for this stream, not for the subagent: a later run may continue the same invocation once the interrupts are answered.",
      "properties": {
        "type": { "const": "suspended", "description": "Discriminator." },
        "interruptIds": {
          "type": "array",
          "description": "The run-level interrupts this subagent raised itself. May be empty or absent: a subagent suspended because a descendant interrupted owns no interrupt of its own.",
          "items": { "type": "string", "description": "An Interrupt.id." }
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "Interrupt": {
      "$anchor": "Interrupt",
      "type": "object",
      "description": "Something a run needs from outside before it can continue, such as an approval or a missing value.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": {
          "type": "string",
          "description": "Identifies the interrupt. A resume entry answers it by this id."
        },
        "reason": {
          "type": "string",
          "description": "Why the run stopped. An open string rather than an enumeration: the protocol does not attempt to classify every reason an agent might need input."
        },
        "message": {
          "type": "string",
          "description": "A human-readable prompt for whoever answers."
        },
        "toolCallId": {
          "type": "string",
          "description": "The tool call this interrupt concerns, when it is a tool approval."
        },
        "responseSchema": {
          "type": "object",
          "description": "A JSON Schema describing the answer this interrupt expects, so a consumer can build a form for it. Carried opaquely: the protocol does not constrain or validate it. Restricted to an object because TypeScript and Python both declare it that way; .NET holds it as any JSON, and the ticket that commissioned this schema lists it among the arbitrary-JSON fields. Following the two that constrain it keeps the schema from accepting documents the reference client rejects, at the cost of rejecting the boolean schemas JSON Schema also permits — a bare true for \"any answer\". Recorded as a known divergence rather than settled.",
          "additionalProperties": true
        },
        "expiresAt": {
          "type": "string",
          "description": "When the interrupt stops being answerable. Deliberately unconstrained rather than a date-time format, because producers already disagree about the representation and tightening it here would reject streams that work today. The documented convention is ISO 8601, and a consumer comparing this value will parse it as a date, so a value that is not one leaves the interrupt looking permanently unexpired."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this interrupt."
        }
      },
      "required": ["id", "reason"],
      "unevaluatedProperties": false
    },
    "ResumeEntry": {
      "$anchor": "ResumeEntry",
      "type": "object",
      "description": "An answer to one interrupt, sent on the run that continues from it.",
      "properties": {
        "interruptId": {
          "type": "string",
          "description": "The interrupt being answered."
        },
        "status": {
          "type": "string",
          "description": "Whether the interrupt was answered or abandoned.",
          "enum": ["resolved", "cancelled"]
        },
        "payload": {
          "not": { "type": "null" },
          "description": "The answer the agent asked for and will act on. Any JSON value."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Envelope information about the response, such as signatures or routing keys, as opposed to payload, which is the answer itself."
        }
      },
      "required": ["interruptId", "status"],
      "unevaluatedProperties": false
    },
    "TokenUsage": {
      "$anchor": "TokenUsage",
      "type": "object",
      "description": "Token counts for one provider and model, in the protocol's own accounting: every count is either a total or a named part of one, so entries from different providers add up without double-counting. inputTokens and outputTokens are the totals; reasoningTokens, cachedInputTokens and cacheWriteInputTokens are parts of them, never additions to them; totalTokens is the two totals summed. Every field is a label or a number — nothing content-bearing or identifying, no prompts, completions, messages, or thread, run and user identifiers.",
      "properties": {
        "provider": {
          "type": "string",
          "description": "Which provider served the request."
        },
        "model": {
          "type": "string",
          "description": "Which model served the request."
        },
        "inputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Every prompt token the call was charged for: tokens read from a provider cache, tokens written to one, and audio or other non-text input all count here. cachedInputTokens and cacheWriteInputTokens break this number down and are never added to it — a provider that reports its cache counts beside a smaller input count has them added in by the producer before the entry leaves. Bounded like timestamp and for the same reason: a count above the JSON safe-integer range does not survive a round trip, so a consumer would silently read a different number than the producer wrote."
        },
        "outputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Every generated token, reasoning included where the provider distinguishes it. reasoningTokens breaks this number down and is never added to it — a provider that reports reasoning tokens beside a smaller completion count has them added in by the producer."
        },
        "totalTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "inputTokens plus outputTokens, under the accounting above. A producer MAY compute it rather than copy a provider's total, and copies a provider's total only when that total counts the same way, so a consumer can read this field as the sum of the other two."
        },
        "reasoningTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Output tokens spent on reasoning, where the provider distinguishes them. Part of outputTokens, not in addition to it."
        },
        "cachedInputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Input tokens read from a provider cache. Part of inputTokens, not in addition to it, and disjoint from cacheWriteInputTokens."
        },
        "cacheWriteInputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Input tokens written to a provider cache on this call, where the provider distinguishes them. Part of inputTokens, not in addition to it, and disjoint from cachedInputTokens. Its own field because providers price a cache write differently from a cache read, so a consumer computing cost cannot do without it."
        }
      },
      "unevaluatedProperties": false
    },
    "Message": {
      "$anchor": "Message",
      "description": "Any message in a conversation. Discriminated by role.",
      "oneOf": [
        { "$ref": "#/$defs/DeveloperMessage" },
        { "$ref": "#/$defs/SystemMessage" },
        { "$ref": "#/$defs/AssistantMessage" },
        { "$ref": "#/$defs/UserMessage" },
        { "$ref": "#/$defs/ToolMessage" },
        { "$ref": "#/$defs/ActivityMessage" },
        { "$ref": "#/$defs/ReasoningMessage" }
      ]
    },
    "BaseMessage": {
      "$anchor": "BaseMessage",
      "type": "object",
      "description": "The fields shared by the developer, system, assistant and user messages. Deliberately excludes content, because a user message's content may be an array while the others are strings, and composition here intersects rather than overrides: a base that constrained content to a string would make an array content invalid. The tool, activity and reasoning messages do not compose this, because they carry no name.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": {
          "type": "string",
          "description": "Identifies the message within the conversation."
        },
        "role": {
          "type": "string",
          "description": "Who the message is from. Each message definition narrows this to a single value."
        },
        "name": {
          "type": "string",
          "description": "An optional display name for the author."
        },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque artefact belonging to this message, stored by a consumer and returned on a later turn."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role"]
    },
    "DeveloperMessage": {
      "$anchor": "DeveloperMessage",
      "type": "object",
      "description": "Instructions from the application developer.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "developer" },
        "content": {
          "type": "string",
          "description": "The instructions. Required: a developer message with nothing in it says nothing."
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "SystemMessage": {
      "$anchor": "SystemMessage",
      "type": "object",
      "description": "Instructions from the system.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "system" },
        "content": {
          "type": "string",
          "description": "The instructions. Required."
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "AssistantMessage": {
      "$anchor": "AssistantMessage",
      "type": "object",
      "description": "A message from the agent. Content is optional because a turn may consist only of tool calls.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "assistant" },
        "content": {
          "type": "string",
          "description": "What the agent said, if it said anything."
        },
        "toolCalls": {
          "type": "array",
          "description": "The tool calls this turn made.",
          "items": { "$ref": "#/$defs/ToolCall" }
        }
      },
      "required": ["id", "role"],
      "unevaluatedProperties": false
    },
    "UserMessage": {
      "$anchor": "UserMessage",
      "type": "object",
      "description": "A message from the person using the application.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "user" },
        "content": {
          "description": "What the person sent: either plain text, or an ordered list of parts for a multimodal message.",
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "$ref": "#/$defs/ContentPart" } }
          ]
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "ToolMessage": {
      "$anchor": "ToolMessage",
      "type": "object",
      "description": "What a tool returned, as a message in the conversation. Stands alone rather than composing BaseMessage, because it carries no name.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": { "type": "string", "description": "Identifies the message." },
        "role": {
          "const": "tool",
          "description": "Fixed. Declared here rather than inherited, because this message does not compose BaseMessage."
        },
        "content": {
          "description": "What the tool returned: either plain text, or an ordered list of parts. A tool returning structured data serialises it into text; media travel as parts of their own.",
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "$ref": "#/$defs/ContentPart" } }
          ]
        },
        "toolCallId": {
          "type": "string",
          "description": "The call this answers."
        },
        "error": {
          "type": "string",
          "description": "Why the tool failed, when it did. Present alongside content rather than instead of it, so a partial result survives a failure."
        },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque artefact belonging to this message."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role", "content", "toolCallId"],
      "unevaluatedProperties": false
    },
    "ActivityMessage": {
      "$anchor": "ActivityMessage",
      "type": "object",
      "description": "Structured progress that is not conversation content, materialised as a message so it keeps its place in the sequence. Stands alone rather than composing BaseMessage, because its content is an object rather than a string.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": { "type": "string", "description": "Identifies the message." },
        "role": {
          "const": "activity",
          "description": "Fixed. Declared here rather than inherited, because this message does not compose BaseMessage."
        },
        "activityType": {
          "type": "string",
          "description": "What kind of activity this is. An open string: the set is the producer's."
        },
        "content": {
          "type": "object",
          "description": "The activity's payload, open by key.",
          "additionalProperties": true
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role", "activityType", "content"],
      "unevaluatedProperties": false
    },
    "ReasoningMessage": {
      "$anchor": "ReasoningMessage",
      "type": "object",
      "description": "A span of the agent's reasoning, materialised as a message. Stands alone rather than composing BaseMessage, because it carries no name.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": { "type": "string", "description": "Identifies the message." },
        "role": {
          "const": "reasoning",
          "description": "Fixed. Declared here rather than inherited, because this message does not compose BaseMessage."
        },
        "content": { "type": "string", "description": "The reasoning text." },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque reasoning artefact belonging to this message."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "ToolCall": {
      "$anchor": "ToolCall",
      "type": "object",
      "description": "A call an assistant message made. Carries no subagent attribution of its own and inherits its containing message's, since several calls can share one parent.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Identifies the call. The answering tool message carries this as its toolCallId."
        },
        "type": {
          "const": "function",
          "description": "The only kind of call the protocol models."
        },
        "function": {
          "$ref": "#/$defs/FunctionCall",
          "description": "What is being called, and with what."
        },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque artefact belonging to this call."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this call. Carried here rather than folded into the containing message, because several calls can share one parent and merging them would make the result depend on their order."
        }
      },
      "required": ["id", "type", "function"],
      "unevaluatedProperties": false
    },
    "FunctionCall": {
      "$anchor": "FunctionCall",
      "type": "object",
      "description": "The name and arguments of a tool call.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Which tool is being called."
        },
        "arguments": {
          "type": "string",
          "description": "The arguments as a JSON string, not as parsed JSON. Kept as written because a model can emit arguments that are not valid JSON, and losing them at the protocol boundary would hide the fault from the consumer that has to handle it."
        }
      },
      "required": ["name", "arguments"],
      "unevaluatedProperties": false
    },
    "ContentPart": {
      "$anchor": "ContentPart",
      "description": "One part of a message body: what a person sends in a user message, or what a tool returns in a tool message. Discriminated by type. Named by what the part is rather than by direction, because the same part travels into the model inside a user message and back out of the stream inside a tool result.",
      "oneOf": [
        { "$ref": "#/$defs/TextPart" },
        { "$ref": "#/$defs/ImagePart" },
        { "$ref": "#/$defs/AudioPart" },
        { "$ref": "#/$defs/VideoPart" },
        { "$ref": "#/$defs/DocumentPart" }
      ]
    },
    "TextPart": {
      "$anchor": "TextPart",
      "type": "object",
      "description": "A text part.",
      "properties": {
        "type": { "const": "text", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved so that a streamed part can be matched to its entry in history once assistant messages carry parts too."
        },
        "text": { "type": "string", "description": "The text." },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the media parts. This is where a text search hit carries its source and title, rather than the protocol modelling a search-result part of its own."
        }
      },
      "required": ["type", "text"],
      "unevaluatedProperties": false
    },
    "ImagePart": {
      "$anchor": "ImagePart",
      "type": "object",
      "description": "An image part.",
      "properties": {
        "type": { "const": "image", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the image comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained rather than an object: inherited from the SDKs, which declare it unknown rather than a record; listed under known divergences in the README rather than resolved here."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "AudioPart": {
      "$anchor": "AudioPart",
      "type": "object",
      "description": "An audio part.",
      "properties": {
        "type": { "const": "audio", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the audio comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the other media parts."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "VideoPart": {
      "$anchor": "VideoPart",
      "type": "object",
      "description": "A video part.",
      "properties": {
        "type": { "const": "video", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the video comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the other media parts."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "DocumentPart": {
      "$anchor": "DocumentPart",
      "type": "object",
      "description": "A document part.",
      "properties": {
        "type": { "const": "document", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the document comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the other media parts."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "PartSource": {
      "$anchor": "PartSource",
      "description": "Where a media part's bytes come from: carried inline, referenced by URL, or already at the provider under a handle it issued.",
      "oneOf": [
        { "$ref": "#/$defs/DataSource" },
        { "$ref": "#/$defs/UrlSource" },
        { "$ref": "#/$defs/FileSource" }
      ]
    },
    "DataSource": {
      "$anchor": "DataSource",
      "type": "object",
      "description": "Bytes carried inline.",
      "properties": {
        "type": { "const": "data", "description": "Discriminator." },
        "value": {
          "type": "string",
          "contentEncoding": "base64",
          "description": "The bytes, base64-encoded. contentEncoding is an annotation rather than a constraint in 2020-12, so a malformed string still validates here; rejecting one is the decoder's job."
        },
        "mimeType": {
          "type": "string",
          "description": "What the bytes are. Required here, unlike on a URL source, because nothing else can tell a consumer how to read them."
        }
      },
      "required": ["type", "value", "mimeType"],
      "unevaluatedProperties": false
    },
    "UrlSource": {
      "$anchor": "UrlSource",
      "type": "object",
      "description": "Bytes referenced by URL, fetched by whoever needs them.",
      "properties": {
        "type": { "const": "url", "description": "Discriminator." },
        "value": {
          "type": "string",
          "description": "The URL. Deliberately not constrained to a URI format, so a scheme a producer already uses is not rejected here."
        },
        "mimeType": {
          "type": "string",
          "description": "What the resource is, when the producer knows. Optional, because the response can say."
        }
      },
      "required": ["type", "value"],
      "unevaluatedProperties": false
    },
    "FileSource": {
      "$anchor": "FileSource",
      "type": "object",
      "description": "Bytes already at the provider, named by a handle the provider issued: an OpenAI or Anthropic file id, a Gemini file URI, a storage URL only that provider can read. No bytes travel and nothing is fetched. Only the provider that minted the handle can resolve it; a peer that cannot drops the part as it drops any part it cannot use.",
      "properties": {
        "type": { "const": "file", "description": "Discriminator." },
        "value": {
          "type": "string",
          "description": "The handle, exactly as the provider issued it. Opaque: a consumer MUST NOT fetch it, parse it or read a scheme out of it."
        },
        "provider": {
          "type": "string",
          "description": "Who issued the handle, when the producer knows. Optional: an agent already knows which provider it talks to. When present, SHOULD be the lowercase vendor id (openai, anthropic, google) that TokenUsage.provider uses, so a peer can tell before sending whether a handle is one it can use."
        },
        "mimeType": {
          "type": "string",
          "description": "What the file is, when the producer knows. Optional, because the provider that holds the bytes knows."
        }
      },
      "required": ["type", "value"],
      "unevaluatedProperties": false
    },
    "Context": {
      "$anchor": "Context",
      "type": "object",
      "description": "A named piece of ambient information given to the agent for the run, distinct from the conversation.",
      "properties": {
        "description": {
          "type": "string",
          "description": "What this context is, for the agent to interpret."
        },
        "value": { "type": "string", "description": "The context itself." }
      },
      "required": ["description", "value"],
      "unevaluatedProperties": false
    },
    "Tool": {
      "$anchor": "Tool",
      "type": "object",
      "description": "A tool the agent may call.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The tool's name, as the agent will call it."
        },
        "description": {
          "type": "string",
          "description": "What the tool does, for the agent to decide when to use it."
        },
        "parameters": {
          "not": { "type": "null" },
          "description": "A JSON Schema describing the tool's arguments. Carried opaquely: the protocol does not constrain or validate it. Optional, because all three SDKs already treat it that way and a tool that takes no arguments has nothing to declare; an absent schema and an empty one mean the same thing to an agent."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information about the tool, for consumers that attach their own rendering or routing information to it."
        }
      },
      "required": ["name", "description"],
      "unevaluatedProperties": false
    },
    "RunAgentInput": {
      "$anchor": "RunAgentInput",
      "type": "object",
      "description": "A request to run an agent. Also echoed back as RUN_STARTED.input. Only threadId, runId and messages are required: those are the three the SDKs already agree on, and for tools and context an absent key and an empty array mean the same thing, so requiring them would catch nothing a producer could get wrong.",
      "properties": {
        "threadId": {
          "type": "string",
          "description": "The conversation this run belongs to."
        },
        "runId": { "type": "string", "description": "Identifies this run." },
        "protocolVersion": {
          "type": "string",
          "description": "The protocol version this consumer speaks, such as \"1.0\". Absent means the input was produced before the protocol carried a version — the versioning rules in the prose govern what each side does with that. Sent in-band rather than by the transport, so a recorded exchange stays self-describing."
        },
        "parentRunId": {
          "type": "string",
          "description": "The run that spawned this one."
        },
        "state": {
          "not": { "type": "null" },
          "$ref": "#/$defs/State",
          "description": "The state the run starts from."
        },
        "messages": {
          "type": "array",
          "description": "The conversation so far, in order.",
          "items": { "$ref": "#/$defs/Message" }
        },
        "tools": {
          "type": "array",
          "description": "The tools the agent may call. Absent means none.",
          "items": { "$ref": "#/$defs/Tool" }
        },
        "context": {
          "type": "array",
          "description": "Ambient information for the run. Absent means none.",
          "items": { "$ref": "#/$defs/Context" }
        },
        "forwardedProps": {
          "not": { "type": "null" },
          "description": "Application-specific values passed through to the agent untouched. Any JSON value."
        },
        "resume": {
          "type": "array",
          "description": "Answers to the interrupts that ended a previous run, when this run continues from one.",
          "items": { "$ref": "#/$defs/ResumeEntry" }
        }
      },
      "required": ["threadId", "runId", "messages"],
      "unevaluatedProperties": false
    },
    "SubagentInfo": {
      "$anchor": "SubagentInfo",
      "type": "object",
      "description": "Describes a subagent that can be invoked by a parent agent.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Unique name or identifier of the subagent."
        },
        "description": {
          "type": "string",
          "description": "What this subagent specializes in. Helps clients build agent selection UIs."
        }
      },
      "required": ["name"],
      "unevaluatedProperties": false
    },
    "IdentityCapabilities": {
      "$anchor": "IdentityCapabilities",
      "type": "object",
      "description": "Basic metadata about the agent. Useful for discovery UIs, agent marketplaces, and debugging. Set these when you want clients to display agent information or when multiple agents are available and users need to pick one.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Human-readable name shown in UIs and agent selectors."
        },
        "type": {
          "type": "string",
          "description": "The framework or platform powering this agent (e.g., \"langgraph\", \"mastra\", \"crewai\")."
        },
        "description": {
          "type": "string",
          "description": "What this agent does — helps users and routing logic decide when to use it."
        },
        "version": {
          "type": "string",
          "description": "Semantic version of the agent (e.g., \"1.2.0\"). Useful for compatibility checks."
        },
        "provider": {
          "type": "string",
          "description": "Organization or team that maintains this agent."
        },
        "documentationUrl": {
          "type": "string",
          "description": "URL to the agent's documentation or homepage."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Arbitrary key-value pairs for integration-specific identity info."
        }
      },
      "unevaluatedProperties": false
    },
    "TransportCapabilities": {
      "$anchor": "TransportCapabilities",
      "type": "object",
      "description": "Declares which transport mechanisms the agent supports. Clients use this to pick the best connection strategy. Only set flags to true for transports your agent actually handles — omit or set false for unsupported ones.",
      "properties": {
        "streaming": {
          "type": "boolean",
          "description": "Set true if the agent streams responses via SSE. Most agents enable this."
        },
        "websocket": {
          "type": "boolean",
          "description": "Set true if the agent accepts persistent WebSocket connections."
        },
        "httpBinary": {
          "type": "boolean",
          "description": "Set true if the agent supports the AG-UI binary protocol (protobuf over HTTP)."
        },
        "pushNotifications": {
          "type": "boolean",
          "description": "Set true if the agent can send async updates via webhooks after a run finishes."
        },
        "resumable": {
          "type": "boolean",
          "description": "Set true if the agent supports resuming interrupted streams via sequence numbers."
        }
      },
      "unevaluatedProperties": false
    },
    "ToolsCapabilities": {
      "$anchor": "ToolsCapabilities",
      "type": "object",
      "description": "Tool calling capabilities. Distinguishes between tools the agent itself provides (listed in items) and tools the client passes at runtime via RunAgentInput.tools. Enable this when your agent can call functions, search the web, execute code, etc.",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent can make tool calls at all. Set false to explicitly signal tool calling is disabled even if items are present."
        },
        "items": {
          "type": "array",
          "description": "The tools this agent provides on its own (full JSON Schema definitions). These are distinct from client-provided tools passed in RunAgentInput.tools.",
          "items": { "$ref": "#/$defs/Tool" }
        },
        "parallelCalls": {
          "type": "boolean",
          "description": "Set true if the agent can invoke multiple tools concurrently within a single step."
        },
        "clientProvided": {
          "type": "boolean",
          "description": "Set true if the agent accepts and uses tools provided by the client at runtime."
        }
      },
      "unevaluatedProperties": false
    },
    "OutputCapabilities": {
      "$anchor": "OutputCapabilities",
      "type": "object",
      "description": "Output format support. Enable structuredOutput when your agent can return responses conforming to a JSON schema, which is useful for programmatic consumption.",
      "properties": {
        "structuredOutput": {
          "type": "boolean",
          "description": "Set true if the agent can produce structured JSON output matching a provided schema."
        },
        "supportedMimeTypes": {
          "type": "array",
          "description": "MIME types the agent can produce (e.g., [\"text/plain\", \"application/json\"]). Omit if the agent only produces plain text.",
          "items": { "type": "string" }
        }
      },
      "unevaluatedProperties": false
    },
    "StateCapabilities": {
      "$anchor": "StateCapabilities",
      "type": "object",
      "description": "State and memory management capabilities. These tell the client how the agent handles shared state and whether conversation context persists across runs.",
      "properties": {
        "snapshots": {
          "type": "boolean",
          "description": "Set true if the agent emits STATE_SNAPSHOT events (full state replacement)."
        },
        "deltas": {
          "type": "boolean",
          "description": "Set true if the agent emits STATE_DELTA events (JSON Patch incremental updates)."
        },
        "memory": {
          "type": "boolean",
          "description": "Set true if the agent has long-term memory beyond the current thread (e.g., vector store, knowledge base, or cross-session recall)."
        },
        "persistentState": {
          "type": "boolean",
          "description": "Set true if state is preserved across multiple runs within the same thread. When false, state resets on each run."
        }
      },
      "unevaluatedProperties": false
    },
    "MultiAgentCapabilities": {
      "$anchor": "MultiAgentCapabilities",
      "type": "object",
      "description": "Multi-agent coordination capabilities. Enable these when your agent can orchestrate or hand off work to other agents.",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent participates in any form of multi-agent coordination."
        },
        "delegation": {
          "type": "boolean",
          "description": "Set true if the agent can delegate subtasks to other agents while retaining control."
        },
        "handoffs": {
          "type": "boolean",
          "description": "Set true if the agent can transfer the conversation entirely to another agent."
        },
        "subagents": {
          "type": "array",
          "description": "List of subagents this agent can invoke. Helps clients build agent selection UIs.",
          "items": { "$ref": "#/$defs/SubagentInfo" }
        }
      },
      "unevaluatedProperties": false
    },
    "ReasoningCapabilities": {
      "$anchor": "ReasoningCapabilities",
      "type": "object",
      "description": "Reasoning and thinking capabilities. Enable these when your agent exposes its internal thought process (e.g., chain-of-thought, extended thinking).",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent produces reasoning/thinking tokens visible to the client."
        },
        "streaming": {
          "type": "boolean",
          "description": "Set true if reasoning tokens are streamed incrementally (vs. returned all at once)."
        },
        "encrypted": {
          "type": "boolean",
          "description": "Set true if reasoning content is encrypted (zero-data-retention mode). Clients should expect opaque encryptedValue fields instead of readable content."
        }
      },
      "unevaluatedProperties": false
    },
    "MultimodalInputCapabilities": {
      "$anchor": "MultimodalInputCapabilities",
      "type": "object",
      "description": "Modalities the agent can accept as input. Clients use this to show or hide file upload buttons, audio recorders, image pickers, etc.",
      "properties": {
        "image": {
          "type": "boolean",
          "description": "Set true if the agent can process image inputs (e.g., screenshots, photos)."
        },
        "audio": {
          "type": "boolean",
          "description": "Set true if the agent can process audio inputs (speech, recordings)."
        },
        "video": {
          "type": "boolean",
          "description": "Set true if the agent can process video inputs."
        },
        "pdf": {
          "type": "boolean",
          "description": "Set true if the agent can process PDF documents."
        },
        "file": {
          "type": "boolean",
          "description": "Set true if the agent can process arbitrary file uploads: files of a kind the image, audio, video and document parts do not cover. Says nothing about how a file arrives; a part's source (inline, URL or provider handle) is a separate question."
        }
      },
      "unevaluatedProperties": false
    },
    "MultimodalOutputCapabilities": {
      "$anchor": "MultimodalOutputCapabilities",
      "type": "object",
      "description": "Modalities the agent can produce as output. Clients use this to anticipate rich content in the agent's response.",
      "properties": {
        "image": {
          "type": "boolean",
          "description": "Set true if the agent can generate images as part of its response."
        },
        "audio": {
          "type": "boolean",
          "description": "Set true if the agent can produce audio output (text-to-speech, audio files)."
        }
      },
      "unevaluatedProperties": false
    },
    "MultimodalCapabilities": {
      "$anchor": "MultimodalCapabilities",
      "type": "object",
      "description": "Multimodal input and output support. Organized into input and output sub-objects so clients can independently query what the agent accepts versus what it produces.",
      "properties": {
        "input": {
          "$ref": "#/$defs/MultimodalInputCapabilities",
          "description": "Modalities the agent can accept as input (images, audio, video, PDFs, files)."
        },
        "output": {
          "$ref": "#/$defs/MultimodalOutputCapabilities",
          "description": "Modalities the agent can produce as output (images, audio)."
        }
      },
      "unevaluatedProperties": false
    },
    "ExecutionCapabilities": {
      "$anchor": "ExecutionCapabilities",
      "type": "object",
      "description": "Execution control and limits. Declare these so clients can set expectations about how long or how many steps an agent run might take.",
      "properties": {
        "codeExecution": {
          "type": "boolean",
          "description": "Set true if the agent can execute code (e.g., Python, JavaScript) during a run."
        },
        "sandboxed": {
          "type": "boolean",
          "description": "Set true if code execution happens in a sandboxed or isolated environment. Only meaningful when codeExecution is true."
        },
        "maxIterations": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Maximum number of tool-call/reasoning iterations the agent will perform per run. Helps clients display progress or set timeout expectations."
        },
        "maxExecutionTime": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Maximum wall-clock time (in milliseconds) the agent will run before timing out."
        }
      },
      "unevaluatedProperties": false
    },
    "HumanInTheLoopCapabilities": {
      "$anchor": "HumanInTheLoopCapabilities",
      "type": "object",
      "description": "Human-in-the-loop interaction support. Enable these when your agent can pause execution to request human input, approval, or feedback before continuing.",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent supports any form of human-in-the-loop interaction."
        },
        "approvals": {
          "type": "boolean",
          "description": "Set true if the agent can pause and request explicit approval before performing sensitive actions (e.g., sending emails, deleting data)."
        },
        "interventions": {
          "type": "boolean",
          "description": "Set true if the agent allows humans to intervene and modify its plan mid-execution."
        },
        "feedback": {
          "type": "boolean",
          "description": "Set true if the agent can incorporate user feedback (thumbs up/down, corrections) to improve its behavior within the current session."
        },
        "interrupts": {
          "type": "boolean",
          "description": "Set true if the agent participates in the AG-UI interrupt protocol: it ends a run with RUN_FINISHED carrying an interrupt outcome, and accepts the answers back in RunAgentInput.resume."
        },
        "approveWithEdits": {
          "type": "boolean",
          "description": "Set true if tool-call interrupts accept editedArgs in the resume payload. Only meaningful when interrupts is true."
        }
      },
      "unevaluatedProperties": false
    },
    "AgentCapabilities": {
      "$anchor": "AgentCapabilities",
      "type": "object",
      "description": "A typed, categorized snapshot of an agent's current capabilities. All fields are optional — agents only declare what they support. An omitted field means the capability is not declared (unknown), not that it is unsupported. The custom field is an escape hatch for integration-specific capabilities that do not fit into the standard categories.",
      "properties": {
        "identity": {
          "$ref": "#/$defs/IdentityCapabilities",
          "description": "Agent identity and metadata."
        },
        "transport": {
          "$ref": "#/$defs/TransportCapabilities",
          "description": "Supported transport mechanisms (SSE, WebSocket, binary, etc.)."
        },
        "tools": {
          "$ref": "#/$defs/ToolsCapabilities",
          "description": "Tools the agent provides and tool calling configuration."
        },
        "output": {
          "$ref": "#/$defs/OutputCapabilities",
          "description": "Output format support (structured output, MIME types)."
        },
        "state": {
          "$ref": "#/$defs/StateCapabilities",
          "description": "State and memory management (snapshots, deltas, persistence)."
        },
        "multiAgent": {
          "$ref": "#/$defs/MultiAgentCapabilities",
          "description": "Multi-agent coordination (delegation, handoffs, subagents)."
        },
        "reasoning": {
          "$ref": "#/$defs/ReasoningCapabilities",
          "description": "Reasoning and thinking support (chain-of-thought, encrypted thinking)."
        },
        "multimodal": {
          "$ref": "#/$defs/MultimodalCapabilities",
          "description": "Multimodal input/output support (images, audio, video, files)."
        },
        "execution": {
          "$ref": "#/$defs/ExecutionCapabilities",
          "description": "Execution control and limits (code execution, timeouts, iteration caps)."
        },
        "humanInTheLoop": {
          "$ref": "#/$defs/HumanInTheLoopCapabilities",
          "description": "Human-in-the-loop support (approvals, interventions, feedback)."
        },
        "custom": {
          "type": "object",
          "description": "Integration-specific capabilities not covered by the standard categories. Open by key: any JSON value is allowed under a key, because the categories above cannot anticipate what an integration declares.",
          "additionalProperties": true
        }
      },
      "unevaluatedProperties": false
    },
    "JsonPatch": {
      "$anchor": "JsonPatch",
      "type": "array",
      "description": "A JSON Patch document as defined by RFC 6902, referenced by STATE_DELTA.delta and ACTIVITY_DELTA.patch: an ordered sequence of operations applied to a target document. An empty array is a valid no-op patch. Whether the operations actually apply to the document they target is a runtime question RFC 6902 leaves to the applier; structural validity here says nothing about it.",
      "items": { "$ref": "#/$defs/JsonPatchOperation" }
    },
    "JsonPatchOperation": {
      "$anchor": "JsonPatchOperation",
      "description": "A single RFC 6902 operation. Exactly one of the operation shapes must match, discriminated by op. Unlike the protocol's own objects, the operations are open: RFC 6902 section 4 requires members an operation does not define to be ignored rather than rejected, so a remove carrying a leftover value is a valid patch. Two of the RFC's rules are relations between values rather than shapes, so no static schema can express them and neither is checked here: a move whose from is a proper prefix of its path (section 4.4), and any operation whose pointer does not resolve in the target document. Both are the applier's to reject.",
      "oneOf": [
        { "$ref": "#/$defs/AddOperation" },
        { "$ref": "#/$defs/RemoveOperation" },
        { "$ref": "#/$defs/ReplaceOperation" },
        { "$ref": "#/$defs/MoveOperation" },
        { "$ref": "#/$defs/CopyOperation" },
        { "$ref": "#/$defs/TestOperation" }
      ]
    },
    "AddOperation": {
      "$anchor": "AddOperation",
      "type": "object",
      "description": "Inserts value at path. RFC 6902 section 4.1.",
      "properties": {
        "op": {
          "const": "add",
          "description": "Discriminator for the add operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where to insert the value."
        },
        "value": {
          "description": "The value to insert. Any JSON value, including null, which is a legitimate thing to add."
        }
      },
      "required": ["op", "path", "value"]
    },
    "RemoveOperation": {
      "$anchor": "RemoveOperation",
      "type": "object",
      "description": "Removes the value at path. RFC 6902 section 4.2.",
      "properties": {
        "op": {
          "const": "remove",
          "description": "Discriminator for the remove operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "What to remove."
        }
      },
      "required": ["op", "path"]
    },
    "ReplaceOperation": {
      "$anchor": "ReplaceOperation",
      "type": "object",
      "description": "Replaces the value at path. RFC 6902 section 4.3.",
      "properties": {
        "op": {
          "const": "replace",
          "description": "Discriminator for the replace operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "What to replace."
        },
        "value": {
          "description": "The replacement. Any JSON value, including null."
        }
      },
      "required": ["op", "path", "value"]
    },
    "MoveOperation": {
      "$anchor": "MoveOperation",
      "type": "object",
      "description": "Moves the value at from to path. RFC 6902 section 4.4.",
      "properties": {
        "op": {
          "const": "move",
          "description": "Discriminator for the move operation."
        },
        "from": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is moved from."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is moved to."
        }
      },
      "required": ["op", "from", "path"]
    },
    "CopyOperation": {
      "$anchor": "CopyOperation",
      "type": "object",
      "description": "Copies the value at from to path. RFC 6902 section 4.5.",
      "properties": {
        "op": {
          "const": "copy",
          "description": "Discriminator for the copy operation."
        },
        "from": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is copied from."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is copied to."
        }
      },
      "required": ["op", "from", "path"]
    },
    "TestOperation": {
      "$anchor": "TestOperation",
      "type": "object",
      "description": "Asserts that the value at path equals value. RFC 6902 section 4.6.",
      "properties": {
        "op": {
          "const": "test",
          "description": "Discriminator for the test operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "What to compare."
        },
        "value": {
          "description": "The value the target must equal. Any JSON value, including null."
        }
      },
      "required": ["op", "path", "value"]
    },
    "JsonPointer": {
      "$anchor": "JsonPointer",
      "type": "string",
      "description": "A JSON Pointer as defined by RFC 6901. Either the empty string, meaning the whole document, or a sequence of slash-prefixed reference tokens in which a tilde is escaped as ~0 and a slash as ~1. A value with no leading slash, or a tilde followed by anything other than 0 or 1, is not a JSON Pointer.",
      "pattern": "^(/([^/~]|~[01])*)*$"
    }
  }
}