Repository navigation
Commit 5377bfe
authored
fix: report structured ACP v2 failures (spacering-net#651)
## Summary
Report terminal ACP v2 foreground failures through the standard `idle` /
`stopReason: "error"` shape, with an `error` object containing a code
and user-facing message. This is the next isolated package after spacering-net#649
and spacering-net#650, based on main.
- Carry terminal failure independently of AIR negotiation and of the
v1-shaped prompt result. Preserve v1 responses, AIR session-failure
metadata, quota, and usage.
- Cover ordinary prompted turns, local commands, compact/review
commands, implementation follow-ups, and agent-initiated turns.
- Before insertion, keep the JSON-RPC error response as well as the idle
error when foreground work ends. After insertion, keep the successful
messageId response and report the work outcome through idle.
- Preserve cancellation precedence, including runtime errors raised
while aborting. Retried model errors, individual failed tools,
unrelated-turn errors, and idle background errors do not become terminal
foreground failures.
- Close unfinished v2 tool calls before the idle failure instead of
clearing their tracker first.
- Omit opaque error data from the new standard error object; use safe
messages for process loss and unexpected internal exceptions. V2
fallback text for process loss is sanitized too.
- Keep resume snapshots free of failure details so reconnecting does not
replay a terminal incident as a new completion.
The specification checked was `4034a8c`: [v2 failure
semantics](https://github.com/agentclientprotocol/agent-client-protocol/blob/4034a8cbc99bc48fd4579f70a3407b07907e0eb6/docs/protocol/v2/prompt-lifecycle.mdx#L801-L839).
Initial commands, system prompts, and standard subagent sessions remain
separate work packages. Existing AIR subagent behavior is unchanged.
## Validation
- `npm run typecheck` — passed, including examples.
- `npm test` — 1,815 passed; 36 skipped.
- `npm run build` — passed.
- `npm run test:integration` — 5 passed against real Codex app-server
with a local mock model.
- The real-process v2 test now verifies terminal HTTP 401 -> idle/error
with code -32000, then clears the mock failure and verifies a successful
prompt and all resume modes. The mock holds the error across Codex's
authentication retry rather than accidentally returning an unrelated
error.
- Focused wire/snapshot coverage checks AIR and non-AIR failures,
pre-insertion authentication, cancellation races, failed-tool cleanup,
implementation failures, unrelated errors, and resume behavior.
- `npm run codex-test` — live-model smoke test from an empty scratch
directory completed with end_turn (backward-compatibility check).
- `git diff --check` — passed.
The full live-model E2E suite was not run. Failure scenarios use the
local model mock rather than changing real credentials or provoking
failures against an external provider.1 parent 986955a commit 5377bfe
24 files changed
Lines changed: 600 additions & 52 deletions
File tree
- src
- __tests__
- CodexACPAgent
- data
- data
- integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
162 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| |||
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | | - | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| 81 | + | |
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| |||
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
91 | 107 | | |
92 | 108 | | |
93 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
345 | 347 | | |
346 | 348 | | |
347 | 349 | | |
348 | | - | |
349 | | - | |
350 | | - | |
| 350 | + | |
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| |||
1417 | 1417 | | |
1418 | 1418 | | |
1419 | 1419 | | |
1420 | | - | |
| 1420 | + | |
1421 | 1421 | | |
1422 | 1422 | | |
1423 | 1423 | | |
| |||
1484 | 1484 | | |
1485 | 1485 | | |
1486 | 1486 | | |
1487 | | - | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
1488 | 1492 | | |
1489 | 1493 | | |
1490 | 1494 | | |
1491 | 1495 | | |
1492 | 1496 | | |
1493 | 1497 | | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1494 | 1502 | | |
1495 | 1503 | | |
1496 | | - | |
| 1504 | + | |
1497 | 1505 | | |
1498 | 1506 | | |
1499 | 1507 | | |
| |||
4099 | 4107 | | |
4100 | 4108 | | |
4101 | 4109 | | |
| 4110 | + | |
4102 | 4111 | | |
4103 | 4112 | | |
4104 | 4113 | | |
| |||
4114 | 4123 | | |
4115 | 4124 | | |
4116 | 4125 | | |
| 4126 | + | |
| 4127 | + | |
| 4128 | + | |
| 4129 | + | |
| 4130 | + | |
| 4131 | + | |
| 4132 | + | |
| 4133 | + | |
| 4134 | + | |
| 4135 | + | |
4117 | 4136 | | |
4118 | 4137 | | |
4119 | 4138 | | |
| |||
4166 | 4185 | | |
4167 | 4186 | | |
4168 | 4187 | | |
4169 | | - | |
4170 | 4188 | | |
4171 | 4189 | | |
4172 | 4190 | | |
| |||
4188 | 4206 | | |
4189 | 4207 | | |
4190 | 4208 | | |
| 4209 | + | |
4191 | 4210 | | |
4192 | 4211 | | |
4193 | 4212 | | |
| |||
4200 | 4219 | | |
4201 | 4220 | | |
4202 | 4221 | | |
4203 | | - | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
4204 | 4225 | | |
4205 | 4226 | | |
4206 | 4227 | | |
4207 | 4228 | | |
4208 | 4229 | | |
4209 | | - | |
| 4230 | + | |
4210 | 4231 | | |
4211 | 4232 | | |
4212 | 4233 | | |
| |||
4216 | 4237 | | |
4217 | 4238 | | |
4218 | 4239 | | |
4219 | | - | |
| 4240 | + | |
4220 | 4241 | | |
4221 | 4242 | | |
| 4243 | + | |
4222 | 4244 | | |
4223 | 4245 | | |
4224 | 4246 | | |
4225 | 4247 | | |
4226 | 4248 | | |
4227 | 4249 | | |
4228 | 4250 | | |
4229 | | - | |
| 4251 | + | |
4230 | 4252 | | |
4231 | 4253 | | |
4232 | 4254 | | |
| |||
4239 | 4261 | | |
4240 | 4262 | | |
4241 | 4263 | | |
4242 | | - | |
| 4264 | + | |
4243 | 4265 | | |
4244 | 4266 | | |
4245 | 4267 | | |
4246 | 4268 | | |
4247 | 4269 | | |
4248 | 4270 | | |
4249 | 4271 | | |
4250 | | - | |
| 4272 | + | |
4251 | 4273 | | |
4252 | 4274 | | |
4253 | 4275 | | |
| |||
4320 | 4342 | | |
4321 | 4343 | | |
4322 | 4344 | | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
4323 | 4349 | | |
4324 | 4350 | | |
4325 | 4351 | | |
| |||
4451 | 4477 | | |
4452 | 4478 | | |
4453 | 4479 | | |
4454 | | - | |
| 4480 | + | |
4455 | 4481 | | |
4456 | 4482 | | |
4457 | 4483 | | |
| |||
4463 | 4489 | | |
4464 | 4490 | | |
4465 | 4491 | | |
4466 | | - | |
| 4492 | + | |
4467 | 4493 | | |
4468 | 4494 | | |
4469 | 4495 | | |
| |||
4532 | 4558 | | |
4533 | 4559 | | |
4534 | 4560 | | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
4535 | 4565 | | |
4536 | 4566 | | |
4537 | 4567 | | |
| |||
4648 | 4678 | | |
4649 | 4679 | | |
4650 | 4680 | | |
| 4681 | + | |
| 4682 | + | |
| 4683 | + | |
| 4684 | + | |
4651 | 4685 | | |
4652 | 4686 | | |
4653 | 4687 | | |
| |||
4764 | 4798 | | |
4765 | 4799 | | |
4766 | 4800 | | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
| 4804 | + | |
4767 | 4805 | | |
4768 | 4806 | | |
4769 | 4807 | | |
| |||
4833 | 4871 | | |
4834 | 4872 | | |
4835 | 4873 | | |
4836 | | - | |
| 4874 | + | |
4837 | 4875 | | |
4838 | 4876 | | |
4839 | 4877 | | |
| |||
4853 | 4891 | | |
4854 | 4892 | | |
4855 | 4893 | | |
| 4894 | + | |
4856 | 4895 | | |
4857 | 4896 | | |
4858 | 4897 | | |
| |||
0 commit comments