Skip to content

feat(agents): let owners hand keys, config, and skill edits to their agent in chat - #158120

Merged
obviyus merged 13 commits into
mainfrom
feat/owner-trust-chat
Sep 26, 2026
Merged

obviyus merged 13 commits into
mainfrom
feat/owner-trust-chat

Conversation

@obviyus

@obviyus obviyus commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: owners who ask their agent in chat to change a key, a config value, or one of their own skills get refused, sent to a dashboard, or told to file a Workshop proposal. Examples: "you can't post API keys here", switching the embeddings provider routed to the web-search wizard, only proposals for handwritten skills.

User Impact

An owner can hand the agent an API key or token in chat, ask it to change config such as the embeddings provider, and have it edit skills they own. Session permission modes are unchanged: Full Access applies, restricted sessions ask.

  • Keys from chat. Masked setup flows still keep keys out of model context and remain the default. If the user already pasted a key or token, the agent stores it in the shared secret store and points the config key at it with a store SecretRef instead of refusing. It never echoes the value back. The pasted message already reached the model provider and transcript; redaction covers later logs and output only, and the docs say so.
  • Existing store entries are never touched. Each save inserts a new entry named after the config key plus a random suffix (GATEWAY_REMOTE_TOKEN_9B139B5E231299BC). Nothing is overwritten, revived, or deleted, and a new name can never match anything already pointing into the store, including a stale reference to a removed and purged entry. Replacing a key leaves its previous entry for openclaw secrets store rm. Rotating a key keeps its configured store provider alias, and the audit records the alias actually used.
  • Embeddings. The agent now treats the memory embeddings provider, model, and key as memory.search.* config, not the web-search setup wizard.
  • Skills. When the user asks, the agent edits skills they own directly: repository skill source, workspace skills/, project .agents/skills/, and configured extra skill directories. Bundled, ClawHub-installed, and plugin-provided skills are replaced by their owners' updates. For those, the agent says so and offers to capture the change as a Workshop skill.
  • Tone. The "never request / paste credentials in chat" lines are gone from the openclaw tools and system-agent prompts. "Never echo secret values" stays, and so do factual pointers for flows that genuinely need a UI: channel sign-in, provider OAuth/accounts, and model onboarding.

No config option, schema, or protocol change. The Full Access permission-policy floor from the first revision moved to #158142 for its own security review.

Why This Change Was Made

After #149870, approved config writes may target any path. What still blocked owners was model-facing text telling the agent to refuse credentials, plus the missing ability to store a chat-provided value anywhere but plaintext config.

config_set_ref gains an optional secret argument (read without trimming; only emptiness is checked). With it, the system agent:

  1. registers the value for redaction when the proposal is built;
  2. keeps the key's existing store provider alias when it has one;
  3. sends one secrets.writeForConfigRef command to the SQLite state worker with the requester's live-authority guard. The host re-checks that guard at the worker's transaction and commit admission (createSqliteWorkerWriteAdmission), so a run stopped while the command is queued writes nothing. The transaction inserts a new row under a freshly minted NAME_<16 random hex>;
  4. writes the ref through the existing config writer, which re-checks authority. If that write fails (before or after the writer commits), OpenClaw rereads the config and the error says the key was saved as <NAME> and whether the config key points at it. There is no automatic delete: another consumer may have linked the fresh entry, or the writer may have committed before failing;
  5. the normal config reload picks up the new ref, since its id always changes.

Nothing new runs SQLite on the Gateway main thread.

Out of scope / follow-ups
  • Found while proving this: in Full Access, after a delegated change applies, the next agent turn in the same chat fails with SQLite database already belongs to another worker backend. It reproduces on unmodified origin/main (71bb516) with a logging.level change followed by one more message. This PR does not fix it.
  • Built-in provider sign-in and model onboarding stay handoffs; they own live verification of the active inference route.
  • Other secret-store set/delete paths remain synchronous migration debt, as worker-access.md already records.

Evidence

Real Telegram Test Server (Convex-leased userbot, fresh Gateway, QA mock provider, Full Access, tester is owner), first revision:

Screenshot
Token given in chat, applied with no approval prompt and no refusal (synthetic QA token) User sends a remote Gateway token and asks to save it; the agent replies without refusing or asking for approval

Final effects at this head

