Skip to content

docs: improve LocalAi module documentation and agent coding rules - #1329

Merged
shanselman merged 3 commits into
openclaw:mainfrom
larroy:dev/plarroy/doc_improv
Sep 9, 2026
Merged

shanselman merged 3 commits into
openclaw:mainfrom
larroy:dev/plarroy/doc_improv

Conversation

@larroy

@larroy larroy commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

What this improves

Agent-facing context for the Local AI subsystem was thin: the modules under src/OpenClaw.Connection/LocalAi did not explain their ownership boundaries or demonstrate their primary APIs, and repository coding guidance did not concisely state the existing preference for focused, idiomatic implementation.

Changes

  • add purpose and usage headers to the nine Local AI runtime, manifest, process, endpoint, router, inference, and gateway-definition modules
  • keep examples aligned with the actual public API, /v1 endpoint validation, lazy-load Verified/Loaded semantics, manifest failure behavior, and gateway batch configuration
  • explicitly identify internal runtime-owned process infrastructure and lifecycle ownership
  • add narrow coding guidance to AGENTS.md without moving the mandatory targeted-validation hierarchy
  • add a portable CLAUDE.md import of AGENTS.md while preserving discovery of .agents/skills/

No runtime behavior, public API, dependency, workflow, or persisted format changes.

Required proof pools

  • none: documentation and agent-instruction changes only. The examples were compiled or checked against the current public/internal API surface; no runtime behavior changed.

Validation

Current head: a88d1ae9.

  • .\build.ps1: passed
  • dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore --filter "FullyQualifiedName~LlamaServerClientTests|FullyQualifiedName~LlamaServerInferenceClientTests|FullyQualifiedName~LocalAiPortLifecycleTests": 52 passed
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,943 passed, 32 skipped
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 2,861 passed
  • one initial Shared run hit the known Piper extractor PID-file lock race; the failed test passed in isolation, then the complete required validation set passed
  • independent rubber-duck review: clean after correcting all copy/paste, ownership, lazy-load, heading, and skill-discovery findings

Real behavior proof

A scratch .NET 10 console project outside the repository referenced OpenClaw.Connection and compiled the public examples for:

  • LlamaServerClient.ProbeManagedModelAsync using the required http://127.0.0.1:<port>/v1 endpoint
  • LlamaServerInferenceClient.VerifyAsync
  • LlamaServerRouterConfiguration.Build
  • LlamaServerRuntimeService and ILocalAiEndpointLifecycle injection
  • LocalAiRuntimeSnapshot.ModelEvidence.State with Verified or Loaded readiness
  • LocalAiGatewayProviderDefinition.BuildProviderJson, BuildProviderBatchJson, and MatchesProviderJson
  • LocalAiPaths and LocalAiManifestStore

The proof build succeeded with 0 warnings and 0 errors. The process-host example uses internal types by design and was verified argument-for-argument against the real LlamaServerRuntimeService call site.

The source comments also now document these non-obvious invariants:

  • Verified is the healthy lazy-unloaded model state; Loaded means active inference
  • the runtime service owns endpoint quiesce/publish transitions and treats unsuccessful lifecycle results as failures
  • provider configuration requires a resolved install with a verified loopback endpoint and is applied through one batch payload
  • a missing manifest returns null, while corrupt or unsupported receipts throw
  • the managed process-host surface is internal runtime-owned infrastructure

Not verified / blocked: none for this documentation-only change.

Security impact

No permissions, credentials, network calls, command surfaces, or data-access behavior changed.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 9, 2026, 12:17 PM ET / 16:17 UTC (Revision 7).

ClawSweeper review

What this changes

Adds ownership explanations and usage examples to nine Local AI modules, concise coding rules, and a Claude instruction file importing repository guidance.

Merge readiness

⛔ Blocked before merge - 2 items remain

The earlier example defects are corrected, and this remains a useful documentation contribution without an established merged replacement. No blocking patch defect remains, but the external-PR real-behavior proof requirement is still unmet.

Priority: P3
Reviewed head: a88d1ae981bc7edfea77b04c352c4abe018ac49e

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The corrected documentation is sound, but the remaining proof consists of compilation and tests.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The current-head scratch project compiled the documented Local AI client, runtime, manifest, and provider APIs, but no observed use of those examples or the Claude import is supplied. The inspected screenshot demonstrates the separate merged diagnostics change. Compilation and tests remain supplemental because this external PR changes files outside docs/. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The current-head scratch project compiled the documented Local AI client, runtime, manifest, and provider APIs, but no observed use of those examples or the Claude import is supplied. The inspected screenshot demonstrates the separate merged diagnostics change. Compilation and tests remain supplemental because this external PR changes files outside docs/. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Verified patch scope: The pinned merge-base-to-head patch contains 138 additions across 11 files: 129 source-comment lines and nine agent-guidance lines, with no executable code changes.
Earlier findings resolved: The health example includes the required /v1 endpoint, runtime examples use ModelEvidence.State, the process-host example supplies ExecutablePath, and CLAUDE.md names .agents/skills/. The probe implementation and existing tests support Verified and Loaded readiness.
Maintainer discussion resolves import choice: The reply at #1329 (comment) explains retaining a regular file with @AGENTS.md for Windows/archive portability and preserving skill discovery, addressing the earlier symlink suggestion.
Findings None None.
Security None None.

How this fits together

The Windows companion manages a local llama-server process using installation receipts, launch settings, and health/model checks. It publishes the verified endpoint for gateway use and reports runtime state to consumers.

