Summary
The gateway tool's config.schema action returns the entire JSON schema + help text (~373KB / 372,946 characters), which stays in session context and causes token explosion.
Impact
- Sessions hitting 170K+ tokens (near 200K limit)
- Single
config.schema call adds ~100K tokens to context
- Multiple calls compound the problem (observed 2x dumps = 766KB in one session)
Reproduction
- Agent encounters "invalid config" error from
config.patch
- Agent requests
config.schema to understand correct structure
- Gateway returns full 373KB schema
- Context explodes; session becomes unusable
Evidence
Session 7c03a526: 1 config.schema call → 170,505 tokens
Session 6ed0d989: 2 config.schema calls → 766KB stored, 2.3MB session file
Tool result sample (line 109):
{
"ok": true,
"result": {
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": { ... 372KB of schema ... }
}
}
}
Suggested Fixes
- Truncate/summarize the schema response (return only relevant section based on query)
- Paginate the schema (return top-level keys first, drill down on request)
- Size limit on tool responses stored in session history
- Exclude from context - mark large tool results as non-cacheable in session
Environment
- clawdbot version: 2026.1.24-3
- Model: claude-opus-4-5-20251101 / claude-sonnet-4-20250514
- Platform: macOS Darwin 25.2.0
Summary
The
gatewaytool'sconfig.schemaaction returns the entire JSON schema + help text (~373KB / 372,946 characters), which stays in session context and causes token explosion.Impact
config.schemacall adds ~100K tokens to contextReproduction
config.patchconfig.schemato understand correct structureEvidence
Tool result sample (line 109):
{ "ok": true, "result": { "schema": { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { ... 372KB of schema ... } } } }Suggested Fixes
Environment