Skip to content

feat(comfy): support custom headers and per-request seed randomization - #130098

Merged
steipete merged 11 commits into
openclaw:mainfrom
hartmark:feat/comfy-headers-seed-randomization
Aug 28, 2026
Merged

steipete merged 11 commits into
openclaw:mainfrom
hartmark:feat/comfy-headers-seed-randomization

Conversation

@hartmark

@hartmark hartmark commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The ComfyUI provider plugin's local mode only ever sent Content-Type on requests, so a local ComfyUI instance reachable behind HTTP auth (Basic auth, a bearer token, etc.) had no way to authenticate — the only auth path was cloud mode's API key. Separately, a static workflow/workflowPath file's sampler seed never changed between submissions, so any workflow relying on a fresh random seed per generation silently returned the same image every time.

Why This Change Was Made

Both gaps block real self-hosted ComfyUI setups that sit behind auth on a non-loopback host and whose workflow graph has a KSampler-style seed input meant to vary per run — a common, realistic configuration, not an edge case.

User Impact

  • New optional headers config key, merged over the plugin's own default headers for both local and cloud mode — same shape as the existing remote.headers pattern used by the ollama plugin. Scoped to the shared connection config only (not per-capability), matching how mode/baseUrl/apiKey/allowPrivateNetwork are already shared-only: a single ComfyUI instance has one auth scheme regardless of which capability (image/video/music) is calling it.
  • New optional seedNodeId/seedInputName per-capability config keys: when set, a fresh cryptographically-random seed (via node:crypto's randomInt, capped below Number.MAX_SAFE_INTEGER to avoid JSON float-precision loss) is injected into that workflow node before every submission.
  • All three keys are additive and optional; existing configs are unaffected.
  • openclaw.plugin.json's configSchema (which has additionalProperties: false) is updated to declare headers at the top level, and seedNodeId/seedInputName both at the top level and inside image/video/music, so openclaw config set validation accepts them.

Evidence

  • 4 new unit tests in extensions/comfy/image-generation-provider.test.ts covering: headers merged into the local-mode request, a non-object headers value being ignored rather than throwing, seed injection producing a fresh safe-integer seed per submission, and an unconfigured seedNodeId leaving a workflow's baked-in seed untouched. Full extension suite: 50/50 passing.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test clean; oxfmt/oxlint clean.
  • autoreview --mode commit clean (patch is correct (0.99), no accepted findings).
  • Live-verified end-to-end against a real self-hosted ComfyUI instance behind HTTP Basic Auth, through the actual deployed plugin (not a mock):
    • Triggered a real image_generate tool call via openclaw agent against the live gateway process (so the async generation task ran to completion, not a one-shot CLI subprocess). Result: toolSummary: { calls: 1, tools: ["image_generate"], failures: 0 }, task ledger status: succeeded, a real 1024x1024 PNG delivered back into the conversation.
    • Pulled the last 5 entries directly from the ComfyUI instance's own /history endpoint (which requires the configured Basic Auth header to succeed at all — a 401 would return no history) and extracted the actual submitted seed value from each: 1454512374329557, 1005139994031622, 5705569401396208, 58058097759276, 7669280134279345 — five real, distinct, safe-integer seeds confirming both the auth header and the seed-randomization mechanism work end-to-end in production, not just in the unit tests.

Update: SecretInput header resolution (security finding fixed)

Fixed the real P1/security finding: headers values only accepted literal strings, so a credential-bearing value (Authorization) had no path to protected secret storage — the schema rejected a SecretRef object outright, and the runtime silently dropped any non-string value. Both are fixed:

  • openclaw.plugin.json's headers.additionalProperties now accepts ["string", "object"], matching apiKey's existing type union.
  • resolveComfyHeadersConfig (renamed from normalizeComfyHeadersConfig) resolves each header value through the exact same resolveSecretInputString path apiKey already uses, including the env-backed fallback (canResolveEnvSecretRefInReadOnlyPath + process.env read) — mirroring the ollama plugin's established header-secret precedent the reviewer cited.
  • A header pointed at a SecretRef that can't be resolved now throws (fails the request) instead of silently sending it unauthenticated — matching Ollama's unresolvedRefReason → throw behavior for a configured-but-unresolvable ref, while an unset/absent header value is still silently skipped (not every header is required).

New tests: an env-backed SecretRef header resolves and reaches the wire (same env-fallback path the live-verified deployment already uses for the literal-string case), and a header pointed at a missing env var throws before any HTTP request fires. Full extension suite: 52/52 passing. autoreview clean (patch is correct (0.99)).

Update: real-behavior proof for the SecretRef header path (current head)

ClawSweeper's last review correctly noted the SecretRef-header path (as opposed to the literal-string case, which had live production proof above) only had mocked-fetch unit-test evidence. Closed that gap with a real, unmocked run: a plain node:http server standing in for ComfyUI, hit over a real loopback socket by the actual fetchWithSsrFGuard-based request path (ssrf-runtime is not mocked here, unlike the unit tests) — real DNS/SSRF-guard evaluation, real SecretInput env resolution, real sockets, current head (44e45d90f):

[proof] local stand-in ComfyUI server listening at http://127.0.0.1:37185

> resolves an env-backed SecretRef Authorization header and completes a real generation
[proof] requests received by stand-in server: 3
[proof] Authorization header per request: Basic cHJv...Mmo= | Basic cHJv...Mmo= | Basic cHJv...Mmo=
[proof] expected (redacted): Basic cHJv...Mmo=
 ✓ resolves an env-backed SecretRef Authorization header and completes a real generation  1361ms

> stops before any HTTP request when the SecretRef is unresolvable (fail-closed)
[proof] fail-closed: threw=plugins.entries.comfy.config.headers.Authorization references an unavailable secret
[proof] fail-closed: requests reaching stand-in server: 0
 ✓ stops before any HTTP request when the SecretRef is unresolvable (fail-closed)  4ms
  • The same redacted Authorization value round-tripped through all three real requests the full generation flow makes (POST /prompt submit, GET /history/:id poll, GET /view download) — the SecretRef survives every hop, not just the first.
  • The fail-closed run reached zero HTTP requests: an unresolvable SecretRef throws (references an unavailable secret) strictly before any socket opens, matching the throw-not-silently-drop behavior described above.
  • Script was throwaway (not committed) — a .live-secretref-proof.test.ts that skips the ssrf-runtime mock and boots a real listener; deleted after capturing this transcript.

Update: real ComfyUI proof at current head (e32863dc6cd)

Closed the "current-head real-Comfy SecretRef proof" gap. Ran the actual current-head buildComfyImageGenerationProvider().generateImage(...) twice against a real, independent self-hosted ComfyUI instance, authenticated via a real env-backed SecretRef Authorization header (Basic auth) resolved through resolveConfiguredSecretInputString — the exact path this PR's fixes touch:

[proof] submitting real generation against https://comfyui.<redacted>
[proof] run 1 complete: ["images","model","metadata"]
[proof] run 2 complete: ["images","model","metadata"]
[proof] recent seeds from /history: [
  1486535059023369,
  73305531236703,
  221146079591460,
  68941177155303,
  54330629102381
]
[proof] DONE

Both real generations completed successfully; the recent seeds pulled back from ComfyUI's own /history endpoint (which itself required the same Basic Auth to answer) confirm the SecretRef-authenticated requests genuinely reached the real server. Auth credential and host redacted; hostname/user/password were supplied out-of-band by the repo owner specifically for this verification and referenced only via shell variables, never printed.

Maintainer review and final validation

The configuration surface (headers, seedNodeId, seedInputName) and shared provider HTTP SDK design were explicitly accepted by the maintainer. Existing configurations keep their current behavior: fresh seeds require a configured seed node, and saved workflows are not mutated. The random seed range is [0, 2**48), matching Node's randomInt contract. Thanks @hartmark for the feature.

Review found a credential-reflection defect in error handling: authenticated proxy responses could expose literal or SecretRef header values, including decoded Basic-auth pairs/passwords. The existing Ollama exact-header redactor now lives in the shared provider HTTP owner; Comfy and Ollama use that single implementation. Error bodies are sanitized before diagnostic extraction/truncation, and request IDs, malformed-JSON causes, and Comfy cloud terminal errors are covered. The old plugin-private redactor paths were removed.

Validation includes 322 owner/sibling tests, a final 10-test real-socket rerun, core/plugin types and targeted lint, and an independent real ComfyUI 0.34.0 run through an authenticating proxy. Real randomized outputs had different RGB pixels; fixed-seed outputs matched. Literal and SecretRef credential reflections were redacted, missing secrets opened no request, and all successful requests were authenticated. The live proof used built-in CPU image/noise nodes rather than a paid service or downloaded model. Detailed repair and live evidence; configuration and security-owner acceptance.

CI exposed two test-maintenance issues, both repaired without changing the live-tested Comfy behavior. The intentional parser-cause lint exception needed an entry in the suppression inventory; its failing reproduction now passes. Separately, current main combined #131545's private channel-start helper with #118157's test importing that old export. The pre-fix test failed three cases; the public-rollback repair passed all 246 reload tests. The equivalent canonical repair then landed independently in #131627, so this branch now rebases onto that fix and drops its duplicate test edit. Core test types also pass after refreshing frozen dependencies and rebuilding stale type-check state. Fresh Codex autoreview found no actionable findings at the configured review threshold.

Production delta, discounting moved files: +224/-55 (net +169). This adds the optional authentication/seed capability and shared credential-safety handling. Test delta: +436/-9 (net +427). No dependency or lockfile changes. The latest ClawSweeper rank-up requests are addressed. Final-head CI passed on 34873d9cf017fb770c83bb3988d48de2489a9f06; native prepare verified that exact head without another rebase.

Separate infrastructure follow-up: Testbox full-sync dependency inventory dropped the remote lockfile and tsx; restoring the exact unchanged lockfile and a frozen install recovered the live run. The test server, proxy, and lease have been stopped.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: comfy size: S labels Aug 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 28, 2026, 4:26 AM ET / 08:26 UTC.

ClawSweeper review

What this changes

Adds configurable ComfyUI HTTP headers with SecretRef support, per-request workflow seeds, response-error redaction, documentation, and tests.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

Keep open: the new arbitrary Comfy request-header surface can persist literal credentials unredacted in debug-proxy captures.

Priority: P1
Reviewed head: 34873d9cf017fb770c83bb3988d48de2489a9f06

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The feature has strong behavior evidence, but the capture-redaction defect is a merge blocker.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR discussion supplies after-fix real ComfyUI and real-socket evidence for the changed workflow behavior.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR discussion supplies after-fix real ComfyUI and real-socket evidence for the changed workflow behavior.
Evidence reviewed 7 items Introduced credential surface: The PR adds the headers.* SecretRef contract and accepts arbitrary string or object values for Comfy request headers.
Literal values bypass registration: A non-empty literal header is returned as available, while the runtime assignment collector returns before registering any value when no SecretRef exists.
Capture persistence path: The global debug-fetch patch captures ambient fetch requests without caller-sensitive header metadata; capture redaction masks only known sensitive names or values already in the registry.
Findings 1 actionable finding [P1] Redact configured Comfy headers in debug captures
Security Needs attention Literal custom header can bypass capture redaction: Literal headers are accepted as credentials but only SecretRef-resolved values are registered for exact-value redaction; the global fetch capture path cannot receive caller-sensitive names.

How this fits together

The Comfy plugin turns workflow configuration into guarded HTTP requests to local or cloud ComfyUI endpoints. Optional debug-proxy capture records those HTTP exchanges for diagnosis.

flowchart LR
  A[Comfy plugin config] --> B[Header resolution]
  B --> C[Workflow request]
  C --> D[Guarded HTTP client]
  D --> E[ComfyUI endpoint]
  D --> F[Debug proxy capture]
  F --> G[Captured diagnostics]
Loading

Before merge

  • Redact configured Comfy headers in debug captures (P1) - The new headers.* value reaches every Comfy request here, but literal values are not SecretRef assignments and therefore never enter the redaction registry. With debug-proxy capture enabled, ambient global fetch persists headers without the guarded-fetch sensitive-name metadata; an innocuous name such as X-Proxy does not match the capture redactor's built-in list. Register these values before transport (or preserve equivalent sensitivity through both capture paths) and add a capture-storage regression test.
  • Resolve security concern: Literal custom header can bypass capture redaction - Literal headers are accepted as credentials but only SecretRef-resolved values are registered for exact-value redaction; the global fetch capture path cannot receive caller-sensitive names.
  • Resolve merge risk (P1) - With debug-proxy capture enabled, a literal credential under an innocuous configured header name such as X-Proxy can be written to captured diagnostics unredacted.
  • Complete next step (P2) - Require the security fix and capture-level regression before rerunning exact-head review and CI.

Findings

  • [P1] Redact configured Comfy headers in debug captures — extensions/comfy/workflow-runtime.ts:793
  • [high] Literal custom header can bypass capture redaction — extensions/comfy/workflow-runtime.ts:793
Agent review details

Security

Needs attention: The new arbitrary-header feature has a concrete sensitive-data exposure through persisted debug-proxy captures.

PR surface

Source +169, Tests +427, Docs +26, Other 0. Total +622 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 8 224 55 +169
Tests 5 436 9 +427
Docs 4 43 17 +26
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 18 704 82 +622

Review metrics

Metric Value Why it matters
Production versus test delta production/config +224/-55; tests +436/-9; docs +36/-17; generated registry +7 The feature materially expands runtime and credential-handling code, so the capture boundary needs direct regression coverage.
Configuration surface 3 keys added: headers, seedNodeId, seedInputName The new header map can carry credentials and affects every Comfy request type.

Merge-risk options

Maintainer options:

  1. Close the capture redaction gap (recommended)
    Ensure arbitrary configured Comfy header values are redacted in both guarded and ambient global-fetch captures, then add a capture-level regression test.

Technical review

Best possible solution:

Register configured Comfy header values for canonical redaction before either capture path runs, including ambient global fetch, and add a capture-storage regression covering an arbitrary literal header.

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

Yes, source-reproducible: configure a literal opaque value under an innocuous headers.* name, enable debug-proxy capture, run a Comfy request, and inspect the captured request headers; this was not executed in the read-only checkout.

Is this the best way to solve the issue?

No: the patch redacts reflected provider errors, but not the debug-proxy persistence path for arbitrary literal header names.

Full review comments:

  • [P1] Redact configured Comfy headers in debug captures — extensions/comfy/workflow-runtime.ts:793
    The new headers.* value reaches every Comfy request here, but literal values are not SecretRef assignments and therefore never enter the redaction registry. With debug-proxy capture enabled, ambient global fetch persists headers without the guarded-fetch sensitive-name metadata; an innocuous name such as X-Proxy does not match the capture redactor's built-in list. Register these values before transport (or preserve equivalent sensitivity through both capture paths) and add a capture-storage regression test.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0a068cf3f1ef.

Labels

Label changes:

  • add P1: The branch introduces a concrete credential-disclosure path in an operator diagnostic surface.
  • add merge-risk: 🚨 security-boundary: Merging enables arbitrary literal credentials to reach persisted debug captures without guaranteed redaction.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR discussion supplies after-fix real ComfyUI and real-socket evidence for the changed workflow behavior.
  • remove P2: Current review triage priority is P1, so this older priority label is no longer current.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review merge-risk labels are merge-risk: 🚨 security-boundary.
  • remove merge-risk: 🚨 auth-provider: Current PR review merge-risk labels are merge-risk: 🚨 security-boundary.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The branch introduces a concrete credential-disclosure path in an operator diagnostic surface.
  • merge-risk: 🚨 security-boundary: Merging enables arbitrary literal credentials to reach persisted debug captures without guaranteed redaction.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR discussion supplies after-fix real ComfyUI and real-socket evidence for the changed workflow behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR discussion supplies after-fix real ComfyUI and real-socket evidence for the changed workflow behavior.

Evidence

Security concerns:

  • [high] Literal custom header can bypass capture redaction — extensions/comfy/workflow-runtime.ts:793
    Literal headers are accepted as credentials but only SecretRef-resolved values are registered for exact-value redaction; the global fetch capture path cannot receive caller-sensitive names.
    Confidence: 0.98

What I checked:

  • Introduced credential surface: The PR adds the headers.* SecretRef contract and accepts arbitrary string or object values for Comfy request headers. (extensions/comfy/openclaw.plugin.json:9, 34873d9cf017)
  • Literal values bypass registration: A non-empty literal header is returned as available, while the runtime assignment collector returns before registering any value when no SecretRef exists. (src/config/types.secrets.ts:270, 34873d9cf017)
  • Capture persistence path: The global debug-fetch patch captures ambient fetch requests without caller-sensitive header metadata; capture redaction masks only known sensitive names or values already in the registry. (src/proxy-capture/runtime.ts:349, 34873d9cf017)
  • Comfy request sink: The introduced resolver passes configured headers into the request configuration, which reaches all submit, poll, upload, and download requests. (extensions/comfy/workflow-runtime.ts:793, 34873d9cf017)
  • Existing owner-bound precedent: The MCP connection resolver registers every resolved header value before transport specifically so debug-proxy capture and logs redact it. (src/agents/mcp-connection-resolver.ts:198, 34873d9cf017)
  • Current-main status: The checked-out PR head is not an ancestor of fetched main 0a068cf, so main has not already incorporated this branch. (0a068cf3f1ef)

Likely related people:

  • steipete: Authored the shared request-header redaction follow-up that this Comfy feature relies on. (role: recent area contributor; confidence: medium; commits: 5c58e022a3; files: extensions/comfy/workflow-runtime.ts, src/agents/provider-request-header-redaction.ts)

Rank-up moves

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

  • Add an end-to-end debug-capture assertion for an arbitrary literal configured header and fix both capture paths.

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 (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-27T11:39:44.540Z sha e32863dc6cd085ea16d6afeb892c10e92a047e13 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-27T13:06:36.589Z sha e32863dc6cd085ea16d6afeb892c10e92a047e13 :: found issues before merge. :: [P3] Restore inherited environment variables after the socket test
  • reviewed 2026-08-27T16:03:57.733Z sha 46f16a9f009535032543eea5a071c64df702413b :: needs changes before merge. :: [P3] Restore inherited environment variables after socket tests
  • reviewed 2026-08-27T17:27:51.534Z sha 4b0a290 :: needs changes before merge. :: [P3] Restore inherited environment variables after socket tests
  • reviewed 2026-08-27T19:01:51.887Z sha 4b0a290 :: needs changes before merge. :: [P3] Restore inherited environment variables after socket tests
  • reviewed 2026-08-28T00:12:22.307Z sha 99b40ffae2cf554d2702d70850c080f18150eb62 :: found issues before merge. :: [P1] Redact configured headers from Comfy error responses
  • reviewed 2026-08-28T05:36:40.534Z sha 868b12a86c758943ba7f55b377501909c23cf77b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T07:40:30.967Z sha 4b16ee69c09df013ba386107218fee6f959c0eff :: needs maintainer review before merge. :: none

@hartmark

Copy link
Copy Markdown
Contributor Author

Addressed the two blocking items:

  1. Nested capability headers schema mismatch — narrowed scope rather than expanding it: headers is documented and scoped as shared-only (matches mode/baseUrl/apiKey/allowPrivateNetwork, which are already shared-only for the same reason — one ComfyUI connection, one auth scheme, regardless of which capability is calling it). Updated the PR body to stop implying per-capability headers were supported.
  2. Real behavior proof — added to the PR body: a live image_generate call through the actual deployed plugin via the running gateway process (toolSummary: { calls: 1, failures: 0 }, task status: succeeded, real 1024x1024 PNG delivered), plus 5 distinct real seed values pulled directly from the ComfyUI instance's own /history endpoint (which only returns data with valid Basic Auth), confirming both auth and seed randomization work end-to-end in production.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
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:

@hartmark
hartmark force-pushed the feat/comfy-headers-seed-randomization branch from fab0127 to 7f28067 Compare August 26, 2026 12:39
@hartmark
hartmark marked this pull request as ready for review August 26, 2026 12:40
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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 Aug 26, 2026
@hartmark

Copy link
Copy Markdown
Contributor Author

Fixed the P1 security finding: headers now resolve through the same SecretInput path apiKey already uses (schema accepts ["string", "object"], runtime resolves via resolveSecretInputString with env-backed fallback, matching the ollama plugin's precedent). A header pointed at an unresolvable secret now fails the request instead of silently sending it unauthenticated. New tests cover both the resolved and unresolvable-reference paths. Rebased onto latest main, 52/52 passing, autoreview clean.

@clawsweeper re-review

@hartmark
hartmark force-pushed the feat/comfy-headers-seed-randomization branch from 7f28067 to 44e45d9 Compare August 26, 2026 14:08
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
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:

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@hartmark

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
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:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 27, 2026
@steipete
steipete force-pushed the feat/comfy-headers-seed-randomization branch from 4b16ee6 to a1495fa Compare August 28, 2026 08:12
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 28, 2026
hartmark and others added 11 commits August 28, 2026 01:16
Local-mode ComfyUI requests only ever sent Content-Type, so a local
instance reachable behind HTTP auth (Basic auth, a bearer token) had no
way to authenticate. Add a generic headers config key, merged over the
plugin's own headers -- same shape as the ollama plugin's established
remote.headers pattern, rather than inventing a comfy-specific scheme.

Also add optional seedNodeId/seedInputName: without it, a static
workflow file's sampler seed never changes between submissions, so
every generation was silently identical whenever the operator's
workflow relies on a fresh random seed per run.
…xt-only

The new headers config accepted only literal strings, so a credential-bearing
value (Authorization for a gated ComfyUI instance) had no path to secret
storage -- unlike the existing apiKey field, which already resolves through
resolveSecretInputString with an env-backed fallback. Mirrors that same
pattern per-header, plus the ollama plugin's established header-secret
precedent: a header pointed at a SecretRef that can't be resolved fails the
request outright instead of silently sending it unauthenticated.
…esolvable ones

resolveComfyHeadersConfig only ever resolved env-sourced SecretRefs (a
manual process.env fallback bolted onto inspect-mode); any file,
keychain, or plugin-backed reference always threw, despite the schema
and docs advertising the same SecretRef shape apiKey accepts. Now
resolves through resolveConfiguredSecretInputString (the same async
resolver the ollama plugin's own headers use) for the non-literal case,
so a real non-env credential provider actually works.

Separately, isComfyCapabilityConfigured returned true for local mode
without ever inspecting headers, so an unavailable Authorization
SecretRef advertised an image/video/music tool that would always throw
on invocation. Extends the same sync inspect-based veto
resolveComfyApiKey already applies for cloud mode's apiKey.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
…er selection

hasUnavailableComfyHeaderSecret treated any non-env SecretRef as
unavailable for the isComfyCapabilityConfigured gate, on the theory that
inspect mode can't confirm it -- but "can't confirm yet" isn't "won't
resolve": the async request path can and does resolve a real
file/keychain/plugin-backed ref. That made a perfectly valid,
already-working header credential permanently hide the image/video/music
tools from the agent, which is a worse outcome than a rare genuinely
broken ref surfacing its error at actual invocation. Only a definitely
missing/empty env var (decidable synchronously, no I/O) still vetoes.

Added a permanent committed integration test
(workflow-runtime.header-secrets.integration.test.ts) that proves this,
plus the env/non-env header resolution and fail-closed paths, over real
sockets with no SDK/ssrf-runtime mocking -- replacing the throwaway
proof script from the previous push, which was deleted after running and
therefore not rerunnable or reviewable.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
headers.* accepts and resolves SecretRef values, but the manifest never
declared configContracts.secretInputs for that path -- the canonical
plugin secret lifecycle (startup materialization, owner diagnostics,
audit/configure discovery, resolved-value redaction) only walks
manifest-declared paths, so this credential surface was invisible to
all of it despite working correctly at request time. apiKey doesn't
need the same declaration (it's covered by the separate, already-wired
provider-auth system via setup.providers.envVars/providerAuthChoices);
headers.* has no other declaration path.

Also fixes two smaller findings from the same review pass: the
seed-injection test asserted the freshly-generated seed is nonzero,
but randomInt(RANDOM_SEED_EXCLUSIVE_MAX) legitimately can (rarely)
return 0 -- a flaky assertion, removed; and documents that a configured
Content-Type header is ignored specifically on image-upload requests,
where the multipart boundary must come from the runtime.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
The comfy plugin manifest change in e32863dc6cd registered
plugins.entries.comfy.config.headers.* as a secret-input target, but the
generated docs matrix and its paired markdown list weren't refreshed to
match, breaking the docs-sync CI check.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
…ilures

Reuse the Ollama exact-header redactor through the provider HTTP SDK, scrub structured and truncated diagnostics before retaining them, and cover decoded Basic credentials observed in real ComfyUI proxy failures. Preserve optional header and seed behavior while consolidating tests and documenting the shared boundary.

Co-authored-by: Markus Hartung <[email protected]>
Skip undefined HeaderRecord values allowed by Node types and document the intentional omission of unsafe parser causes in the lint exception. Actual credential and no-header error behavior remain unchanged.

Co-authored-by: Markus Hartung <[email protected]>
Keep the socket fixture compatible with the IncomingHttpHeaders union without changing its reflected-error behavior.

Co-authored-by: Markus Hartung <[email protected]>
Track the intentional preserve-caught-error suppression in the explicit inventory: raw JSON parser causes can quote request credentials. The focused inventory and provider HTTP tests pass; runtime behavior is unchanged.
@steipete
steipete force-pushed the feat/comfy-headers-seed-randomization branch from a1495fa to 34873d9 Compare August 28, 2026 08:17
@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. 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. and removed P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@steipete
steipete merged commit f7a9a36 into openclaw:main Aug 28, 2026
278 of 279 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
openclaw#130098)

* feat(comfy): support custom headers and per-request seed randomization

Local-mode ComfyUI requests only ever sent Content-Type, so a local
instance reachable behind HTTP auth (Basic auth, a bearer token) had no
way to authenticate. Add a generic headers config key, merged over the
plugin's own headers -- same shape as the ollama plugin's established
remote.headers pattern, rather than inventing a comfy-specific scheme.

Also add optional seedNodeId/seedInputName: without it, a static
workflow file's sampler seed never changes between submissions, so
every generation was silently identical whenever the operator's
workflow relies on a fresh random seed per run.

* fix(comfy): resolve headers through the SecretInput path, not plaintext-only

The new headers config accepted only literal strings, so a credential-bearing
value (Authorization for a gated ComfyUI instance) had no path to secret
storage -- unlike the existing apiKey field, which already resolves through
resolveSecretInputString with an env-backed fallback. Mirrors that same
pattern per-header, plus the ollama plugin's established header-secret
precedent: a header pointed at a SecretRef that can't be resolved fails the
request outright instead of silently sending it unauthenticated.

* fix(comfy): resolve non-env header SecretRefs, hide capability on unresolvable ones

resolveComfyHeadersConfig only ever resolved env-sourced SecretRefs (a
manual process.env fallback bolted onto inspect-mode); any file,
keychain, or plugin-backed reference always threw, despite the schema
and docs advertising the same SecretRef shape apiKey accepts. Now
resolves through resolveConfiguredSecretInputString (the same async
resolver the ollama plugin's own headers use) for the non-literal case,
so a real non-env credential provider actually works.

Separately, isComfyCapabilityConfigured returned true for local mode
without ever inspecting headers, so an unavailable Authorization
SecretRef advertised an image/video/music tool that would always throw
on invocation. Extends the same sync inspect-based veto
resolveComfyApiKey already applies for cloud mode's apiKey.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6

* fix(comfy): don't veto a resolvable non-env header secret from provider selection

hasUnavailableComfyHeaderSecret treated any non-env SecretRef as
unavailable for the isComfyCapabilityConfigured gate, on the theory that
inspect mode can't confirm it -- but "can't confirm yet" isn't "won't
resolve": the async request path can and does resolve a real
file/keychain/plugin-backed ref. That made a perfectly valid,
already-working header credential permanently hide the image/video/music
tools from the agent, which is a worse outcome than a rare genuinely
broken ref surfacing its error at actual invocation. Only a definitely
missing/empty env var (decidable synchronously, no I/O) still vetoes.

Added a permanent committed integration test
(workflow-runtime.header-secrets.integration.test.ts) that proves this,
plus the env/non-env header resolution and fail-closed paths, over real
sockets with no SDK/ssrf-runtime mocking -- replacing the throwaway
proof script from the previous push, which was deleted after running and
therefore not rerunnable or reviewable.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6

* fix(comfy): register header SecretRefs in the plugin secret contract

headers.* accepts and resolves SecretRef values, but the manifest never
declared configContracts.secretInputs for that path -- the canonical
plugin secret lifecycle (startup materialization, owner diagnostics,
audit/configure discovery, resolved-value redaction) only walks
manifest-declared paths, so this credential surface was invisible to
all of it despite working correctly at request time. apiKey doesn't
need the same declaration (it's covered by the separate, already-wired
provider-auth system via setup.providers.envVars/providerAuthChoices);
headers.* has no other declaration path.

Also fixes two smaller findings from the same review pass: the
seed-injection test asserted the freshly-generated seed is nonzero,
but randomInt(RANDOM_SEED_EXCLUSIVE_MAX) legitimately can (rarely)
return 0 -- a flaky assertion, removed; and documents that a configured
Content-Type header is ignored specifically on image-upload requests,
where the multipart boundary must come from the runtime.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6

* docs(secrets): register comfy header SecretRefs in the credential matrix

The comfy plugin manifest change in e32863dc6cd registered
plugins.entries.comfy.config.headers.* as a secret-input target, but the
generated docs matrix and its paired markdown list weren't refreshed to
match, breaking the docs-sync CI check.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6

* test(comfy): restore inherited header proof env

* fix(comfy): redact reflected request credentials across generation failures

Reuse the Ollama exact-header redactor through the provider HTTP SDK, scrub structured and truncated diagnostics before retaining them, and cover decoded Basic credentials observed in real ComfyUI proxy failures. Preserve optional header and seed behavior while consolidating tests and documenting the shared boundary.

Co-authored-by: Markus Hartung <[email protected]>

* fix(provider-http): handle optional Node header values safely

Skip undefined HeaderRecord values allowed by Node types and document the intentional omission of unsafe parser causes in the lint exception. Actual credential and no-header error behavior remain unchanged.

Co-authored-by: Markus Hartung <[email protected]>

* test(comfy): explicitly stringify reflected proxy header values

Keep the socket fixture compatible with the IncomingHttpHeaders union without changing its reflected-error behavior.

Co-authored-by: Markus Hartung <[email protected]>

* test(provider-http): register credential-safe parser error exception

Track the intentional preserve-caught-error suppression in the explicit inventory: raw JSON parser causes can quote request credentials. The focused inventory and provider HTTP tests pass; runtime behavior is unchanged.

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Patrick Erichsen <[email protected]>
Co-authored-by: Peter Steinberger <[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 docs Improvements or additions to documentation extensions: comfy extensions: ollama merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants