Repository navigation
Commit c229207
committed
fix(langgraph): keep JSON Schema semantics for object values and validate node I/O
The pydantic models generated from Agent Spec object schemas lost the
semantics of the schemas they came from, and node executors never
checked values against the declared schemas:
- a bare object schema (or a typed dictionary) became an empty model
that silently stripped every key (oracle#220);
- additional properties were dropped even when the schema allowed them
(oracle#239);
- declared defaults of omitted nested properties were replaced by None
(oracle#241, LangGraph part);
- tools received pydantic model instances for object arguments instead
of the plain dictionaries used by the other runtimes, and those
instances leaked into flow outputs and client-tool interrupt payloads;
- StartNode inputs and EndNode outputs violating their nested schema
(missing required property, wrong type, unexpected key) were accepted
(oracle#231, oracle#233);
- a ToolNode without declared outputs raised "Unsupported multi-output
mapping" for any tool return value that was not a dict or tuple.
Generated object models now derive from AgentSpecObjectModel: bare
object schemas map to Dict[str, Any] (typed when additionalProperties
is a schema), extra keys are kept unless additionalProperties is false,
declared defaults are applied and unset optional fields are omitted
when converting back to JSON with to_json_value(). Tool callables are
wrapped so they receive JSON values, and structured agent outputs are
converted the same way. Node executors apply nested defaults and
validate every input/output value against its JSON schema with the
jsonschema package, reporting each violation with the node and property
names. The zero-output ToolNode branch now short-circuits the mapping.
One existing test declared an object output but expected the scalar 1
to come out of it; it now declares an untyped output.
Fixes oracle#220, oracle#231, oracle#233, oracle#239. Fixes the LangGraph part of oracle#241.
Signed-off-by: Federico Kamelhar <[email protected]>1 parent ee111bb commit c229207
8 files changed
Lines changed: 1009 additions & 41 deletions
File tree
- docs/pyagentspec/source
- pyagentspec
- src/pyagentspec/adapters
- langgraph
- tests/adapters
- langgraph
- flows
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
53 | 72 | | |
54 | 73 | | |
55 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
100 | 102 | | |
101 | 103 | | |
102 | 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 | + | |
103 | 195 | | |
104 | 196 | | |
105 | 197 | | |
| |||
137 | 229 | | |
138 | 230 | | |
139 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
140 | 247 | | |
141 | 248 | | |
142 | 249 | | |
| |||
145 | 252 | | |
146 | 253 | | |
147 | 254 | | |
148 | | - | |
149 | 255 | | |
150 | 256 | | |
151 | 257 | | |
| 258 | + | |
152 | 259 | | |
153 | 260 | | |
154 | 261 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
160 | 270 | | |
161 | 271 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
168 | 276 | | |
169 | | - | |
| 277 | + | |
| 278 | + | |
170 | 279 | | |
171 | 280 | | |
172 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
787 | 788 | | |
788 | 789 | | |
789 | 790 | | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
794 | 797 | | |
795 | 798 | | |
796 | 799 | | |
| |||
907 | 910 | | |
908 | 911 | | |
909 | 912 | | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
910 | 916 | | |
911 | 917 | | |
912 | 918 | | |
| |||
1909 | 1915 | | |
1910 | 1916 | | |
1911 | 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 | + | |
1912 | 1951 | | |
1913 | 1952 | | |
1914 | 1953 | | |
| |||
1933 | 1972 | | |
1934 | 1973 | | |
1935 | 1974 | | |
1936 | | - | |
1937 | | - | |
1938 | | - | |
1939 | | - | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
1940 | 1981 | | |
1941 | 1982 | | |
1942 | 1983 | | |
1943 | 1984 | | |
1944 | | - | |
1945 | | - | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
1946 | 1996 | | |
1947 | 1997 | | |
1948 | 1998 | | |
1949 | | - | |
1950 | | - | |
1951 | | - | |
1952 | | - | |
1953 | | - | |
1954 | 1999 | | |
1955 | 2000 | | |
1956 | 2001 | | |
| |||
0 commit comments