openclaw - 💡(How to fix) Fix Feature: Expose requestMetadata config for Bedrock cost allocation tagging [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#57360Fetched 2026-04-08 01:50:39
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

The @mariozechner/pi-ai library (bundled in OpenClaw v2026.3.28, pi-ai v0.63.1) added requestMetadata support to BedrockOptions, which forwards key-value pairs to the AWS Bedrock Converse API for split cost allocation.

However, there is currently no way to configure requestMetadata from openclaw.json — the option exists in the underlying library but is not surfaced through OpenClaw's agent or provider configuration schema.

Root Cause

The @mariozechner/pi-ai library (bundled in OpenClaw v2026.3.28, pi-ai v0.63.1) added requestMetadata support to BedrockOptions, which forwards key-value pairs to the AWS Bedrock Converse API for split cost allocation.

However, there is currently no way to configure requestMetadata from openclaw.json — the option exists in the underlying library but is not surfaced through OpenClaw's agent or provider configuration schema.

Code Example

{
  "agents": {
    "defaults": {
      "bedrockOptions": {
        "requestMetadata": {
          "project": "my-project",
          "agent": "main",
          "env": "prod"
        }
      }
    }
  }
}

---

{
  "models": {
    "providers": {
      "amazon-bedrock": {
        "requestMetadata": {
          "team": "my-team",
          "env": "prod"
        }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Summary

The @mariozechner/pi-ai library (bundled in OpenClaw v2026.3.28, pi-ai v0.63.1) added requestMetadata support to BedrockOptions, which forwards key-value pairs to the AWS Bedrock Converse API for split cost allocation.

However, there is currently no way to configure requestMetadata from openclaw.json — the option exists in the underlying library but is not surfaced through OpenClaw's agent or provider configuration schema.

Current Behavior

  • pi-ai v0.63.1 supports requestMetadata?: Record<string, string> in BedrockOptions
  • The field is passed directly to Bedrock's ConverseStream command: ...(options.requestMetadata !== undefined && { requestMetadata: options.requestMetadata })
  • But OpenClaw's openclaw.json schema has no corresponding config key to inject this value

Desired Behavior

Allow users to set requestMetadata per-agent or per-provider in openclaw.json, e.g.:

{
  "agents": {
    "defaults": {
      "bedrockOptions": {
        "requestMetadata": {
          "project": "my-project",
          "agent": "main",
          "env": "prod"
        }
      }
    }
  }
}

Or alternatively at the provider level:

{
  "models": {
    "providers": {
      "amazon-bedrock": {
        "requestMetadata": {
          "team": "my-team",
          "env": "prod"
        }
      }
    }
  }
}

Use Cases

Tag KeyExample ValuePurpose
projectmy-project-a, my-project-bPer-project cost allocation
agentmain, assistantPer-agent usage breakdown
envprod, devEnvironment separation
teammy-team-nameTeam/org cost attribution

This is especially valuable for AWS accounts where multiple projects/agents share a single Bedrock setup and cost visibility per workload is needed in AWS Cost Explorer.

Constraints

Per AWS Bedrock API:

  • Keys: max 64 chars, no aws: prefix
  • Values: max 256 chars
  • Max 50 pairs

References

  • AWS Bedrock ConverseStream API
  • pi-coding-agent CHANGELOG: "AWS Bedrock cost allocation tagging. New requestMetadata option on BedrockOptions forwards key-value pairs to the Bedrock Converse API for AWS Cost Explorer split cost allocation."

extent analysis

Fix Plan

To add support for configuring requestMetadata in openclaw.json, we need to update the OpenClaw configuration schema and the underlying library to accept and pass this configuration to the BedrockOptions.

Step 1: Update OpenClaw Configuration Schema

Add a new property requestMetadata to the bedrockOptions object in the OpenClaw configuration schema.

{
  "type": "object",
  "properties": {
    "agents": {
      "type": "object",
      "properties": {
        "defaults": {
          "type": "object",
          "properties": {
            "bedrockOptions": {
              "type": "object",
              "properties": {
                "requestMetadata": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Step 2: Update OpenClaw Library

Update the OpenClaw library to accept the requestMetadata configuration and pass it to the BedrockOptions.

import { BedrockOptions } from '@mariozechner/pi-ai';

interface OpenClawConfig {
  agents: {
    defaults: {
      bedrockOptions: {
        requestMetadata?: { [key: string]: string };
      };
    };
  };
}

const config: OpenClawConfig = // load config from openclaw.json

const bedrockOptions: BedrockOptions = {
  // ... other options ...
  requestMetadata: config.agents.defaults.bedrockOptions.requestMetadata,
};

Step 3: Add Validation

Add validation to ensure that the requestMetadata configuration conforms to the AWS Bedrock API constraints.

function validateRequestMetadata(metadata: { [key: string]: string }) {
  if (Object.keys(metadata).length > 50) {
    throw new Error('Too many request metadata pairs');
  }
  for (const [key, value] of Object.entries(metadata)) {
    if (key.length > 64 || key.startsWith('aws:')) {
      throw new Error(`Invalid request metadata key: ${key}`);
    }
    if (value.length > 256) {
      throw new Error(`Request metadata value too long: ${value}`);
    }
  }
}

validateRequestMetadata(config.agents.defaults.bedrockOptions.requestMetadata);

Verification

To verify that the fix worked, create a test configuration file openclaw.json with the requestMetadata property and run the OpenClaw application. The requestMetadata should be passed to the BedrockOptions and forwarded to the AWS Bedrock Converse API.

{
  "agents": {
    "defaults": {
      "bedrockOptions": {
        "requestMetadata": {
          "project": "my-project

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