Skip to content

fix: show connection failures in terminal replies - #168247

Merged
steipete merged 2 commits into
mainfrom
fix/connection-failure-terminal-copy
Oct 10, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/connection-failure-terminal-copy

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes misleading timeout replies when the connection to an AI service fails during a turn, such as when a local model server stops.

User Impact

The final reply now identifies the connection failure and retains the warning to check the conversation for completed work before retrying. Raw provider diagnostics remain hidden. No configuration changes or migration are required.

Why This Change Was Made

Network failures intentionally share the timeout retry bucket. The failure-facts owner now refines that bucket with the existing shared transport-copy formatter. Terminal replies and incomplete-turn replies consume the same curated text; retry policy, actual timeout wording, and HTTP/provider-specific guidance retain their existing precedence.

Production: +16/-4 lines (net +12). Tests: +42/-0. Docs: +4/-0. The small production increase adds the safe copy projection and partial-work caution; no obsolete nearby path justified unrelated cleanup.

Evidence

  • Regression on unchanged main source: 3 connection cases failed with timeout wording, 38 controls passed; 220.69 s wall time. The new cases cover preserved raw errors, ECONNREFUSED codes, DNS failures, diagnostic privacy, and partial-work caution. HTTP 503 and existing genuine-timeout/local-worker controls retain their guidance.
  • Fixed owner/shared proof: node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-failure-reply.test.ts src/shared/assistant-error-format.test.ts src/agents/failover/assistant-request-failure-copy.test.ts --maxWorkers=1 — 118 passed, 477.88 s wall. Most time is existing compiled-worker preparation/import work; the new assertions took milliseconds and add no timers or process boots.
  • Real external llama-server, Qwen3-1.7B Q8_0, isolated Gateway on 19291 and server on 19292: successful BASELINE_OK and FIXED_OK channel turns. For each outage, SIGTERM was sent only after the server logged launch_slot_ for a long counting request. Baseline delivered one timeout reply after 101.14 s. Fixed code delivered one connection-failure reply with the completed-work caution after 87.981 s. Both runs showed ECONNREFUSED; these timings are observations, not a performance claim.
  • Live QA and the 118-test run used commit 6cbccaa835a7de0c2b9952e2db136a6bf096a66d; the final follow-up only updates the second internal consumer to the renamed curated-copy field. The final consumer test passed (9 tests, 336.36 s wall), production types passed (19.22 s), and all test-typecheck shards passed (523.21 s).
  • Runtime pnpm build passed with the supported OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 and private QA profile, 725.50 s wall. Full package declaration build was not run. Interrupted checks from a shared-host Node update and a build/test artifact overlap were rerun after repairing those harness conditions.
  • Required ratchets, configuration docs, plugin inventory, selected broader guards, and targeted lint passed. Final branch Codex autoreview: scoped-clean, no actionable P0–P2 findings. Exact-head CI and openclaw/ci-gate passed. CI executed all 41 terminal-copy cases in 0.013 s and all 9 incomplete-turn cases in 0.006 s. ClawSweeper reviewed this exact head with no findings and no Before-merge items. Raw runtime capture attachments and Telegram end-to-end proof were not supplied; those proof-only requests are covered by the campaign's maintainer-authorized override.

The live fixture used llama-server --model <Qwen3-1.7B-Q8_0.gguf> --alias qwen3-1.7b --jinja --ctx-size 32768 --parallel 1 --host 127.0.0.1 --port 19292 --reasoning-format none and pnpm openclaw --profile small-fixes gateway run --port 19291 with isolated state/config and the synthetic QA channel.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Oct 10, 2026
@steipete
steipete marked this pull request as ready for review October 10, 2026 05:47
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves connection-failure guidance in terminal and incomplete-turn replies, including the warning about completed work.

Example: A local model server stops during generation and subsequent requests fail with ECONNREFUSED.

  • Before: The request took too long. Check the conversation for any completed work before trying again.
  • After: Couldn't connect to the AI service, with connection diagnostics guidance and the completed-work warning.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and meaningful regressions support correctness; runtime confidence rests on the detailed report rather than independently inspectable output.
Proof confidence 🦐 gold shrimp (3/6) The verified maintainer-authored PR is outside the external-contributor proof gate; its body reports a real Gateway channel outage changing timeout copy to connection guidance at 6cbccaa, followed only by the verified second-consumer field update, but supplies no inspectable runtime capture for this behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A stopped or unreachable model server produces misleading timeout advice instead of identifying the connection failure.
Reason: The existing area owner supplies a focused correction that improves recovery guidance while preserving diagnostic privacy and completed-work caution.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: current main still mislabels connection failures as timeouts, and the focused shared-owner repair introduces no actionable correctness or security defect.

Priority: P2
Reviewed head: 4b645956f053d3a61dd7ae24347360592db0d2c9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Raw before/after channel output from the reported local-server outage is not attached for independent inspection.
Agent review details

How this fits together

The shared failure-facts owner converts classified provider errors into curated text consumed by terminal and incomplete-turn reply builders.

flowchart TD
  A[Provider failure] --> B[Failover classification]
  B --> C[Shared reply failure facts]
  D[Transport copy formatter] --> C
  C --> E[Terminal reply]
  C --> F[Incomplete turn reply]
Loading

Technical review

Best possible solution:

Preserve connection guidance through the existing shared failure-facts owner without changing retry policy or exposing raw diagnostics.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows that ECONNREFUSED classified as timeout reaches generic timeout copy; the author also reports reproducing this through an isolated Gateway channel, but this review ran no target code.

Is this the best way to solve the issue?

The repair uses the existing shared formatter and failure-facts owner, completes the internal field rename across both consumers, and preserves HTTP, provider-specific, and local-worker guidance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6ca61e2b5b78.

Provenance checked

  • Shared failure facts keeps the original intent (6a31a19: Preserve curated provider guidance when an agent ends without an assistant reply, retaining warnings and hiding unknown diagnostics.)
  • Incomplete-turn guidance precedence keeps the original intent (6a1852b: Keep specific public provider-access guidance through non-replayable terminal presentation without relaxing replay protection.)
  • Terminal classified failure copy keeps the original intent (85f6969: Carry bounded transcript-format recovery guidance through thrown failures without publishing raw provider or transcript details.)
  • Provider rejection and history troubleshooting keeps the original intent (cc030e6: Explain provider validation failures accurately while preserving existing recovery guidance for known failures.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6a31a19 adds src/agents/failover/request-error-facts.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6a31a19c4ed4; files: src/agents/failover/request-error-facts.ts)
  • GokayAI: Raw commit d7b8c98 adds src/auto-reply/reply/agent-runner-failure-reply.ts:403 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d7b8c982a188; files: src/auto-reply/reply/agent-runner-failure-reply.ts)

PR surface

Source +12, Tests +42, Docs +4. Total +58 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 16 4 +12
Tests 1 42 0 +42
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 62 4 +58

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +16/-4; tests +42/-0 The small production increase adds one shared curated-copy projection; the regression cases protect recovery guidance, privacy, partial-work caution, and HTTP precedence.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Misleading connection-failure guidance adds recovery friction, while provider availability and retry behavior remain unchanged.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The shared failure-copy change is visible in Telegram replies when a model connection fails, including the completed-work warning.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Optionally attach redacted before/after channel output from the reported server outage, excluding credentials and non-public endpoints.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-10T05:54:04.009Z sha 4b64595 :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 2:12 AM ET / 06:12 UTC (Revision 2).

@steipete steipete self-assigned this Oct 10, 2026
@steipete
steipete merged commit e67e13c into main Oct 10, 2026
217 of 220 checks passed
@steipete
steipete deleted the fix/connection-failure-terminal-copy branch October 10, 2026 06:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
* fix: preserve connection failure guidance in terminal replies

* fix: consume curated failure copy for incomplete turns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant