Skip to content

fix: show provider request time for model connection checks - #169554

Merged
obviyus merged 4 commits into
mainfrom
fix/models-test-connection-timing
Oct 12, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/models-test-connection-timing

Conversation

@obviyus

@obviyus obviyus commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #169066

What Problem This Solves

Fixes slow, misleading Test connection results that count model/credential preparation and internal agent-session work as provider latency.

User Impact

Connection checks make a fresh request without creating an agent session. Each credential shows a labeled Request round-trip; the ambiguous aggregate header timing is gone. Empty or thinking-only responses fail the format check, timeouts remain timeouts, and provider diagnostics remain useful and secret-redacted.

Why This Change Was Made

The original probe in 40181af exercised a real provider request through an embedded agent. #117494 added the structured internal session required by that runtime. Connectivity checks can now use the existing isolated-completion owner instead of paying for that agent-session lifecycle.

The deliberately isolated, read-only direct-credential generation from #125816 stays intact. Every credential still uses raw OpenClaw transport, preserving #121500. OAuth refresh remains with its normal persistent owner, including the historical-peer fencing and settlement from #168957; no new cooldown/quota writes are introduced. Known configured models no longer trigger unnecessary catalog preparation.

Checked #159246: its Agents API restricted-session contract and runtime defaults are unchanged.

Evidence

  • Command/target/resource regressions: 38 passed. Includes direct and stored credentials, immutable API-key auth state, expired OAuth refreshing once into the real shared store with owner/peer fences and peer settlement, and valid OAuth causing no credential/state write.
  • Isolated-completion suite: 50 passed; Gateway probe suite: 13 passed.
  • Models view: 38 passed; i18n verification passed; Models browser E2E: 7 passed.
  • Discriminating negative control: removing the output/timeout/diagnostic fixes makes empty and thinking-only responses incorrectly report ok, aborted timeout output report unknown, and provider-detail assertions fail.
  • Mock-export gate passes after six justified isolation annotations and removal of six retired baseline entries.

Paired timing comparison

Real Gateway and Control UI button clicks against the same synthetic HTTP provider with a 250 ms response delay. Baseline cbba7e2e2ef versus candidate 994f04547a9; five alternating measured samples per row, excluding one warmup per lane. These are local stub measurements, not live-provider speed claims.

Scenario Median full probe RPC, before → after Median displayed credential duration, before → request-only after
Successful response 2,103 → 738 ms 1,532 → 256 ms
HTTP 401 1,073 → 389 ms 929 → 256 ms

The stub's median HTTP duration was 251–253 ms. Each success made one HTTP request; the old 401 path made two, while the new isolated check made one. Full probe time still includes setup; it is not shown as provider request time.

Desktop

Before — unlabeled aggregate and repeated credential timing:

Desktop before: unlabeled aggregate timing

After — labeled per-credential request timing, no aggregate header duration:

Desktop after: labeled per-credential request timing

Mobile

Mobile before: unlabeled aggregate timing

Mobile after: labeled per-credential request timing

CI context

The initial CI run also hit the main-owned eager-import-closure.test.ts duplicate-inventory failure. The same three duplicate paths are demonstrated on clean main 44f538c1855d in the existing main reproduction, and in this PR's failing job. This PR does not modify that test, wrapper inventory, or those source files.

Merge danger: two-way door. Reverting restores the old probe path without a schema or configuration migration. Blast radius is model connection diagnostics in the CLI and Control UI; ordinary chat and other runtime adapters are unchanged.

@clawsweeper

clawsweeper Bot commented Oct 12, 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 app: web-ui App: web-ui commands Command implementations agents Agent runtime and tooling size: L labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR runs model connection checks through isolated completion and displays each credential’s request round-trip time.

Example: Test a synthetic provider configured to respond after 250 ms.

  • Before: The paired measurements showed a median displayed credential duration of 1,532 ms, including preparation.
  • After: The median displayed request duration was 256 ms, labeled Request round-trip, without an aggregate header duration.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong shipped UI and request-timing proof, green exact-head CI, and no actionable findings; shared failure handling is additionally supported by focused regression coverage.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected desktop/mobile screenshots and paired real Gateway button-click measurements exercise the changed probe and timing display against a synthetic HTTP provider; the final repair leaves those production paths unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Test connection presents preparation-inclusive durations as provider latency and repeats an ambiguous fastest-target value in the header.
Reason: The reported diagnostic confusion is source-backed, the overhead reduction is measured, and the collaborator-authored change reuses an existing owner without adding user configuration.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses misleading connection-check timing that remains on main, and the reviewed head has no actionable findings.

