langchain-ai/deepagents · error · ValueError

workspace configuration is too large

Error message

workspace configuration is too large

What it means

`canonical_workspace_config` enforces a maximum canonical serialized size (`_MAX_CONFIG_LENGTH`) so workspace binding rows and fingerprints stay bounded. This ValueError means the serialized config exceeded that limit.

Source

Thrown at libs/code/deepagents_code/workspace.py:116

    """Return bounded canonical JSON and its SHA-256 fingerprint.

    Raises:
        TypeError: If the configuration is not an object.
        ValueError: If it cannot be serialized or exceeds the size limit.
    """
    if value is None:
        value = {}
    if not isinstance(value, dict):
        msg = "workspace_config must be an object"
        raise TypeError(msg)
    try:
        serialized = json.dumps(value, sort_keys=True, separators=(",", ":"))
    except (TypeError, ValueError) as exc:
        msg = "workspace configuration must be JSON serializable"
        raise ValueError(msg) from exc
    if len(serialized) > _MAX_CONFIG_LENGTH:
        msg = "workspace configuration is too large"
        raise ValueError(msg)
    return serialized, hashlib.sha256(serialized.encode()).hexdigest()


def _fingerprint(value: object) -> str:
    serialized = json.dumps(value, sort_keys=True, separators=(",", ":"))
    return hashlib.sha256(serialized.encode()).hexdigest()


def resolve_workspace(
    cwd: object,
    workspace_config: object | None = None,
    *,
    config_fingerprint: str | None = None,
) -> WorkspaceBinding:
    """Resolve and validate a client workspace claim.

    Returns:
        A canonical, fingerprinted binding including the resource policy.

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Trim the config to essential small key/value settings
  2. Move bulk data (file lists, blobs) out of workspace_config into the workspace itself or another store
  3. Check `len(json.dumps(cfg, sort_keys=True, separators=(',', ':')))` before calling to confirm it fits

Example fix

// before
cfg = {"files": [f for f in scan_entire_tree()]}  # huge
// after
cfg = {"root": str(root)}  # small, workspace scans its own tree
Defensive patterns

Strategy: validation

Validate before calling

serialized_len = len(json.dumps(workspace_config or {}, sort_keys=True, separators=(",", ":")))
assert serialized_len <= 65536, "workspace_config too large"

Try / catch

try:
    resolve_workspace(cwd, workspace_config)
except ValueError as exc:
    if "too large" in str(exc):
        workspace_config = reduce_config(workspace_config)
        resolve_workspace(cwd, workspace_config)

Prevention

When it happens

Trigger: Calling `canonical_workspace_config`, `resolve_workspace`, `bind_thread_workspace`, or `require_thread_workspace` with a workspace_config dict whose compact JSON serialization exceeds `_MAX_CONFIG_LENGTH` (e.g. embedding large file contents, long path lists, or base64 blobs in the config).

Common situations: Inlining large allowlists or full directory trees into workspace config; accidentally passing the whole settings file instead of the workspace section; accumulating entries in the config over a long-lived session.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/3be9e298394c1762. Report an issue: GitHub.