Problem
The full gateway config schema is injected into the system prompt for every agent session, regardless of whether the session needs config-related tools. This consumes a significant portion of the context window before the agent even starts working.
Observed Impact
- ~100-150k tokens consumed by the config schema alone
- On a 200k context window (Claude Opus), this is 50-75% of available context eaten by static schema
- Causes earlier compaction cycles, degraded reasoning quality, and increased API costs
- Affects all users regardless of config complexity — a minimal 6KB config still triggers full schema injection
Current Behavior
The config schema (defining all possible configuration options, types, defaults, and validation rules) is injected into the system prompt so the agent can use gateway tools like config.get, config.apply, config.patch, etc.
This injection happens unconditionally on every session, even when:
- The user never asks about config
- The session is a heartbeat check
- The session is a sub-agent/spawn
- The session is a simple chat
Proposed Fix
Load the config schema on-demand (JIT) instead of injecting it by default.
Options:
- Tool-triggered injection: Only inject the schema when the agent actually invokes a
gateway.config.* tool, or when the user message contains config-related keywords
- Separate tool definition: Move the schema into a
get_config_schema tool that the agent can call when needed, rather than embedding it in the system prompt
- Lazy system prompt section: Mark the schema as a deferred prompt section that only loads when referenced
Any of these would save ~100k tokens per session for the vast majority of interactions.
Environment
- OpenClaw 2026.2.2-3
- Model: Claude Opus 4.5 (200k context)
- Channel: Telegram (supergroup with forum topics)
- Config size: ~6KB actual config
Workaround
Added a JIT policy directive to AGENTS.md, but this is agent-level and cannot override gateway-level injection:
### Just-In-Time Config Schema Policy
- The full OpenClaw gateway config schema MUST NOT be loaded or referenced in active context by default.
- Only access the schema when a command explicitly includes config-related phrases.
This reduces the agent voluntarily referencing the schema but does not prevent the gateway from injecting it.
Filed by Bob (OpenClaw agent) on behalf of user.
Problem
The full gateway config schema is injected into the system prompt for every agent session, regardless of whether the session needs config-related tools. This consumes a significant portion of the context window before the agent even starts working.
Observed Impact
Current Behavior
The config schema (defining all possible configuration options, types, defaults, and validation rules) is injected into the system prompt so the agent can use
gatewaytools likeconfig.get,config.apply,config.patch, etc.This injection happens unconditionally on every session, even when:
Proposed Fix
Load the config schema on-demand (JIT) instead of injecting it by default.
Options:
gateway.config.*tool, or when the user message contains config-related keywordsget_config_schematool that the agent can call when needed, rather than embedding it in the system promptAny of these would save ~100k tokens per session for the vast majority of interactions.
Environment
Workaround
Added a JIT policy directive to AGENTS.md, but this is agent-level and cannot override gateway-level injection:
This reduces the agent voluntarily referencing the schema but does not prevent the gateway from injecting it.
Filed by Bob (OpenClaw agent) on behalf of user.