Priority: P2
Reviewed head: 46813f5e598a14f05ce70df85e7889b35e362e07

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI and Control UI connection checks select models and credentials, invoke the provider transport, and return categorized results with per-credential timing.

flowchart TD
  A[CLI or Control UI] --> B[Connection check owner]
  B --> C[Model and credential preparation]
  C --> D[Isolated completion]
  D --> E[Provider transport]
  E --> F[Status and request timing]
  F --> A
Loading

Technical review

Best possible solution:

Use the existing isolated-completion owner for connection checks while preserving credential isolation, refresh ownership, and clear per-request timing.

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

Current-main source establishes preparation-inclusive credential timing and fastest-target aggregation; the supplied paired Gateway measurements demonstrate the removable overhead, without reproducing the reporter’s exact Synology delay.

Is this the best way to solve the issue?

The change removes the unnecessary agent-session lifecycle at its owner rather than adjusting retries or credential coverage, while retaining the established raw transport and credential contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 48d96b4e3b6f.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9166b23 adds src/commands/models/list.probe.ts:839 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9166b233185c; files: src/commands/models/list.probe.ts)
  • Ayaan Zaidi: Raw commit 2e4391a adds src/agents/isolated-completion.ts:19 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2e4391ac95ae; files: src/agents/isolated-completion.ts)

PR surface

Source -37, Tests -118, Docs +9, Other -6. Total -152 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 93 130 -37
Tests 7 307 425 -118
Docs 2 10 1 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 6 -6
Total 17 410 562 -152

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change improves misleading and unnecessarily slow connection diagnostics; ordinary model use is not reported broken.
  • merge-risk: 🚨 compatibility: The documented harness contract gains an optional timing callback; omitted callbacks remain supported, and the collaborator-authored direction supplies owner approval.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-12T02:57:49.634Z sha 994f045 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T03:09:09.900Z sha 994f045 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 11:29 PM ET / October 12, 2026, 03:29 UTC (Revision 3).

@obviyus
obviyus marked this pull request as ready for review October 12, 2026 03:01
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The PR body now includes inspected before/after desktop and mobile screenshots from the real Gateway + browser flow, plus five paired alternating measurements per success/401 scenario on the same 250 ms stub. All four uploaded images render on GitHub. Source head remains 994f045.

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 12, 2026
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Please review exact head 46813f5. The final two-file repair fixes the reported lint/type issues (bound method call; awaited test cleanup; explicit isolated state env). Full CI run 38199124259 is green. The inspected desktop/mobile images remain embedded; their UI and request-timer code is unchanged by this repair.

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 7af9595 into main Oct 12, 2026
131 of 132 checks passed
@obviyus
obviyus deleted the fix/models-test-connection-timing branch October 12, 2026 03:31
@obviyus

obviyus commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 7af9595. Connection checks now use sessionless raw OpenClaw completion and show only labeled per-credential request timing, while preserving isolated direct credentials and canonical OAuth refresh. Empty/thinking-only output, timeout classification, and redacted provider diagnostics have regression coverage. Focused suites, the same-stub five-pair timing proof, approved desktop/mobile screenshots, exact-head ClawSweeper, and required CI passed. Thanks for reporting #169066.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…#169554)

Closes openclaw#169066

## What Problem This Solves

Fixes slow, misleading **Test connection** results that count model/credential preparation and internal agent-session work as provider latency.

## User Impact

Connection checks make a fresh request without creating an agent session. Each credential shows a labeled **Request round-trip**; the ambiguous aggregate header timing is gone. Empty or thinking-only responses fail the format check, timeouts remain timeouts, and provider diagnostics remain useful and secret-redacted.

## Why This Change Was Made

