Skip to content

fix(ai): preserve stdout errors and exit diagnostics - #1342

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-ai-failure-reason
Oct 23, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-ai-failure-reason

Conversation

@nateEc

@nateEc nateEc commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Summary

An AI CLI that reports failure on stdout surfaced as an empty 'AI call failed:' message because the client read stderr only. Preserve stderr priority, fall back to stdout, and report the exit code or termination signal when both streams are empty.

Type of Change

  • Bug fix
  • Breaking compatibility change (details below)

Test Plan

  • npx tsc --noEmit

  • npm run lint

  • npm run build

  • Added behavioral regression coverage

  • Entire unit suite green (baseline failures documented below)

  • npx vitest run src/__tests__/ai-client.test.ts src/__tests__/ai-client-openclaw.test.ts: 23 passed. New cases cover stdout-only errors, stderr priority, whitespace-only streams and signal termination; three fail on unchanged main.

  • Real built CLI: after npm run build, openclaw-ai-import.test.ts through the E2E config passes: an isolated OpenClaw executable imports code successfully, then a stdout-only provider failure remains visible through the real deep-enrich command.

Broader regression record: a full combined runtime/test snapshot of these five fixes on main 83f6d1db ran npx vitest run --maxWorkers=8: 12,266 passed, 36 skipped, 4 failed across 502 files. Two failures were Pi normal-file diagnostic labels, subsequently corrected; the final combined rerun of instruction-targets.test.ts and user-rules-files.test.ts passes 373/373, including both regressions. The other two are existing submodule-checkout.test.ts empty legacy Claude/Codex settings cases: a separate clean 83f6d1db worktree reproduces exactly 24 passed / 2 failed on Apple Git 2.50.1 (missing hook.teamai-post-checkout.command). They are not hidden or skipped here.

The final combined snapshot passes type checking, lint and build. Four focused real built-CLI files pass 14 tests on the updated main; the final Pi/ZCode integration rerun passes 2/2 after the diagnostic-label correction. An earlier broader run of those four E2E files passed 56/56.

Local verification used isolated HOME directories and local Git remotes on macOS / Node 22.22.1. Additional live agent, native Windows and GitLab/GitHub provider combinations were not run locally.

Related Issues

Related #1221: addresses stderr-only AI failure reporting. OpenClaw session retention is a separate finding and is not changed here.

Notes for Reviewers

Successful output, timeout handling, spawn errors, CLI selection and parallel task behavior keep their existing contracts. English/Chinese knowledge docs and the wiki reference explain the diagnostic fallback.

- Keep stderr as the primary AI failure reason and use stdout when the CLI reports its error there.
- Fall back to the nonzero exit code or termination signal when both captured streams contain no diagnostic text.
- Preserve successful output, timeout and spawn-error behavior; update bilingual knowledge guidance and the wiki reference.
- Verify 23 client tests plus real built-CLI OpenClaw import/deep-enrichment with a stdout-only provider failure, type checking and lint.
@github-actions

Copy link
Copy Markdown

No findings in the specified PR diff.

The change preserves stderr priority, falls back to stdout, and reports the exit code or termination signal when both streams are empty. Regression tests cover these cases.

The PR description satisfies the testing requirement: it records a passing real built-CLI E2E run covering the stdout-only failure. Additional provider/agent coverage is not required.

Review was read-only; I did not run, build, or install anything from the PR.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Reviewed the diff; merged locally onto main together with #1289/#1299/#1348/#1342, then ran tsc, build, the affected unit tests and e2e (redact, dashboard-collector, ai-client-openclaw, report-timeout, openclaw-ai-import): all passed.

@jeff-r2026
jeff-r2026 merged commit 54622c3 into Tencent:main Oct 23, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants