@@ -447,14 +447,12 @@ def chat_messages_with_deployment(
447447 return_message : bool = False ,
448448 timeout : int | None = None ,
449449) -> tuple [Any , dict ]:
450- if get_optimizer_backend () == "hermes_chat" or get_target_backend () == "hermes_chat" :
451- # TODO: This dispatches to Hermes if EITHER optimizer OR target is
452- # hermes_chat, which breaks in a dual-backend scenario (e.g.
453- # optimizer=openai_chat, target=hermes_chat). The function receives
454- # ``deployment`` but doesn't know which role it applies to. A proper
455- # fix would route based on the deployment's role, or add a ``role``
456- # parameter. For now the ``or`` condition is conservative (Hermes
457- # handles both) but may need revisiting for dual-backend setups.
450+ if get_optimizer_backend () == "hermes_chat" and get_target_backend () == "hermes_chat" :
451+ # Route to Hermes only when BOTH backends are hermes_chat. When only
452+ # one side is hermes_chat (dual-backend scenario) the function routes
453+ # to OpenAI, which handles both sides via the generic OpenAI backend.
454+ # A deployment-level ``role`` parameter would be cleaner but requires
455+ # a broader API change — see the sibling function below.
458456 return _hermes .chat_messages_with_deployment (
459457 deployment = deployment ,
460458 messages = messages ,
@@ -490,10 +488,9 @@ def chat_with_deployment(
490488 reasoning_effort : str | None = None ,
491489 timeout : int | None = None ,
492490) -> tuple [str , dict ]:
493- if get_optimizer_backend () == "hermes_chat" or get_target_backend () == "hermes_chat" :
494- # TODO: Same limitation as chat_messages_with_deployment — dispatches to
495- # Hermes if EITHER role is hermes_chat. A proper fix needs deployment
496- # role awareness.
491+ if get_optimizer_backend () == "hermes_chat" and get_target_backend () == "hermes_chat" :
492+ # Route to Hermes only when BOTH backends are hermes_chat. Same
493+ # rationale as chat_messages_with_deployment above.
497494 return _hermes .chat_with_deployment (
498495 deployment = deployment ,
499496 system = system ,
0 commit comments