The original probe in [5083dd5](openclaw@5083dd5) exercised a real provider request through an embedded agent. [openclaw#117494](openclaw#117494) added the structured internal session required by that runtime. Connectivity checks can now use the existing isolated-completion owner instead of paying for that agent-session lifecycle.

The deliberately isolated, read-only direct-credential generation from [openclaw#125816](openclaw#125816) stays intact. Every credential still uses raw OpenClaw transport, preserving [openclaw#121500](openclaw#121500). OAuth refresh remains with its normal persistent owner, including the historical-peer fencing and settlement from [openclaw#168957](openclaw#168957); no new cooldown/quota writes are introduced. Known configured models no longer trigger unnecessary catalog preparation.

Checked Sarah's [openclaw#159246](openclaw#159246): its Agents API restricted-session contract and runtime defaults are unchanged. No overlap with Pash's changes.

## Evidence

- Command/target/resource regressions: **38 passed**. Includes direct and stored credentials, immutable API-key auth state, expired OAuth refreshing once into the real shared store with owner/peer fences and peer settlement, and valid OAuth causing no credential/state write.
- Isolated-completion suite: **50 passed**; Gateway probe suite: **13 passed**.
- Models view: **38 passed**; i18n verification passed; Models browser E2E: **7 passed**.
- Discriminating negative control: removing the output/timeout/diagnostic fixes makes empty and thinking-only responses incorrectly report `ok`, aborted timeout output report `unknown`, and provider-detail assertions fail.
- Mock-export gate passes after six justified isolation annotations and removal of six retired baseline entries.

### Paired timing comparison

Real Gateway and Control UI button clicks against the same synthetic HTTP provider with a 250 ms response delay. Baseline `b372edb6424` versus candidate `994f04547a9`; five alternating measured samples per row, excluding one warmup per lane. These are local stub measurements, not live-provider speed claims.

| Scenario | Median full probe RPC, before → after | Median displayed credential duration, before → request-only after |
| --- | ---: | ---: |
| Successful response | 2,103 → 738 ms | 1,532 → 256 ms |
| HTTP 401 | 1,073 → 389 ms | 929 → 256 ms |

The stub's median HTTP duration was 251–253 ms. Each success made one HTTP request; the old 401 path made two, while the new isolated check made one. Full probe time still includes setup; it is not shown as provider request time.

### Desktop

Before — unlabeled aggregate and repeated credential timing:

![Desktop before: unlabeled aggregate timing](https://github.com/user-attachments/assets/026b85b9-4e7c-4c72-b2c9-401a4bdaee3a)

After — labeled per-credential request timing, no aggregate header duration:

![Desktop after: labeled per-credential request timing](https://github.com/user-attachments/assets/82c30402-0975-4d34-9584-0d97aa2d611a)

### Mobile

![Mobile before: unlabeled aggregate timing](https://github.com/user-attachments/assets/34770f2d-d1e1-4bab-b9dd-f3ccfaabf244)

![Mobile after: labeled per-credential request timing](https://github.com/user-attachments/assets/a54f20d2-f838-4cda-9cc6-d13a2dc72f08)

### CI context

The initial CI run also hit the main-owned `eager-import-closure.test.ts` duplicate-inventory failure. The same three duplicate paths are demonstrated on clean main `1abe83478663` in [the existing main reproduction](openclaw#169511 (comment)), and in [this PR's failing job](https://github.com/openclaw/openclaw/actions/runs/38198084932/job/114645376204). This PR does not modify that test, wrapper inventory, or those source files.

Merge danger: two-way door. Reverting restores the old probe path without a schema or configuration migration. Blast radius is model connection diagnostics in the CLI and Control UI; ordinary chat and other runtime adapters are unchanged.

Co-authored-by: Ayaan Zaidi <[email protected]>
steipete added a commit that referenced this pull request Oct 12, 2026
…overy

Scheduled main CI run 38201451496 failed model-setup-recovery.e2e.test.ts
waiting for "1234 ms" in the provider probe summary. #169554 intentionally
removed that aggregate header timing and now labels each credential with
"Request round-trip: N ms"; this e2e test was not updated.

Assert the full per-credential row text, so the status, the new label, and
the measured time are all checked.

Proof: model-setup-recovery.e2e.test.ts passes 4/4.
steipete added a commit that referenced this pull request Oct 12, 2026
#169554 made isolated completions report the provider's formatted error
instead of the fixed stop-reason text. This changed-shard e2e still asserted
the old text, so main stayed latently red until a PR selected it.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…overy

Scheduled main CI run 38201451496 failed model-setup-recovery.e2e.test.ts
waiting for "1234 ms" in the provider probe summary. openclaw#169554 intentionally
removed that aggregate header timing and now labels each credential with
"Request round-trip: N ms"; this e2e test was not updated.

Assert the full per-credential row text, so the status, the new label, and
the measured time are all checked.

Proof: model-setup-recovery.e2e.test.ts passes 4/4.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
openclaw#169554 made isolated completions report the provider's formatted error
instead of the fixed stop-reason text. This changed-shard e2e still asserted
the old text, so main stayed latently red until a PR selected it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

Regression: Settings → Models “Test connection” is slow and reports incorrect latency after 2026.9

1 participant