openclaw - ✅(Solved) Fix Feature: Pass field through to provider API request body [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#64812Fetched 2026-04-12 13:26:38
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Fix Action

Fix / Workaround

Use streamWithPayloadPatch (the same pattern already used for parallelToolCalls) to inject the user field into the API request body when it's defined in effectiveExtraParams.

  • src/agents/pi-embedded-runner/extra-params.ts — single file change
  • No API changes, no breaking changes, no config schema changes
  • Follows existing pattern (createParallelToolCallsWrapper uses streamWithPayloadPatch)
  • Only applies when user is set in config — zero overhead otherwise

PR fix notes

PR #64813: feat: pass user field through to API request body

Description (problem / solution / changelog)

Summary

  • Problem: OpenClaw's createStreamFnWithExtraParams silently drops the user field from agent/model config params, preventing per-request attribution on OpenRouter/OpenAI.
  • Why it matters: Users cannot use provider features like OpenRouter broadcast, cost-per-project tracking, or abuse detection.
  • What changed: Added createUserFieldWrapper that uses streamWithPayloadPatch to inject user into the API request body (same pattern as parallelToolCalls).
  • What did NOT change: No changes to config schema, no new config options, no changes to providers. Single file, single concern.

Change Type

  • Feature

Details

When user is set in agent/model params:

{
  "agents": {
    "defaults": {
      "params": {
        "user": "mission-control"
      }
    }
  }
}

The gateway now injects it into every API request body via streamWithPayloadPatch. Zero overhead when user is not set.

Implementation: Follows the exact same pattern as createParallelToolCallsWrapper — wraps the stream function with streamWithPayloadPatch to modify the JSON payload before it's sent to the provider.

Fixes #64812

Changed files

  • src/agents/pi-embedded-runner/extra-params.ts (modified, +29/-0)

Code Example

{
  "agents": {
    "defaults": {
      "params": {
        "user": "mission-control"
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

OpenClaw's gateway accepts arbitrary params in agent/model config (agents.defaults.params), but createStreamFnWithExtraParams has a hardcoded allowlist of fields that get passed to the API request:

  • temperature
  • maxTokens
  • transport
  • openaiWsWarmup
  • cachedContent/cached_content
  • cacheRetention

All other fields — including the user parameter — are silently dropped. This means setting "user": "mission-control" in openclaw.json does nothing.

Why it matters

Both OpenRouter and OpenAI accept a user field in their chat completion requests for:

  • Per-request attribution — OpenRouter's broadcast feature uses this for cost-per-project tracking
  • Abuse detection — Both providers use it for rate limiting and abuse patterns
  • Request correlation — Enables users to correlate their application's request IDs with provider logs

Without user passthrough, OpenClaw users cannot use these provider features at all.

Proposed solution

Use streamWithPayloadPatch (the same pattern already used for parallelToolCalls) to inject the user field into the API request body when it's defined in effectiveExtraParams.

Config usage:

{
  "agents": {
    "defaults": {
      "params": {
        "user": "mission-control"
      }
    }
  }
}

The user field would then appear in every API request, enabling OpenRouter broadcast attribution and similar provider features.

Scope

  • src/agents/pi-embedded-runner/extra-params.ts — single file change
  • No API changes, no breaking changes, no config schema changes
  • Follows existing pattern (createParallelToolCallsWrapper uses streamWithPayloadPatch)
  • Only applies when user is set in config — zero overhead otherwise

Related

PR: #64748 (incoming)

Notes

This handles the static user case. Dynamic fields (e.g., injecting graph/task IDs per-request) would need a separate mechanism — potentially a gateway hook that evaluates a template at request time.

extent analysis

TL;DR

Use the streamWithPayloadPatch pattern to inject the user field into the API request body when defined in effectiveExtraParams.

Guidance

  • Modify the src/agents/pi-embedded-runner/extra-params.ts file to include the user field in the allowlist of fields passed to the API request.
  • Update the createStreamFnWithExtraParams function to use streamWithPayloadPatch and inject the user field into the API request body.
  • Verify that the user field is correctly passed to the API request by checking the request payload.
  • Test the updated functionality with a sample config, such as the provided openclaw.json example.

Example

{
  "agents": {
    "defaults": {
      "params": {
        "user": "mission-control"
      }
    }
  }
}

This config example demonstrates how to set the user field in openclaw.json.

Notes

This solution only addresses the static user case and does not handle dynamic fields. A separate mechanism, potentially a gateway hook, would be needed to inject dynamic fields like graph or task IDs per-request.

Recommendation

Apply the proposed workaround using streamWithPayloadPatch to inject the user field into the API request body, as it provides a non-intrusive and targeted solution to the problem without requiring API changes or breaking existing functionality.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING