lh agent run polling fallback returns success for failure statuses and missing operation-status results
Observed in source
Reviewing #19597 at 07c31121, two polling-fallback branches return normally without setting a nonzero exit status. This is a source-level finding, not an end-to-end deployment test.
1. Failure and interruption statuses
In apps/cli/src/commands/agent.ts:942-944:
if (TERMINAL_RUN_STATUSES.has(status)) {
if (error) log.error(`Run error: ${error}`);
return;
}The set includes successful statuses as well as error, failed, interrupted and cancellation/abort aliases (853-866). The branch does not distinguish them for exit status. An error is printed only when an error value is present.
2. No operation-status result
In apps/cli/src/commands/agent.ts:915-917:
if (!r) {
log.info('Run is no longer tracked — finished (or expired).');
return;
}A missing result does not establish that the run finished or expired, nor that the operation was previously tracked. This is distinct from receiving a nonempty response whose status cannot be read.
Impact
Scripts relying on the command's exit status cannot distinguish these outcomes from successful completion on this path.
Expected behavior
- Use a nonzero exit status for terminal failure/interruption outcomes.
- Describe a missing result without inferring completion, expiration or prior tracking.
- Define an explicit exit-status contract for the missing-result case rather than implying successful completion.
In the #19597 discussion, L4XB suggested handling these caller-visible behavior changes in a separate PR with a changelog note. Final scope remains with the maintainers.
Related
- #19597 and the original hang report #19543.
- Companion follow-up: #19613, live-stream completion ignores
waiting_for_human. This issue is limited to the polling fallback.
Source: lobehub/lobehub