Summary
An agent session accumulated 237,817 tokens (exceeding Claude's 200k limit) after calling gateway(action: "config.schema"), which returned 394,396 characters (~100k tokens) of JSON Schema data.
This caused repeated embedded run timeout errors as every subsequent API call failed with prompt is too long.
Root Cause
When an agent wanted to check logging format options, it called:
{"action": "config.schema"}
The agent only needed to understand logging configuration, but received the entire OpenClaw configuration schema - including all channels, plugins, UI hints, and field definitions.
Evidence
From session 84018b53-6210-4868-a7ed-62c6e83d42cb:
| Time (UTC) |
Total Tokens |
Event |
| 03:03:07 |
20,300 |
Normal operation |
| 03:20:31 |
32,574 |
Read config file |
| 03:20:34 |
147,874 |
config.schema returned 394k chars |
| 03:33:37 |
210,633 |
First prompt too long error |
| 03:34+ |
237,817 |
All requests fail, 10-minute timeout loop |
Error message:
prompt is too long: 237817 tokens > 200000 maximum
Suggested Fixes
Option A: Truncate or summarize large toolResults
Add a size limit to toolResult content before adding to session history. For schema-like responses, return a summary instead of full content.
Option B: Add scope parameter to config.schema
// Instead of returning everything:
gateway({ action: "config.schema" })
// Allow scoped queries:
gateway({ action: "config.schema", scope: "logging" })
gateway({ action: "config.schema", scope: "channels.telegram" })
Option C: Session history auto-compression
When session approaches token limit, automatically compress/summarize older tool results.
Option D: Warn agent about large responses
Before executing config.schema, warn that it returns a large response and suggest alternatives like reading docs or using config.get.
Related Code
src/agents/tools/gateway-tool.ts:171-174 - tool entry point
src/gateway/server-methods/config.ts:110-151 - handler
src/config/schema.ts:1081-1103 - buildConfigSchema() generates full schema
Impact
- 10 consecutive
embedded run timeout errors over 7.5 hours
- Agent completely blocked until session is manually cleared
- Wastes API quota on failed requests
Discovered while investigating repeated timeout errors in gateway logs.
Summary
An agent session accumulated 237,817 tokens (exceeding Claude's 200k limit) after calling
gateway(action: "config.schema"), which returned 394,396 characters (~100k tokens) of JSON Schema data.This caused repeated
embedded run timeouterrors as every subsequent API call failed withprompt is too long.Root Cause
When an agent wanted to check logging format options, it called:
{"action": "config.schema"}The agent only needed to understand logging configuration, but received the entire OpenClaw configuration schema - including all channels, plugins, UI hints, and field definitions.
Evidence
From session
84018b53-6210-4868-a7ed-62c6e83d42cb:config.schemareturned 394k charsprompt too longerrorError message:
Suggested Fixes
Option A: Truncate or summarize large toolResults
Add a size limit to toolResult content before adding to session history. For schema-like responses, return a summary instead of full content.
Option B: Add
scopeparameter to config.schemaOption C: Session history auto-compression
When session approaches token limit, automatically compress/summarize older tool results.
Option D: Warn agent about large responses
Before executing
config.schema, warn that it returns a large response and suggest alternatives like reading docs or usingconfig.get.Related Code
src/agents/tools/gateway-tool.ts:171-174- tool entry pointsrc/gateway/server-methods/config.ts:110-151- handlersrc/config/schema.ts:1081-1103-buildConfigSchema()generates full schemaImpact
embedded run timeouterrors over 7.5 hoursDiscovered while investigating repeated timeout errors in gateway logs.