qa-channel scenario system-agent-owner-trust passes through a real Gateway and state worker. The Gateway is seeded with an unrelated GATEWAY_REMOTE_TOKEN entry, then:

  1. A command-allowed non-owner (bob) sends the key. The openclaw tool is owner-only.
  2. The owner (alice, Full Access) sends it.

Captured step details (redacted by the Gateway; the store ref id prints as __OPENCLAW_REDACTED__):

{
  "nonOwnerEntryNames": ["GATEWAY_REMOTE_TOKEN"],
  "storedRef": { "source": "store", "provider": "default", "id": "__OPENCLAW_REDACTED__" },
  "storeEntryNames": ["GATEWAY_REMOTE_TOKEN", "GATEWAY_REMOTE_TOKEN_9B139B5E231299BC"]
}
  • After the non-owner turn: only the seeded entry exists and gateway.remote.token is unset.
  • After the owner turn: gateway.remote.token is a store SecretRef, the token is in its own minted entry (GATEWAY_REMOTE_TOKEN_9B139B5E231299BC), and the seeded entry's updatedAt/updatedBy are unchanged. No approval prompt was posted, and the token is absent from chat, config, and the store listing.

Revoked request, through the production worker (Node main thread, real broker, writeSecretStoreEntryForConfigRef). The requester's guard passes the caller's check, then reports the run stopped:

seeded: [ 'GATEWAY_REMOTE_TOKEN (cli)' ]
revoked request rejected: requesting run is no longer active
after revoked request: [ 'GATEWAY_REMOTE_TOKEN (cli)' ]
owner request saved as: GATEWAY_REMOTE_TOKEN_F1657B971F691824
after owner request: [ 'GATEWAY_REMOTE_TOKEN (cli)', 'GATEWAY_REMOTE_TOKEN_F1657B971F691824 (openclaw)' ]
seeded value intact: true

Tests (each fails without the behavior it covers):

  • production worker path (secret-store-config-ref.worker.test.ts, forked database-worker lane with the real broker): a chat secret gets its own minted entry beside a live GATEWAY_REMOTE_TOKEN without touching it; a requester revoked after the caller's check writes nothing;
  • store kernel: a refusal at commit admission rolls the transaction back; each save mints a new NAME_<hex> and leaves the key's previous entry unchanged; a stale name whose entry was removed and purged still resolves to nothing after a chat save;
  • operations: stored and referenced with no value in output or audit; authority gone before the store write writes nothing; a failed config write names the saved entry and leaves it in place; rotating a key keeps its configured store provider alias, and the audit records it;
  • tool: proposes a store write without repeating the key, preserving leading and trailing whitespace.

Measured single-worker wall time per new or materially changed test file at this head (node scripts/run-vitest.mjs run <file>, local M-series; vitest Duration includes import and setup):

File Tests Wall Vitest duration
src/secrets/store/secret-store-config-ref.worker.test.ts (new, database-worker lane) 2 14 s 2.05 s
src/secrets/store/secret-store.test.ts 32 16 s 13.37 s
src/system-agent/operations.test.ts 43 18 s 15.30 s
src/agents/tools/system-agent-tool.test.ts 36 15 s 12.89 s

QA scenarios: system-agent-owner-trust (mock-openai) runs in about 27 s after build; skill-owner-direct-edit-live is live-frontier only and took about 3 min with claude-cli/claude-sonnet-4-6.

Wording pins for the removed lecture text were deleted. The focused store, worker, exclusivity, operations, tool, approval, and delegate suites pass. node scripts/check-changed.mjs passes every gate except core lint, which fails only on three files this PR does not touch (server-chat-metadata-lifecycle.integration.test.ts, session-companion-ask.ts, app-sidebar-session-list-render.ts over max-lines on the base); oxlint on the changed files is clean.

Security decision: a Full Access owner's pasted key goes to the Gateway-wide team store without a separate approval. Maintainer (@obviyus) accepted this in the PR conversation.

Rotation with a second consumer, through the production worker (Node main thread, real broker). A second consumer references the key's first entry before the next save lands; value fingerprints only:

owner saves key #1 -> MODELS_PROVIDERS_OPENAI_API_KEY_6D96F6E92B59E935 (sha256:4a5c5a4aa8de)
second consumer now references MODELS_PROVIDERS_OPENAI_API_KEY_6D96F6E92B59E935 (e.g. linked while the next save is queued)
owner saves key #2 -> MODELS_PROVIDERS_OPENAI_API_KEY_4066F18ABAAE6903 (sha256:28bc4e3fe10d)
second consumer's entry MODELS_PROVIDERS_OPENAI_API_KEY_6D96F6E92B59E935 after rotation: sha256:4a5c5a4aa8de
unchanged: true

