{"record":{"id":"0d07a70759627361","repo":"bytedance/deer-flow","slug":"invalid-channel-session-assistant-id-raw-value-r","errorCode":null,"errorMessage":"Invalid channel session assistant_id {raw_value!r}. Use 'lead_agent' or a custom agent name containing only letters, digits, and hyphens.","messagePattern":"Invalid channel session assistant_id (.+?)\\. Use 'lead_agent' or a custom agent name containing only letters, digits, and hyphens\\.","errorType":"validation","errorClass":"InvalidChannelSessionConfigError","httpStatus":null,"severity":"error","filePath":"backend/app/channels/manager.py","lineNumber":339,"sourceCode":"def _as_dict(value: Any) -> dict[str, Any]:\n    return dict(value) if isinstance(value, Mapping) else {}\n\n\ndef _merge_dicts(*layers: Any) -> dict[str, Any]:\n    merged: dict[str, Any] = {}\n    for layer in layers:\n        if isinstance(layer, Mapping):\n            merged.update(layer)\n    return merged\n\n\ndef _normalize_custom_agent_name(raw_value: str) -> str:\n    \"\"\"Normalize legacy channel assistant IDs into valid custom agent names.\"\"\"\n    normalized = raw_value.strip().lower().replace(\"_\", \"-\")\n    if not normalized:\n        raise InvalidChannelSessionConfigError(\"Channel session assistant_id is empty. Use 'lead_agent' or a valid custom agent name.\")\n    if not CUSTOM_AGENT_NAME_PATTERN.fullmatch(normalized):\n        raise InvalidChannelSessionConfigError(f\"Invalid channel session assistant_id {raw_value!r}. Use 'lead_agent' or a custom agent name containing only letters, digits, and hyphens.\")\n    return normalized\n\n\ndef _extract_response_text(result: dict | list) -> str:\n    \"\"\"Extract the last AI message text from a LangGraph runs.wait result.\n\n    ``runs.wait`` returns the final state dict which contains a ``messages``\n    list.  Each message is a dict with at least ``type`` and ``content``.\n\n    Handles special cases:\n    - Regular AI text responses\n    - Clarification interrupts (``ask_clarification`` tool messages)\n    \"\"\"\n    if isinstance(result, list):\n        messages = result\n    elif isinstance(result, dict):\n        messages = result.get(\"messages\", [])\n    else:","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/channels/manager.py#L321-L357","documentation":"After normalization, assistant_id must fullmatch ^[A-Za-z0-9-]+$ (CUSTOM_AGENT_NAME_PATTERN). Values containing dots, slashes, spaces, at-signs, CJK characters, or other symbols after the underscore->hyphen mapping raise this error. The strict pattern exists because the name is resolved against registered custom agents and used in routing.","triggerScenarios":"assistant_id set to something like 'agent.one', 'Agent A', '@bot', 'café-agent', or an email address. Normalization only fixes case and underscores, so any remaining non-[A-Za-z0-9-] character triggers the raise when the session config is loaded or updated.","commonSituations":"Copying a display name or email instead of the agent's slug; renaming a custom agent to include spaces and not updating channel bindings; pasting with a trailing period or comma.","solutions":["Use the custom agent's slug exactly as shown in the agents UI — letters, digits, hyphens only (e.g. 'research-agent').","Replace spaces/dots with hyphens: 'code.review.v2' -> 'code-review-v2'.","Use 'lead_agent' (normalizes fine) for the default super-agent."],"exampleFix":"# before\nassistant_id: \"Code Review v2\"\n\n# after\nassistant_id: \"code-review-v2\"","handlingStrategy":"type-guard","validationCode":"CUSTOM_AGENT_NAME_PATTERN = re.compile(r'^[A-Za-z0-9-]+$')\n\ndef valid_assistant_id(raw: str) -> bool:\n    n = raw.strip().lower().replace('_', '-')\n    return bool(CUSTOM_AGENT_NAME_PATTERN.fullmatch(n))","typeGuard":"function isValidAssistantId(raw: string): boolean {\n  const n = raw.trim().toLowerCase().replaceAll('_', '-');\n  return /^[A-Za-z0-9-]+$/.test(n);\n}","tryCatchPattern":"try:\n    session.assistant_id = _normalize_custom_agent_id(user_input)\nexcept InvalidChannelSessionConfigError as e:\n    reply_to_channel(f'{e}')  # actionable message back to the IM user","preventionTips":["Restrict agent-name inputs to slugs (letters/digits/hyphens) at creation time so channel bindings can never diverge.","When renaming a custom agent, sweep channel session configs for stale IDs.","Reject emails/display names at the settings API boundary with the same pattern."],"tags":["channels","config","validation"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}