flowchart LR
  A[Installation receipt] --> B[Router launch settings]
  B --> C[Managed local AI process]
  C --> D[Health and model checks]
  D --> E[Endpoint lifecycle]
  E --> F[Gateway routing]
  D --> G[Runtime state consumers]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The current-head scratch project compiled the documented Local AI client, runtime, manifest, and provider APIs, but no observed use of those examples or the Claude import is supplied. The inspected screenshot demonstrates the separate merged diagnostics change. Compilation and tests remain supplemental because this external PR changes files outside docs/. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Add current-head observed-use proof for the documented examples and Claude import. Terminal output or redacted logs count; screenshots or recordings are preferred where they show the behavior directly. Remove private details before posting. Update the PR body to trigger review, or ask a maintainer to comment @clawsweeper re-review if needed.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Documentation footprint 138 added lines across 11 files; 0 executable changes The scope is source documentation and agent guidance, with no runtime or persisted-format modification.

Technical review

Best possible solution:

Retain the corrected examples and portable instruction import, supported by observed use of the documented entrypoints.

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

Not applicable: this is documentation work, and source inspection confirms the previously reported example errors are corrected.

Is this the best way to solve the issue?

Yes: the revised comments describe existing owners and APIs without introducing parallel implementations, and the portable import follows the explicit review discussion.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5aff6f799e9b.

Labels

Label justifications:

  • P3: This improves developer documentation and agent ergonomics without changing product behavior.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The current-head scratch project compiled the documented Local AI client, runtime, manifest, and provider APIs, but no observed use of those examples or the Claude import is supplied. The inspected screenshot demonstrates the separate merged diagnostics change. Compilation and tests remain supplemental because this external PR changes files outside docs/. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Verified patch scope: The pinned merge-base-to-head patch contains 138 additions across 11 files: 129 source-comment lines and nine agent-guidance lines, with no executable code changes. (a88d1ae981bc)
  • Earlier findings resolved: The health example includes the required /v1 endpoint, runtime examples use ModelEvidence.State, the process-host example supplies ExecutablePath, and CLAUDE.md names .agents/skills/. The probe implementation and existing tests support Verified and Loaded readiness. (src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs:9, a88d1ae981bc)
  • Maintainer discussion resolves import choice: The reply at docs: improve LocalAi module documentation and agent coding rules #1329 (comment) explains retaining a regular file with @AGENTS.md for Windows/archive portability and preserving skill discovery, addressing the earlier symlink suggestion. (CLAUDE.md:1, a88d1ae981bc)
  • Captured validation and proof: Captured sourceRevision 7409a06e71a60eb7afecd592e3ccebab602aa0efff3404986cd7ad236a653e0d reports a successful build, 52 focused tests, 3,943 Shared tests with 32 skips, 2,861 Tray tests, and compilation of a scratch example project. It does not report observed execution of the revised examples or agent import. These results were reported by the PR, not rerun during this read-only review. (a88d1ae981bc)
  • Related screenshot inspected: The prepared proof-image-1.png shows setup-failure diagnostics and log links for the merged diagnostics change at fix(local-ai): surface llama-server root cause on inference failure #1284. It supports that separate contribution, not use of this PR's documentation or agent import.
  • Current-main and release comparison: Fetched main lacks the new LlamaServerClient header and CLAUDE.md. The latest supplied release tree also lacks CLAUDE.md; no tag contains the reviewed head. The related merged diagnostics PR does not implement this documentation request. (src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs:1, 5aff6f799e9b)

Likely related people:

  • Joel: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • larroy: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Add redacted current-head observed-use evidence for the revised Local AI examples and agent instruction import.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-04T22:15:59.205Z sha d2096db :: blocked before merge. :: [P2] Point Claude at the repository's actual skills directory | [P2] Use the real executable input in the process-host example
  • reviewed 2026-09-08T22:06:33.802Z sha 8fd97be :: needs real behavior proof before merge. :: [P2] Include /v1 in the health-probe example endpoint | [P2] Use ModelEvidence.State in the runtime example
  • reviewed 2026-09-08T22:22:07.351Z sha 8fd97be :: needs real behavior proof before merge. :: [P2] Include /v1 in the health-probe example endpoint | [P2] Use ModelEvidence.State in the runtime example
  • reviewed 2026-09-08T22:25:46.738Z sha 8fd97be :: needs real behavior proof before merge. :: [P2] Include /v1 in the health-probe example endpoint | [P2] Use ModelEvidence.State in the runtime example
  • reviewed 2026-09-09T06:22:54.626Z sha 8fd97be :: needs real behavior proof before merge. :: [P2] Include /v1 in the health-probe example endpoint | [P2] Use ModelEvidence.State in the runtime example
  • reviewed 2026-09-09T16:13:42.473Z sha a88d1ae :: needs real behavior proof before merge. :: none

@larroy
larroy force-pushed the dev/plarroy/doc_improv branch from d2096db to 8fd97be Compare September 8, 2026 22:02
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 8, 2026
@larroy

larroy commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@larroy

larroy commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Comment thread CLAUDE.md Resolved
@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 9, 2026
Align the Local AI examples with public API contracts and lazy-load semantics, keep agent guidance scoped to repository conventions, and preserve Claude skill discovery.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 4f97b3a3-def7-4f33-b7d5-ece171b4fd0b
@shanselman

Copy link
Copy Markdown
Collaborator

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 9, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@shanselman
shanselman merged commit 4c6747d into openclaw:main Sep 9, 2026
21 checks passed
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants