Gateway chat: background subagent delivery (async delegate_task) silently disabled — caller conversation_history denies server-history consumer

Author: unRekableCreated Sep 30, 2026Updated Oct 1, 2026
Labelsbugsprint-candidategateway

Summary

Browser chat sessions running through the Gateway runs API (webui_chat_backend: gateway) cannot use background delegate_task subagents. Every delegation silently downgrades to synchronous execution: the parent blocks inside the tool call until all children finish — no parallel work, and Steers sent during the batch wait for it to return.

Observed on v0.21.4 hermes-core + current webui master, gateway mode enabled 2026-09-30. Log evidence (gateway.log / agent log):

delegate_task: session fda15938a1dd has no declared server-history consumer — running the batch synchronously instead.
async delivery unsupported on this session runtime; running the batch synchronously instead.

Root cause chain

  1. The WebUI always sends conversation_history with every /v1/runs admission (_run_gateway_runs_api_streaming, added for #4362 so runs-API chat keeps context between turns).
  2. api_server_runs.py:659: session_history_delivery = not previous_response_id and not conversation_history.
  3. api_server_runs.py:762-764 (by design, #98619 fail-closed): "a caller-supplied conversation_history is authoritative for the turn and never reads the delivery row, so it is denied the same way."
  4. tools/delegate_tool_dispatch.py::_resolve_async_wake_sid: without origin_session_history_delivery, delegation runs synchronously.

Gateway-native sessions (Telegram etc.) and /api/sessions/{id}/chat are unaffected — they never send caller history and get session_history_delivery="1".

Impact

  • Parent agents in browser chats cannot work in parallel with their subagents (behavior regression vs. the legacy in-process WebUI runtime).
  • Mid-run Steers are consumed only after the full delegation batch returns.

Proposed fix

PR #7930 — explicit opt-in (HERMES_WEBUI_GATEWAY_ASYNC_DELIVERY env / webui_gateway_async_delivery config): the WebUI omits conversation_history when an explicit session_id is present; the runs API then loads the authoritative history from SessionDB itself (existing behavior, api_server_runs.py:660-661) and declares the run a server-history consumer, re-enabling async delegation delivery. Default stays off (#4362 guard).

An alternative contract-level fix could live server-side (e.g. a declared flag that the caller's history is mirrored from server state), but the client-side opt-in requires no API contract change.