Skip to content

config.schema returns 373KB response, causing context explosion #7347

@jhwright

Description

@jhwright

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

  1. Agent encounters "invalid config" error from config.patch
  2. Agent requests config.schema to understand correct structure
  3. Gateway returns full 373KB schema
  4. 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

  1. Truncate/summarize the schema response (return only relevant section based on query)
  2. Paginate the schema (return top-level keys first, drill down on request)
  3. Size limit on tool responses stored in session history
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions