[Feature]: Openclaw plugin supports X-OpenViking-Account and X-OpenViking-User
Problem Statement
Problem
The OpenClaw openviking plugin currently works with apiKey, but it does not properly
support multi-tenant production usage with explicit accountId and userId.
Before patching locally, the plugin always sent requests effectively as default/default,
because X-OpenViking-Account and X-OpenViking-User were not configurable through plugin
config and were hardcoded to empty values in the client setup.
This causes a problem when OpenViking is running in production mode with root_api_key:
root_api_keycan authenticate successfully- but requests are still routed to the default tenant
- newly created real accounts/users are not actually used by the plugin
As a result, OpenClaw appears to work, but all memory/session/resource writes still go into
the default tenant instead of the intended production account.
Expected behavior
The plugin should support tenant-aware configuration, for example:
accountIduserId
and pass them through as:
X-OpenViking-AccountX-OpenViking-User
This is required when using root_api_key with a real OpenViking account/user in
production.
Additional issue
Even after adding accountId / userId support in code, Gateway config validation fails
unless the plugin schema also includes these fields.
So this needs to be fixed in both:
- runtime plugin config parsing
- plugin config schema / metadata
Proposed Solution
Proposal
Add first-class multi-tenant support to the OpenClaw openviking plugin.
Proposed changes
-
Extend plugin config with:
accountIduserId
-
Pass these values through on every OpenViking request as:
X-OpenViking-AccountX-OpenViking-User
-
Update the plugin config schema so Gateway accepts these fields.
-
Optionally allow env fallback, for example:
OPENVIKING_ACCOUNT_IDOPENVIKING_USER_ID
Why
This makes the plugin work correctly with OpenViking production mode when using
root_api_key, and prevents requests from silently falling back to the default tenant.
Without this, OpenClaw may appear functional, but all data is written to the wrong tenant.
Alternatives Considered
No response
Feature Area
Core (Client/Engine)
Use Case
Openclaw
Example API (Optional)
Additional Context
No response
Contribution
- [ ] I am willing to contribute to implementing this feature
Resolved in main.
Root cause: the OpenClaw OpenViking plugin had client-side support for tenant headers, but the plugin runtime did not expose/pass tenant identity from plugin config. In practice the client was initialized with empty tenant values, and the OpenClaw plugin manifest schema did not accept accountId/userId, so root-key production deployments could still route writes to the default tenant.
Fix point:
- Primary fix: ef2513c3e73be47c640c15c4dcd2b0a71a0c5f5d, committed 2026-04-21 16:02:06 +0800 (2026-04-21 08:02:06 UTC), via #1606, "feat(openclaw-plugin): align auth, namespace, and role id handling".
- Added accountId/userId to plugin config parsing, including OPENVIKING_ACCOUNT_ID / OPENVIKING_USER_ID fallback.
- Passed cfg.accountId / cfg.userId into OpenVikingClient instead of hardcoded empty tenant values.
- Added accountId/userId to openclaw.plugin.json config schema so Gateway validation accepts the fields.
- Preserved explicit tenant headers for root-key style api_key flows.
- Follow-up hardening: 08dcfc10ac5ab75a2e15442aaefbb305faff3600, committed 2026-04-29 11:49:37 +0800 (2026-04-29 03:49:37 UTC), via #1789, "fix(openclaw-plugin): stop synthesizing tenant headers".
- Ensures X-OpenViking-Account / X-OpenViking-User are only sent when explicitly configured, while normal user-key flow lets the server derive identity from the API key.
Current verification on origin/main:
- examples/openclaw-plugin/config.ts parses accountId/userId and env fallbacks.
- examples/openclaw-plugin/index.ts passes cfg.accountId/cfg.userId into OpenVikingClient.
- examples/openclaw-plugin/client.ts sends X-OpenViking-Account and X-OpenViking-User when configured.
- examples/openclaw-plugin/openclaw.plugin.json includes accountId/userId in the schema.
- Related tests cover config parsing, tenant header propagation, user-key no-override behavior, and tool/search propagation.
Local verification command:
npm test -- --run tests/ut/config.test.ts tests/ut/client.test.ts tests/ut/manifest-contracts.test.ts tests/ut/tools.test.ts
Result: 4 test files passed, 126 tests passed.
Closing this issue as resolved. For root_api_key deployments, configure both accountId and userId; for normal user API keys, leave them unset and identity is derived by the server.