Config write fails after the save, with a second consumer on the fresh entry, through the production worker and the system-agent apply path (fingerprints only):

owner result: Saved the secret as GATEWAY_REMOTE_TOKEN_6B68C031E571F81C, but could not point gateway.remote.token at it: config write failed after commit (rollbackStatus: not-restored). Retry, or remove the entry with `openclaw secrets store rm GATEWAY_REMOTE_TOKEN_6B68C031E571F81C`.
config gateway.remote.token: null
second consumer's entry GATEWAY_REMOTE_TOKEN_6B68C031E571F81C: sha256:09ae5b4fd36b
second consumer keeps the credential: true

Stale reference to a removed and purged entry, production worker for purge and save:

purged rows: 1
stale ref GATEWAY_REMOTE_TOKEN after purge: SECRET_STORE_NOT_FOUND
chat save -> GATEWAY_REMOTE_TOKEN_8F698B5396990ADD resolves (value hidden)
stale ref GATEWAY_REMOTE_TOKEN after chat save: SECRET_STORE_NOT_FOUND

Owned-skill edit with a live model. New scenario skill-owner-direct-edit-live (live-frontier; run with claude-cli/claude-sonnet-4-6, subscription auth) passes at this head. It seeds workspace skill qa-owner-greeting replying OWNER-GREETING-V1, and the owner asks in plain words: "Please change my qa-owner-greeting skill so it replies OWNER-GREETING-V2 instead of OWNER-GREETING-V1." Captured result:

Skill file after the turn:

---
name: qa-owner-greeting
description: Greets the owner with a fixed marker
---
When the user asks for the owner greeting, reply with exactly: OWNER-GREETING-V2

Agent reply: "Let me find the skill file. Done. The qa-owner-greeting skill now replies OWNER-GREETING-V2 instead of OWNER-GREETING-V1."

The model edited the skill file in place and confirmed it; it did not refuse or file a Workshop proposal.

@clawsweeper

clawsweeper Bot commented Sep 25, 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 extensions: qa-lab size: L labels Sep 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 2:20 AM ET / 06:20 UTC (Revision 16).

ClawSweeper review

What this changes

The branch lets an authorized owner save a key supplied in chat as a new shared-store credential, change memory embedding settings, and directly edit skills they own.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main lacks the chat-secret capability, while this branch supplies distinct behavior and addresses the concrete blockers raised in earlier reviews. The owner-to-team-store tradeoff was explicitly accepted in the discussion; the separate permission-policy change remains in its own PR.

Priority: P2
Reviewed head: 745ef6d6cc58f6e4ebfcf6a3cf0511ab9d20fd61

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Production-boundary traces, a live skill flow, focused regressions, and careful recovery handling provide strong review signal without a current actionable defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed system-agent tool and shared-state worker path match captured after-fix Gateway traces for owner acceptance, non-owner rejection, and revoked-write rejection; a live-model trace shows a user-owned skill edit. The latest input-conflict change has focused current-head regressions, while the earlier end-to-end flows were not rerun at this head. No stored-data schema or format changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed system-agent tool and shared-state worker path match captured after-fix Gateway traces for owner acceptance, non-owner rejection, and revoked-write rejection; a live-model trace shows a user-owned skill edit. The latest input-conflict change has focused current-head regressions, while the earlier end-to-end flows were not rerun at this head. No stored-data schema or format changes.
Evidence reviewed 10 items Current-main gap: Current main's config_set_ref tool accepts an environment variable and retains guidance against credentials in chat; it has no secret argument.
Latest-release gap: The latest supplied release tag has the environment-variable input and no chat-secret argument.
Tool input boundary: The PR retains secret bytes, registers them for redaction, and rejects simultaneous meaningful secret and envVar inputs before staging an operation.
Findings None None.
Security None None.

How this fits together

The OpenClaw system agent turns an owner's chat request into an authorized operation. Credential requests pass through the shared-state worker and config writer before the updated setting reaches the runtime; user-owned skill edits use normal file tools.

flowchart LR
  A[Owner chat request] --> B[System agent]
  B --> C[Permission check]
  C --> D[Secret store worker]
  D --> E[Shared secret store]
  E --> F[Config writer]
  F --> G[Gateway runtime]
  B --> H[User-owned skill files]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +301, Tests +445, Docs +24, Other +254. Total +1024 across 32 files.

View PR surface stats
Area Files Added Removed Net
Source 16 351 50 +301
Tests 11 456 11 +445
Docs 3 31 7 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 2 254 0 +254
Total 32 1092 68 +1024

Review metrics

Metric Value Why it matters
Code growth by role production net +286 lines; tests and QA net +714 lines Production growth supports worker-backed storage, config recovery, and agent guidance; the larger test growth exercises those distinct boundaries.
User-facing tool input 1 optional secret argument added It creates a new credential path through an existing system-agent action.

Technical review

Best possible solution:

Retain masked credential entry as the default, while allowing an authorized owner to supply a key in chat through the guarded store and config owners; review the separate permission-policy floor on its own merits.

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

Not applicable as a feature request. Current main's tool accepts an environment reference but no supplied secret, and the branch supplies the new path.

Is this the best way to solve the issue?

Yes. The branch uses the existing system-agent authorization, shared secret store, and config writer, with a fresh entry that avoids overwriting other consumers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 837fad120fba.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a useful setup and skill-editing improvement with a bounded user impact and an existing masked credential path.
  • merge-risk: 🚨 auth-provider: A chat request can point a provider or other credential setting at a new store entry; the existing config writer validates the reference but does not live-test the credential.
  • merge-risk: 🚨 security-boundary: An owner-supplied key enters a Gateway-wide team store after reaching chat and model context, an explicitly documented and maintainer-accepted tradeoff guarded by owner and worker checks.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed system-agent tool and shared-state worker path match captured after-fix Gateway traces for owner acceptance, non-owner rejection, and revoked-write rejection; a live-model trace shows a user-owned skill edit. The latest input-conflict change has focused current-head regressions, while the earlier end-to-end flows were not rerun at this head. No stored-data schema or format changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed system-agent tool and shared-state worker path match captured after-fix Gateway traces for owner acceptance, non-owner rejection, and revoked-write rejection; a live-model trace shows a user-owned skill edit. The latest input-conflict change has focused current-head regressions, while the earlier end-to-end flows were not rerun at this head. No stored-data schema or format changes.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Accepting the owner's key and replying without refusal or an approval prompt changes behavior visible in Telegram chat.

Evidence

What I checked:

