Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 5, 2026, 9:15 AM ET / 13:15 UTC (Revision 15). ClawSweeper reviewWhat this changesAdds an optional safetyIdentifier model setting that sends a validated identifier with native OpenAI Responses and Chat Completions requests, with documentation and focused tests. Merge readiness⛔ Blocked before merge - 3 items remain This PR remains useful: current main lacks the requested capability, and the contributor supplied convincing live API traces. No blocking code defect was found; acceptance of the additive public SDK behavior remains unresolved. Priority: P3 Review scores
Verification
How this fits togetherThe embedded OpenClaw runtime merges model settings and passes them through provider stream wrappers before sending model requests. This change adds a request field only for supported OpenAI Platform routes. flowchart TD
A[Operator model settings] --> B[Merged provider parameters]
B --> C[Validate safety identifier]
C --> D[Check provider and endpoint]
D --> E[Native OpenAI request]
D --> F[Other request unchanged]
E --> G[Preserve caller value or add identifier]
Decision needed
Why: Live API acceptance establishes technical feasibility, but does not authorize a new configuration capability or settle its public SDK semantics. Before merge
Agent review detailsSecurityNone. PR surfaceSource +89, Tests +234, Docs +4. Total +327 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one opt-in OpenAI-owned request wrapper, preserve caller precedence and endpoint exclusions, and make its static hashed-identity scope explicit in the accepted SDK contract. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect reproduction: this adds a capability absent from current main. The supplied real agent traces demonstrate the proposed field on both supported API paths. Is this the best way to solve the issue? Yes, technically: the existing provider family and shared endpoint policy are a narrow implementation path. Acceptance of the static configuration scope remains a maintainer choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f71437a98f53. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (14 earlier review cycles; latest 8 shown)
|
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The endpoint gating is appropriately conservative: the field is injected only for native OpenAI Platform requests, not because a provider merely calls itself OpenAI. Preserving caller-provided safety_identifier and ignoring empty/invalid config avoids surprising request mutation. Keeping identity derivation out of scope is also correct; a static configured identifier should not silently become a per-user privacy policy.
|
@clawsweeper re-review Pushed 910851d5: cap |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
910851d to
01c96c4
Compare
|
@clawsweeper re-review Pushed 01c96c42 (rebased onto current
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Pushed 3b466fc0 (rebased onto current The prior |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
46d89cd to
3b466fc
Compare
|
CI note for maintainers: the Currently failing on
Flaky timing/resource failures (pass locally, other PRs pass the same shards):
Was failing on
Resolved by merging main:
Fixed in this PR: the The branch is merged up to current main (2026-10-05: resolved a conflict from upstream dropping the explicit |
Add a per-model `params.safetyIdentifier` / `params.safety_identifier` that OpenClaw forwards as OpenAI's `safety_identifier` request field on native OpenAI Platform Responses and Chat Completions requests, so abuse-monitoring signals can be attributed to a deployment or hashed end user. - Gate injection through the shared Responses payload policy (`allowsSafetyIdentifier`): api.openai.com only; the ChatGPT/Codex backend, Azure OpenAI, and OpenAI-compatible proxies are untouched. - Caller-provided `safety_identifier` values win; empty, non-string, or oversized values are ignored with a warning. - Wire the wrapper into the `openai-responses-defaults` stream family alongside `serviceTier`. - Cover Responses, Chat Completions, snake_case alias, caller precedence, and non-native routes in the extra-params test suite; document the param. Co-Authored-By: Claude Fable 5.1 <[email protected]>
… limit OpenAI documents `safety_identifier` as a per-user string with a maximum length of 64 characters. Reject longer values with a warning instead of forwarding them, add a focused test, and note the limit in the config docs. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…precedence intact Extra params are merged across global, per-model, and per-agent scopes by literal key before the resolver runs, so accepting a snake_case alias let a lower-precedence scope's spelling win over a higher-precedence override. Recognise only `params.safetyIdentifier`, cover the rejected alias in tests, and update the docs. Co-Authored-By: Claude Fable 5.1 <[email protected]>
3b466fc to
1485d51
Compare
…identifier # Conflicts: # docs/providers/openai.md
…g modules main now enforces a line-cap ratchet that rejects growth in files already over their cap. The safety-identifier resolver and wrapper move from stream-wrappers/openai.ts into stream-wrappers/openai-safety-identifier.ts, and their focused tests move from embedded-agent-runner-extraparams.test.ts into embedded-agent-runner-extraparams-openai-safety-identifier.test.ts, following the existing provider-sibling pattern. No behavior change; both original files return to their main line counts. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…identifier # Conflicts: # packages/ai/src/transports/openai-responses-payload-policy.ts
|
Thanks @lgrosales for the proposal and careful privacy notes. Current main already forwards an explicit I landed the credited docs replacement #189686 to make that existing path discoverable. Closing in favor of that configuration path. Direct |
Closes #138287
What Problem This Solves
Operators running OpenClaw against the OpenAI Platform cannot follow OpenAI's safety identifier guidance. The built-in
openaiprovider uses the Responses API for agent turns, and the only request-body override OpenClaw offers,params.extra_body, is applied toopenai-completionsbodies only. There is no plugin hook that can patch the OpenAI provider's outgoing payload either. Shared deployments (for example a Slack assistant serving a team) therefore send every request without asafety_identifier, so OpenAI cannot attribute abuse-monitoring signals or give actionable policy feedback.Why This Change Was Made
Adds a per-model
params.safetyIdentifierthat is forwarded as OpenAI'ssafety_identifierfield. The resolver and wrapper live in a sibling module,src/llm/providers/stream-wrappers/openai-safety-identifier.ts, and are applied in theopenai-responses-defaultsstream family the same wayserviceTieris, and gated through the shared Responses payload policy (allowsSafetyIdentifier) so it is only injected forprovider: "openai"onapi.openai.comusing Responses, the Responses transport, or Chat Completions. The ChatGPT/Codex backend, Azure OpenAI, and OpenAI-compatible proxies are not verified to accept the field and are left untouched. Caller-providedsafety_identifiervalues win; empty, non-string, or over-64-character values (OpenAI's documented limit) are ignored with a warning. Nothing is sent unless the param is configured.Only the camelCase spelling is recognised, deliberately. Extra params are merged across the global, per-model, and per-agent scopes by literal key before the resolver runs, so accepting a snake_case alias would let a lower-precedence scope's spelling silently win over a higher-precedence override written the other way. A single key keeps the documented scope precedence intact; a test asserts the alias is not honoured.
Non-goal: automatically deriving a per-session or per-sender identifier. That needs a design for what OpenClaw hashes and how channels expose sender identity, so this PR ships the static config value as the minimal first step.
User Impact
Operators can set a stable, hashed, non-PII identifier per OpenAI model and have it carried on every native OpenAI Platform request:
{ "agents": { "defaults": { "models": { "openai/gpt-5.4": { "params": { "safetyIdentifier": "sha256-of-your-user-or-deployment-id" } } } } } }Existing configurations are unaffected. Documented in
docs/gateway/config-agents/models.mdanddocs/providers/openai.md.Evidence
Focused tests in
src/agents/embedded-agent-runner-extraparams-openai-safety-identifier.test.ts(a sibling of the main extra-params suite, following the existing Moonshot/OpenRouter pattern so the over-cap main file does not grow) cover Responses injection, native Chat Completions injection, whitespace trimming, caller-provided precedence, and no injection for the ChatGPT/Codex backend, Azure OpenAI, proxied base URLs, empty values, non-string values, a snake_case alias (single canonical spelling), and values over OpenAI's 64-character limit.Local validation on this branch rebased onto current
main(bd8b6b7):External contract: OpenAI accepts
safety_identifieron both request pathsThe review bot noted it could not reach OpenAI's documentation to verify the field. The contract is pinned in OpenAI's official SDK sources, which are generated from the OpenAPI spec:
41f85bd:src/resources/responses/responses.ts#L127241f85bd:src/resources/chat/completions/completions.ts#L22988326784:response_create_params.py#L205, where the legacyuserfield is documented as "being replaced bysafety_identifierandprompt_cache_key".Field documentation as shipped in those SDKs, identical for both endpoints:
The 64-character maximum is enforced by this PR's resolver. Guide: https://developers.openai.com/api/docs/guides/safety-best-practices#safety_identifiers
Live trace: native OpenAI Platform requests carrying
safety_identifier(HTTP 200)Captured with OpenClaw's own debug proxy (
openclaw proxy run -- openclaw agent exec ...) using this PR's build (openclaw --version→2026.9.2 (01c96c4), the previous head; the rebase onto bd8b6b7 changed no PR files), in an isolated state directory withplugins.deny: ["codex"],agentRuntime: { id: "openclaw" }on the model,params.safetyIdentifier: "clipo-d79375b3e064b1715aa542cd43249bfe", andmodels.providers.openai.request.allowPrivateNetwork: trueso the loopback capture proxy is permitted. The API key was supplied via an env-backed SecretRef and never appears in logs or captures;authorizationheaders below are redacted by the capture inspector.Responses API (
api: "openai-responses",params.transport: "sse")Captured outbound request (capture event
kind=request,captureOrigin=guarded-fetch, gzip blob 117,286 B decoded):Chat Completions (same provider with
api: "openai-completions")Both requests were accepted by api.openai.com (HTTP 200, streamed completion, model reply
OK) withsafety_identifierpresent in the body exactly as the resolver produced it.Note for operators: the field is injected by the embedded OpenClaw runtime. Turns delegated to the Codex agent harness use its own app-server transport and are unaffected; pin
agentRuntime: { id: "openclaw" }on the model (or deny the Codex plugin) where the identifier must be sent.CI note
The earlier
control-ui-performancefailure (startup JS gzip 350353 B vs a 350141 B enforcement limit) came from the branch predating the 2026-09-04 baseline bump onmainto 350377 B; this PR touches no Control UI code and the UI does not import any changed module. Rebasing onto currentmainpicks up the new committed baseline.Confirmed on current
mainthat there are no existing occurrences ofsafety_identifierorsafetyIdentifierinsrc/,packages/,extensions/, ordocs/.Written with Claude Code; the
autoreviewskill was not available in the authoring environment.🤖 Generated with Claude Code