{"record":{"id":"bc3d16cd2d5dfdf7","repo":"NousResearch/hermes-agent","slug":"context-must-be-a-string-of-at-most-32000-characte","errorCode":null,"errorMessage":"context must be a string of at most 32000 characters.","messagePattern":"context must be a string of at most 32000 characters\\.","errorType":"exception","errorClass":"SubagentLifecycleError","httpStatus":null,"severity":"error","filePath":"agent/subagent_lifecycle.py","lineNumber":501,"sourceCode":"        value = f\"{subagent_id}|{parent_session_id or ''}|{created_at:.6f}\".encode()\n        return hmac.new(_SECRET, value, hashlib.sha256).hexdigest()\n\n    @staticmethod\n    def _validate_request(request: SubagentLaunchRequest, parent: Any) -> None:\n        if (\n            not isinstance(request, SubagentLaunchRequest)\n            or not isinstance(request.goal, str)\n            or not request.goal.strip()\n            or len(request.goal) > _MAX_GOAL_CHARS\n        ):\n            raise SubagentLifecycleError(\n                \"goal must be a non-empty string of at most 16000 characters.\"\n            )\n        if request.context is not None and (\n            not isinstance(request.context, str)\n            or len(request.context) > _MAX_CONTEXT_CHARS\n        ):\n            raise SubagentLifecycleError(\n                \"context must be a string of at most 32000 characters.\"\n            )\n        if request.role not in {\"leaf\", \"orchestrator\"}:\n            raise SubagentLifecycleError(\"role must be 'leaf' or 'orchestrator'.\")\n        if request.timeout_seconds is not None:\n            raise SubagentLifecycleError(\n                \"Per-launch timeout is not supported; configure delegation timeout explicitly.\"\n            )\n        if request.working_directory is not None:\n            raise SubagentLifecycleError(\n                \"working_directory is not supported because Hermes delegates use isolated task environments.\"\n            )\n        if request.blocked_tools:\n            raise SubagentLifecycleError(\n                \"Per-tool blocking is not supported; use allowed_toolsets. Hermes always blocks unsafe child tools.\"\n            )\n        try:\n            metadata_bytes = len(","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/subagent_lifecycle.py#L483-L519","documentation":"Validation error from SubagentLifecycleManager._validate_request(): when context is provided on SubagentLaunchRequest it must be a string of at most _MAX_CONTEXT_CHARS (32000) characters. None is allowed (no context); anything non-string or oversized is rejected before launch.","triggerScenarios":"Passing context as a dict/list (un-serialized payload), a bytes object, or a string over 32000 chars; stuffing whole file contents or transcripts into context.","commonSituations":"Mapping an API's structured context object straight onto the field without json.dumps; attaching a large log excerpt or document body as context; mixing up goal and context limits (16000 vs 32000).","solutions":["Serialize structured context with json.dumps(...) or summarize it to text before passing.","If context exceeds 32000 chars, write it to a file and reference the path in the goal, or truncate/compress it.","Keep context as None when there is nothing to add."],"exampleFix":"# before\nrequest = SubagentLaunchRequest(goal=g, context={\"repo\": \"x\", \"logs\": logs_text})\n\n# after\nimport json\nctx = json.dumps({\"repo\": \"x\"}) + \"\\n\" + logs_text[-20000:]\nrequest = SubagentLaunchRequest(goal=g, context=ctx)","handlingStrategy":"validation","validationCode":"MAX_CTX = 32000\nif context is not None:\n    assert isinstance(context, str) and len(context) <= MAX_CTX\nrequest = SubagentLaunchRequest(goal=goal, context=context)","typeGuard":"def is_valid_context(value: object) -> bool:\n    return value is None or (isinstance(value, str) and len(value) <= 32000)","tryCatchPattern":"try:\n    manager.launch(request)\nexcept SubagentLifecycleError as exc:\n    if \"context must be\" in str(exc):\n        request = dataclasses.replace(request, context=context[:32000])\n        manager.launch(request)\n    else:\n        raise","preventionTips":["json.dumps structured context before passing it.","Keep big documents out-of-band; pass a path or summary.","Remember the split: goal 16000, context 32000."],"tags":["subagents","delegation","validation","input"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}