Likely related people:

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

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 (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-25T17:20:44.047Z sha fbd83fa :: needs real behavior proof before merge. :: [P1] Reconcile config before rolling back a saved secret | [P1] Preserve a fresh entry linked during rollback | [P2] Record the store provider actually selected
  • reviewed 2026-09-25T17:43:41.120Z sha 41a2007 :: needs real behavior proof before merge. :: [P1] Prevent reuse of purged secret entry names
  • reviewed 2026-09-25T18:05:12.351Z sha 7830940 :: needs changes before merge. :: none
  • reviewed 2026-09-25T18:18:17.348Z sha 7830940 :: blocked before merge. :: [P1] Check the saved config before suggesting secret removal
  • reviewed 2026-09-26T03:21:18.160Z sha 3a91fa51743e16faca253e5063d5444aba460d42 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T04:11:45.992Z sha e9de8b007693f60f6907c53330dc3b233327c4f2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T04:40:45.793Z sha 66f0c49 :: blocked before merge. :: [P2] Reject conflicting secret and envVar inputs
  • reviewed 2026-09-26T05:55:54.189Z sha 73db25ee0b85d854b7b8f343ed20f39736a60ae7 :: needs maintainer review before merge. :: none

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

User trust and the proposed boundary

“This has a risk” should not automatically become “you’re not allowed to do it.” The agent should help an authorized user carry out their decision—not make them argue past invented restrictions.

I reviewed this draft at dacab41f516a77a895cdda6b9530ad260cde50a2, including the implementation and existing review. I support its direction: accepting supplied credentials, storing them properly, distinguishing embeddings from web-search setup, and editing user-owned skills without an unnecessary Workshop detour.

The distinction I’d preserve

  • Risk advice: explain a concrete consequence briefly, then proceed within the user’s authorization. Don’t repeat the warning or demand ritual confirmation.
  • Actual authority: enforce the requesting person’s permissions, target ownership, and configured approval requirements in the runtime—not through the model’s judgment about whether the person should do it.
  • Agent-initiated expansion: “fix my setup” must not quietly become “disable the restrictions that stopped me.” That is different from an authorized user explicitly requesting a particular permission change.

For credentials, the useful message is: “Masked entry avoids putting the key through chat/model context; if you supply it here, I can store and configure it without echoing it.” Redaction afterward must not be presented as undoing the original exposure.

Where I’d refine this draft

The Full Access approval rule is a separate product decision. The classifier requires approval for every matching policy write—not just permission expansion, and not just changes the agent invented. That is defensible as an explicit contract, but it adds friction and shouldn’t be treated as an unavoidable prerequisite for accepting keys in chat. I’d review that change separately from the usability improvements.

There are also concrete implementation issues worth fixing without retreating to blanket refusals:

  • Secret-name collisions: the generated name loses punctuation/case and is truncated; the store then upserts that name. Distinct targets can overwrite an unrelated shared credential. Naming code.
  • Credential fidelity: the new input path trims the supplied secret. Validate it without changing meaningful bytes. Input handling.
  • Truthful outcomes: refresh can fail after storage/config have committed. Report “saved, runtime refresh failed,” rather than treating it as an uncommitted write. Write/refresh sequence.

If you keep the approval floor, its coverage also needs to match its promise: Gateway roles and Gateway tool policy currently fall outside it.

Bottom line: trust the authorized user’s intent; make execution precise and reliable. Fix accidental overwrites and misleading outcomes—not the user’s willingness to accept risk.

This was a focused static review, not a test run or merge-readiness verdict.

@obviyus

obviyus commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Addressed at 01a6918:

  • Permission-policy floor removed from this PR; it moves to a separate draft with the Gateway authorization paths (gateway.auth, gateway.roles, gateway.tools, gateway.trustedProxies, gateway.nodes).
  • Store name collisions: a key that already references a store entry replaces it; otherwise the first free NAME, NAME_2, ... is used, decided inside one worker transaction. The qa scenario seeds an unrelated GATEWAY_REMOTE_TOKEN and proves it is untouched.
  • Secret bytes are read without trimming.
  • A failed runtime refresh after both writes reports applied, with openclaw secrets reload guidance.
  • Store write and rollback run in the SQLite state worker (secrets.writeForConfigRef, secrets.rollbackWrite).
  • Authority: the live-authority check runs right before the store write, and the config writer re-checks it; revocation at either point leaves no entry (tests cover both).

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Sep 25, 2026
@obviyus

obviyus commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

At 9c41b03:

  • Worker authority: the store write runs through runOpenClawStateWorkerOperation with the requester's guard as assertCurrent and createSqliteWorkerWriteAdmission; the kernel requests transaction and commit admission, so a run revoked while the command is queued writes nothing. Proof: secret-store-config-ref.worker.test.ts in the forked database-worker lane (real broker), plus kernel refusal-at-commit test.
  • Shared entries: in-place replacement only when the config key is the sole config/auth-profile reference in the active runtime snapshot (isOnlySecretStoreReference); otherwise a fresh name.
  • Recycled deleted names drop old allowed_hosts.
  • Non-owner final effect: qa scenario now sends the key as a command-allowed non-owner first; store and config stay unchanged.
  • The team-store security acceptance remains a maintainer decision; called out in the PR body.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 25, 2026
@obviyus

obviyus commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer decision on the open security-boundary question: yes. An owner (the openclaw tool is owner-only) in a Full Access session may hand OpenClaw an API key or token in chat, and OpenClaw saves it to the Gateway-wide team secret store without a separate approval step. Restricted sessions still ask. This matches the product direction of trusting the owner, with a small floor (tracked separately in #158142).

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 25, 2026
@obviyus
obviyus force-pushed the feat/owner-trust-chat branch 2 times, most recently from 0d8a206 to 73db25e Compare September 26, 2026 05:48
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 26, 2026
obviyus and others added 13 commits September 26, 2026 11:42
…ver entries

Move the permission-policy floor to its own PR. Chat-saved keys now reuse the
config key's current store entry or take a free name, preserve exact bytes,
write and roll back in the SQLite state worker, and report a failed runtime
refresh as saved.
… entries

The state worker admits the store write through the requester's guard at
transaction and commit. A key's store entry is replaced only when nothing
else references it, and a recycled deleted name drops its old host grants.
Rotating in place relied on an earlier snapshot of who uses the entry; a
consumer linked before the queued write landed could receive the new key.
Every save now takes the first free name and never overwrites a live entry.
Rollback could delete an entry another consumer had just linked, or strand a
ref the config writer had already committed. A chat save now only inserts a
new row under an unused name, reports the saved entry if the config write
fails, and records the store provider it actually used. Config reload picks up
the new ref, so the explicit per-entry refresh goes away.
A predictable name could match a stale SecretRef whose entry was removed and
purged, handing that consumer the new key. Each save now gets NAME_<16 hex>.
Reconcile authoritative config after failures and distinguish retained, absent, or unknown references without offering unsafe deletion. Preserve typed postcommit outcomes and prove retained/shared-reference recovery through the production writer. Include the unchanged upstream type-shard rebalance from d07b710 so the existing graph budget remains enforced.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Reject secret plus envVar before proposal staging or backend execution, while retaining redaction and the existing secret-only and env-only paths.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
@obviyus
obviyus force-pushed the feat/owner-trust-chat branch from 73db25e to 745ef6d Compare September 26, 2026 06:12
@obviyus
obviyus merged commit 8fd72da into main Sep 26, 2026
513 of 597 checks passed
@obviyus
obviyus deleted the feat/owner-trust-chat branch September 26, 2026 10:50
@obviyus

obviyus commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 8fd72da.

Owners can now hand their agent an API key or token in chat: it goes into a freshly minted team secret-store entry through the state worker, fenced by the requester's live authority, and the config key points at it. No existing entry is ever overwritten, reused, or deleted. The agent also treats embeddings as memory.search.* config and edits owner skills directly instead of refusing.

Proof: qa-channel system-agent-owner-trust (owner saves, non-owner changes nothing, seeded entry untouched), production-worker traces for revoked requests, rotation with a second consumer, post-commit config failure, and purged stale references, plus a live-model run editing an owned skill in place. Thanks @roboclaw-bot for the config-write recovery and mixed-source hardening. The Full Access permission floor stays separate in #158142.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…agent in chat (openclaw#158120)

## What Problem This Solves

Fixes: owners who ask their agent in chat to change a key, a config value, or one of their own skills get refused, sent to a dashboard, or told to file a Workshop proposal. Examples: "you can't post API keys here", switching the embeddings provider routed to the web-search wizard, only proposals for handwritten skills.

## User Impact

An owner can hand the agent an API key or token in chat, ask it to change config such as the embeddings provider, and have it edit skills they own. Session permission modes are unchanged: Full Access applies, restricted sessions ask.

- **Keys from chat.** Masked setup flows still keep keys out of model context and remain the default. If the user already pasted a key or token, the agent stores it in the shared secret store and points the config key at it with a `store` SecretRef instead of refusing. It never echoes the value back. The pasted message already reached the model provider and transcript; redaction covers later logs and output only, and the docs say so.
- **Existing store entries are never touched.** Each save inserts a new entry named after the config key plus a random suffix (`GATEWAY_REMOTE_TOKEN_9B139B5E231299BC`). Nothing is overwritten, revived, or deleted, and a new name can never match anything already pointing into the store, including a stale reference to a removed and purged entry. Replacing a key leaves its previous entry for `openclaw secrets store rm`. Rotating a key keeps its configured store provider alias, and the audit records the alias actually used.
- **Embeddings.** The agent now treats the memory embeddings provider, model, and key as `memory.search.*` config, not the web-search setup wizard.
- **Skills.** When the user asks, the agent edits skills they own directly: repository skill source, workspace `skills/`, project `.agents/skills/`, and configured extra skill directories. Bundled, ClawHub-installed, and plugin-provided skills are replaced by their owners' updates. For those, the agent says so and offers to capture the change as a Workshop skill.
- **Tone.** The "never request / paste credentials in chat" lines are gone from the `openclaw` tools and system-agent prompts. "Never echo secret values" stays, and so do factual pointers for flows that genuinely need a UI: channel sign-in, provider OAuth/accounts, and model onboarding.

No config option, schema, or protocol change. The Full Access permission-policy floor from the first revision moved to openclaw#158142 for its own security review.

## Why This Change Was Made

After openclaw#149870, approved config writes may target any path. What still blocked owners was model-facing text telling the agent to refuse credentials, plus the missing ability to store a chat-provided value anywhere but plaintext config.

`config_set_ref` gains an optional `secret` argument (read without trimming; only emptiness is checked). With it, the system agent:

1. registers the value for redaction when the proposal is built;
2. keeps the key's existing store provider alias when it has one;
3. sends one `secrets.writeForConfigRef` command to the SQLite state worker with the requester's live-authority guard. The host re-checks that guard at the worker's transaction and commit admission (`createSqliteWorkerWriteAdmission`), so a run stopped while the command is queued writes nothing. The transaction inserts a new row under a freshly minted `NAME_<16 random hex>`;
4. writes the ref through the existing config writer, which re-checks authority. If that write fails (before or after the writer commits), OpenClaw rereads the config and the error says the key was saved as `<NAME>` and whether the config key points at it. There is no automatic delete: another consumer may have linked the fresh entry, or the writer may have committed before failing;
5. the normal config reload picks up the new ref, since its id always changes.

Nothing new runs SQLite on the Gateway main thread.

<details>
<summary>Out of scope / follow-ups</summary>

- Found while proving this: in Full Access, after a delegated change applies, the next agent turn in the same chat fails with `SQLite database already belongs to another worker backend`. It reproduces on unmodified `origin/main` (`e51d576`) with a `logging.level` change followed by one more message. This PR does not fix it.
- Built-in provider sign-in and model onboarding stay handoffs; they own live verification of the active inference route.
- Other secret-store set/delete paths remain synchronous migration debt, as `worker-access.md` already records.

</details>

## Evidence

Real Telegram Test Server (Convex-leased userbot, fresh Gateway, QA mock provider, Full Access, tester is owner), first revision:

| | Screenshot |
|---|---|
| Token given in chat, applied with no approval prompt and no refusal (synthetic QA token) | ![User sends a remote Gateway token and asks to save it; the agent replies without refusing or asking for approval](https://github.com/user-attachments/assets/4f68f3db-225c-4047-984d-ed0cff79cd0c) |

### Final effects at this head

qa-channel scenario `system-agent-owner-trust` passes through a real Gateway and state worker. The Gateway is seeded with an unrelated `GATEWAY_REMOTE_TOKEN` entry, then:

1. A command-allowed **non-owner** (`bob`) sends the key. The `openclaw` tool is owner-only.
2. The **owner** (`alice`, Full Access) sends it.

Captured step details (redacted by the Gateway; the store ref id prints as `__OPENCLAW_REDACTED__`):

```json
{
  "nonOwnerEntryNames": ["GATEWAY_REMOTE_TOKEN"],
  "storedRef": { "source": "store", "provider": "default", "id": "__OPENCLAW_REDACTED__" },
  "storeEntryNames": ["GATEWAY_REMOTE_TOKEN", "GATEWAY_REMOTE_TOKEN_9B139B5E231299BC"]
}
```

- After the non-owner turn: only the seeded entry exists and `gateway.remote.token` is unset.
- After the owner turn: `gateway.remote.token` is a `store` SecretRef, the token is in its own minted entry (`GATEWAY_REMOTE_TOKEN_9B139B5E231299BC`), and the seeded entry's `updatedAt`/`updatedBy` are unchanged. No approval prompt was posted, and the token is absent from chat, config, and the store listing.

**Revoked request**, through the production worker (Node main thread, real broker, `writeSecretStoreEntryForConfigRef`). The requester's guard passes the caller's check, then reports the run stopped:

```text
seeded: [ 'GATEWAY_REMOTE_TOKEN (cli)' ]
revoked request rejected: requesting run is no longer active
after revoked request: [ 'GATEWAY_REMOTE_TOKEN (cli)' ]
owner request saved as: GATEWAY_REMOTE_TOKEN_F1657B971F691824
after owner request: [ 'GATEWAY_REMOTE_TOKEN (cli)', 'GATEWAY_REMOTE_TOKEN_F1657B971F691824 (openclaw)' ]
seeded value intact: true
```

Tests (each fails without the behavior it covers):
- production worker path (`secret-store-config-ref.worker.test.ts`, forked database-worker lane with the real broker): a chat secret gets its own minted entry beside a live `GATEWAY_REMOTE_TOKEN` without touching it; a requester revoked after the caller's check writes nothing;
- store kernel: a refusal at commit admission rolls the transaction back; each save mints a new `NAME_<hex>` and leaves the key's previous entry unchanged; a stale name whose entry was removed and purged still resolves to nothing after a chat save;
- operations: stored and referenced with no value in output or audit; authority gone before the store write writes nothing; a failed config write names the saved entry and leaves it in place; rotating a key keeps its configured store provider alias, and the audit records it;
- tool: proposes a store write without repeating the key, preserving leading and trailing whitespace.

Measured single-worker wall time per new or materially changed test file at this head (`node scripts/run-vitest.mjs run <file>`, local M-series; vitest Duration includes import and setup):

| File | Tests | Wall | Vitest duration |
|---|---:|---:|---:|
| `src/secrets/store/secret-store-config-ref.worker.test.ts` (new, database-worker lane) | 2 | 14 s | 2.05 s |
| `src/secrets/store/secret-store.test.ts` | 32 | 16 s | 13.37 s |
| `src/system-agent/operations.test.ts` | 43 | 18 s | 15.30 s |
| `src/agents/tools/system-agent-tool.test.ts` | 36 | 15 s | 12.89 s |

QA scenarios: `system-agent-owner-trust` (mock-openai) runs in about 27 s after build; `skill-owner-direct-edit-live` is live-frontier only and took about 3 min with `claude-cli/claude-sonnet-4-6`.

Wording pins for the removed lecture text were deleted. The focused store, worker, exclusivity, operations, tool, approval, and delegate suites pass. `node scripts/check-changed.mjs` passes every gate except core lint, which fails only on three files this PR does not touch (`server-chat-metadata-lifecycle.integration.test.ts`, `session-companion-ask.ts`, `app-sidebar-session-list-render.ts` over `max-lines` on the base); oxlint on the changed files is clean.

Security decision: a Full Access owner's pasted key goes to the Gateway-wide team store without a separate approval. Maintainer (@obviyus) accepted this in the PR conversation.

**Rotation with a second consumer**, through the production worker (Node main thread, real broker). A second consumer references the key's first entry before the next save lands; value fingerprints only:

```text
owner saves key #1 -> MODELS_PROVIDERS_OPENAI_API_KEY_6D96F6E92B59E935 (sha256:4a5c5a4aa8de)
second consumer now references MODELS_PROVIDERS_OPENAI_API_KEY_6D96F6E92B59E935 (e.g. linked while the next save is queued)
owner saves key #2 -> MODELS_PROVIDERS_OPENAI_API_KEY_4066F18ABAAE6903 (sha256:28bc4e3fe10d)
second consumer's entry MODELS_PROVIDERS_OPENAI_API_KEY_6D96F6E92B59E935 after rotation: sha256:4a5c5a4aa8de
unchanged: true
```

**Config write fails after the save, with a second consumer on the fresh entry**, through the production worker and the system-agent apply path (fingerprints only):

```text
owner result: Saved the secret as GATEWAY_REMOTE_TOKEN_6B68C031E571F81C, but could not point gateway.remote.token at it: config write failed after commit (rollbackStatus: not-restored). Retry, or remove the entry with `openclaw secrets store rm GATEWAY_REMOTE_TOKEN_6B68C031E571F81C`.
config gateway.remote.token: null
second consumer's entry GATEWAY_REMOTE_TOKEN_6B68C031E571F81C: sha256:09ae5b4fd36b
second consumer keeps the credential: true
```

**Stale reference to a removed and purged entry**, production worker for purge and save:

```text
purged rows: 1
stale ref GATEWAY_REMOTE_TOKEN after purge: SECRET_STORE_NOT_FOUND
chat save -> GATEWAY_REMOTE_TOKEN_8F698B5396990ADD resolves (value hidden)
stale ref GATEWAY_REMOTE_TOKEN after chat save: SECRET_STORE_NOT_FOUND
```

**Owned-skill edit with a live model.** New scenario `skill-owner-direct-edit-live` (live-frontier; run with `claude-cli/claude-sonnet-4-6`, subscription auth) passes at this head. It seeds workspace skill `qa-owner-greeting` replying `OWNER-GREETING-V1`, and the owner asks in plain words: "Please change my qa-owner-greeting skill so it replies OWNER-GREETING-V2 instead of OWNER-GREETING-V1." Captured result:

Skill file after the turn:

```markdown
---
name: qa-owner-greeting
description: Greets the owner with a fixed marker
---
When the user asks for the owner greeting, reply with exactly: OWNER-GREETING-V2
```

Agent reply: "Let me find the skill file. Done. The `qa-owner-greeting` skill now replies `OWNER-GREETING-V2` instead of `OWNER-GREETING-V1`."

The model edited the skill file in place and confirmed it; it did not refuse or file a Workshop proposal.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation extensions: qa-lab merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-sensitive-changed size: XL 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.

2 participants