Commit ba616e5
authored
fix(cloud-agent-next): include step and error detail in session restore failure messages (#957)
## Summary
When `kilo-restore-session.js` fails, the structured stdout (containing
`step`, `error`, and `code` fields) was logged locally inside the
Durable Object but lost by the time the error propagated through the
tRPC chain to logpush. The error message only said `"Cold-start session
restore failed: exit 1"`, making it impossible to diagnose failures from
logpush alone.
This change enriches the `SessionSnapshotRestoreError` message at the
throw site to include `step` and `error` fields extracted from the
restore script's JSON stdout. The richer message flows naturally through
the existing error chain (`SessionSnapshotRestoreError` →
`ExecutionError.workspaceSetupFailed` → `TRPCError`) without any
downstream changes.
**Before:** `"Failed to prepare workspace: Cold-start session restore
failed: exit 1"`
**After:** `"Failed to prepare workspace: Cold-start session restore
failed: exit 1, step=import, error=kilo import failed exitCode=1"`
## Verification
- [x] `pnpm run typecheck` — passed (tsgo + wrapper)
- [x] `pnpm run test` — 642 tests passed, 25 test files
- [x] Verified existing test assertions use substring matching
(`toThrow('Cold-start session restore failed')`) and remain compatible
with the enriched message
## Visual Changes
N/A
## Reviewer Notes
- Single file change: `cloud-agent-next/src/session-service.ts` —
extends the existing stdout JSON parsing block (which already extracts
`code`) to also extract `step` and `error`.
- No new error class fields, no changes to
orchestrator/CloudAgentSession/session-execution.
- The `as Record<string, unknown>` cast on `JSON.parse` matches the
existing pattern at this location.1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1317 | 1317 | | |
1318 | 1318 | | |
1319 | 1319 | | |
| 1320 | + | |
| 1321 | + | |
1320 | 1322 | | |
1321 | 1323 | | |
1322 | 1324 | | |
| |||
1325 | 1327 | | |
1326 | 1328 | | |
1327 | 1329 | | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
1328 | 1336 | | |
1329 | 1337 | | |
1330 | 1338 | | |
| |||
1335 | 1343 | | |
1336 | 1344 | | |
1337 | 1345 | | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
1342 | 1355 | | |
1343 | 1356 | | |
1344 | 1357 | | |
| |||
0 commit comments