Commit f75d222
authored
[SDK/Factories] Make The Agent Factories Surface Match The Wire Contract (#2309)
* [SDK/Factories] Make The Agent Factories Surface Match The Wire Contract
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* [SDK/Codegen] Map Both Opaque Schema Markers In The TypeScript Generator
A bare x-opaque-json node now renders as JsonValue and a bare x-opaque-in-process node as OpaqueInProcessValue, instead of both collapsing to an object index signature. Nodes that also carry a real constraint keep it, so declarations like ExternalToolResult and McpServerConfig retain their unions.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* [SDK/Factories] Drop The FactoryRunResult Override And The Factory Casts
The regenerated wire types now type the factory result and argument fields as JsonValue, so the hand-written FactoryRunResult override, the toPublicFactoryRunResult boundary helper, and four casts are all unnecessary. A compile-time assertion pins the result type so the override cannot creep back.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* [SDK/Factories] Refuse A Factory Run Started From Inside A Factory Body
A factory body could start a second top-level run through any session reference it could reach, escaping the limits the user approved. An AsyncLocalStorage guard now refuses factory.run and factory.resume on the body's call path, before the RPC is dispatched, so no durable run row is created. The guard is per-call-path, so an unrelated concurrent run started elsewhere in the extension still succeeds.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* [SDK/Factories] Correct The Factory Resume Error Code Union
The union exported two codes no runtime path raises and omitted five it does, so a caller could branch on a dead code and receive a raw RpcResponseError for a real one. It now names exactly the codes execute_resume raises before a resumed run starts. permission_denied is deliberately excluded: an SDK-initiated resume dispatches with RunOrigin::default(), so the approval branch never runs and the code is unreachable from this path.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* [SDK/Factories] Forward Every Declared Subagent Option From ctx.agent
The hand-written FactoryAgentOptions declared only label, schema and model, and the agent implementation rebuilt the request from those three, so agent, reasoningEffort and contextTier were dropped before the request was sent. The options are now declared once as a key tuple and copied from it, and two compile-time assertions pin that tuple to both the public and the wire interface, so a future wire option fails the build instead of being silently dropped. Undeclared keys are still filtered out, because the wire schema forbids them.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* [SDK/Factories] Stop A Latched Progress Flush Error From Downgrading A Run
A background progress flush that failed earlier latched its error, and close() rethrew it from the factory execute finally block, so a factory body that succeeded settled as an error. The latched error is now best effort and warns, matching the treatment the final send already had. A mid-body flush failure stays fatal, because a running body that cannot record progress must not continue.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* [SDK/Factories] Correct The Factories Guide And Published API Comments
The guide and four JSDoc comments described behavior that does not exist: a declined SDK-initiated run resolving as cancelled, a single-active-run limit, two error codes no runtime path raises, an unpaginated listRuns, and a three-option ctx.agent. They now match the shipped surface, including that the SDK forwards agent, reasoningEffort and contextTier while the current runtime does not yet honor them. File-content assertions guard both files, which nothing else covers.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* Add changelog entry for the Agent Factories wire-contract corrections
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* Drop the transient runtime-support caveat from the factories docs
The claim that the runtime does not yet honor agent, reasoningEffort and contextTier is a point-in-time fact about another repository. It rots as soon as the runtime lands support, so the SDK docs no longer carry it. Also wraps three over-length test assertions that the prettier check flagged.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* Simplify factory docs so they do not encode transient facts
- Describe ctx.session by what it omits, and point at the extensions_manage guide
- Drop the hardcoded active-run limit, which will become a setting
- Drop the listRuns paging parenthetical
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* Stop the subagent-option E2E from waiting on a model response
The factory awaited its subagent to completion, so the test hung wherever no cached model response exists and timed out at 30s on CI. Only the runtime's acceptance of the option payload is under test, and a refused request rejects before a subagent starts. The factory now races the call against a short timer and returns as soon as the request is accepted.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* Describe ctx.session by how it behaves, not by what it lacks
The context session is a full CopilotSession, so factory.run and factory.resume are present and callable. Saying the APIs are absent contradicted the exported type. The guide and the published comment now say the session refuses those calls.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
* Drop the hand-written changelog entry
The changelog is generated at release time, so an entry added by hand in a feature PR does not fit the file's convention.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd
---------
Copilot-Session: 5ece6b29-8b10-47aa-ab17-b64c47f5fdcd1 parent e2cd7ad commit f75d222
14 files changed
Lines changed: 1245 additions & 411 deletions
File tree
- nodejs
- docs
- src
- generated
- test
- e2e
- fixtures
- scripts/codegen
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
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 | | - | |
| 17 | + | |
41 | 18 | | |
42 | 19 | | |
43 | 20 | | |
| |||
115 | 92 | | |
116 | 93 | | |
117 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
118 | 98 | | |
119 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
120 | 109 | | |
121 | 110 | | |
122 | 111 | | |
| |||
185 | 174 | | |
186 | 175 | | |
187 | 176 | | |
188 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
189 | 181 | | |
190 | 182 | | |
191 | 183 | | |
| |||
275 | 267 | | |
276 | 268 | | |
277 | 269 | | |
278 | | - | |
279 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
280 | 275 | | |
281 | 276 | | |
282 | 277 | | |
| |||
290 | 285 | | |
291 | 286 | | |
292 | 287 | | |
293 | | - | |
294 | | - | |
295 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
296 | 294 | | |
297 | 295 | | |
298 | 296 | | |
| |||
302 | 300 | | |
303 | 301 | | |
304 | 302 | | |
305 | | - | |
306 | | - | |
307 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
308 | 306 | | |
309 | 307 | | |
310 | 308 | | |
| |||
324 | 322 | | |
325 | 323 | | |
326 | 324 | | |
327 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| |||
0 commit comments