Commit 09c8190
authored
List a connection's tools from a full OpenAPI spec on Workers without re-parsing it (#1084)
* openapi: stream compile + serve from content-addressed bindings (no re-parse)
The serve path (resolveOpenApiBackedTools, the 2nd OOM site) re-parsed the
whole spec on every tools/list. For the full Microsoft Graph spec (37MB /
16.5k ops) that rebuilt a ~300MB document tree and OOM'd the 128MB Workers
isolate even after the add-path parser swap.
Add a memory-safe compile + serve path that never re-parses:
- streamOperationBindings (extract.ts): two-pass streaming compile. Pass 1
plans tool paths from schema-free metadata (planToolPaths, extracted from
compileToolDefinitions); pass 2 builds invocation bindings in bounded
chunks, flushing each before the next so a huge spec's bindings are never
all co-resident with the parsed tree.
- Content-addressed defs blob (store.ts: putDefs/getDefs, keyed by specHash):
the normalized #/$defs schemas, built once per spec at add time and shared
across tenants. buildDefsJson serializes them one schema at a time so the
normalized tree never co-resides with the parsed document.
- Persist a resolved description per operation so the serve path rebuilds each
tool def from the binding alone.
- resolveOpenApiBackedTools fast path: getDefs(specHash) + listOperations +
toolDefFromStoredOperation, falling back to a spec re-parse for legacy rows
or a missing/corrupt blob.
- Route the openapi, microsoft (full-graph), and google add/update paths
through the streaming persist + putDefs.
* e2e: guard full Graph catalog add + serve at real scale
Drives the public API to add every Microsoft Graph workload (the full
~37MB / 16.5k-operation spec) and then list the served catalog. Pins
both former OOM sites at real scale: the streaming add persists one
binding per operation, and tools/list rebuilds >5000 tools from the
persisted bindings plus the content-addressed defs blob, never
re-parsing the spec. Proven green on cloud and selfhost.
* openapi: keep the file-emit hint on the fast serve path
The content-addressed serve path rebuilds a tool def from the persisted
binding instead of re-parsing the spec. The re-parse path (kept as the
fallback) appends the ToolFile emit contract to a file-returning tool's
description at the projection step; the fast path bypassed that step and
served the bare description, so a file-returning operation lost the
contract whenever it was served from the binding (the common case once a
spec is persisted).
Apply the hint at the same projection step in the fast path, sourced from
the binding's response fileHint (already inspected for the output schema),
so a file tool carries the contract identically whether served fast or via
the fallback. No persist-path or schema change: existing rows pick it up on
the next list. Covered by the tool-descriptions e2e scenario.1 parent 395ba97 commit 09c8190
11 files changed
Lines changed: 641 additions & 78 deletions
File tree
- e2e/scenarios
- packages/plugins
- google/src/sdk
- microsoft/src/sdk
- openapi/src/sdk
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
| |||
298 | 300 | | |
299 | 301 | | |
300 | 302 | | |
301 | | - | |
| 303 | + | |
| 304 | + | |
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
341 | 342 | | |
342 | 343 | | |
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 | + | |
344 | 384 | | |
345 | 385 | | |
346 | 386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| 34 | + | |
32 | 35 | | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
125 | 151 | | |
126 | 152 | | |
127 | 153 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | 154 | | |
133 | 155 | | |
134 | 156 | | |
| |||
156 | 178 | | |
157 | 179 | | |
158 | 180 | | |
159 | | - | |
| 181 | + | |
160 | 182 | | |
161 | 183 | | |
162 | 184 | | |
| |||
167 | 189 | | |
168 | 190 | | |
169 | 191 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 192 | + | |
174 | 193 | | |
175 | 194 | | |
176 | 195 | | |
177 | | - | |
| 196 | + | |
178 | 197 | | |
179 | 198 | | |
180 | 199 | | |
| |||
199 | 218 | | |
200 | 219 | | |
201 | 220 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | 221 | | |
208 | 222 | | |
209 | | - | |
210 | 223 | | |
211 | 224 | | |
212 | 225 | | |
| |||
229 | 242 | | |
230 | 243 | | |
231 | 244 | | |
232 | | - | |
| 245 | + | |
233 | 246 | | |
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
| 253 | + | |
243 | 254 | | |
244 | 255 | | |
245 | 256 | | |
| |||
257 | 268 | | |
258 | 269 | | |
259 | 270 | | |
260 | | - | |
| 271 | + | |
261 | 272 | | |
262 | 273 | | |
263 | 274 | | |
| |||
340 | 351 | | |
341 | 352 | | |
342 | 353 | | |
343 | | - | |
| 354 | + | |
| 355 | + | |
344 | 356 | | |
345 | 357 | | |
346 | 358 | | |
| |||
0 commit comments