mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-28 18:19:28 +00:00
fix(tui): emit multi_select hint only when true — single-select clarify payloads keep the pre-existing protocol shape
This commit is contained in:
parent
d778732cc8
commit
62e8842d07
2 changed files with 31 additions and 2 deletions
|
|
@ -13869,6 +13869,30 @@ def test_clarify_callback_uses_configured_timeout(monkeypatch):
|
|||
assert captured["payload"] == {"question": "Pick one", "choices": ["a", "b"]}
|
||||
|
||||
|
||||
def test_clarify_callback_multi_select_hint(monkeypatch):
|
||||
"""multi_select=True adds the hint to the payload; the single-select
|
||||
payload shape stays byte-identical to the pre-multi-select protocol
|
||||
(older renderers must never see the extra field)."""
|
||||
captured = {}
|
||||
|
||||
def fake_block(event, sid, payload, timeout=300):
|
||||
captured.update(payload=payload)
|
||||
return "answer"
|
||||
|
||||
monkeypatch.setattr(server, "_block", fake_block)
|
||||
cb = server._agent_cbs("sid-1")["clarify_callback"]
|
||||
|
||||
cb("Pick many", ["a", "b"], multi_select=True)
|
||||
assert captured["payload"] == {
|
||||
"question": "Pick many",
|
||||
"choices": ["a", "b"],
|
||||
"multi_select": True,
|
||||
}
|
||||
|
||||
cb("Pick one", ["a", "b"], multi_select=False)
|
||||
assert captured["payload"] == {"question": "Pick one", "choices": ["a", "b"]}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("configured", "expected"),
|
||||
[(0, None), (-1, None), (42, 42)],
|
||||
|
|
|
|||
|
|
@ -5040,8 +5040,13 @@ def _agent_cbs(sid: str) -> dict:
|
|||
# multi_select is a pass-through hint: renderers with checkbox
|
||||
# support can honor it; older renderers ignore the extra field
|
||||
# and stay single-select (a single answer still parses as a
|
||||
# one-element list on the tool side).
|
||||
{"question": q, "choices": c, "multi_select": bool(multi_select)},
|
||||
# one-element list on the tool side). Only emitted when True so
|
||||
# single-select payloads keep the exact pre-multi-select shape.
|
||||
(
|
||||
{"question": q, "choices": c, "multi_select": True}
|
||||
if multi_select
|
||||
else {"question": q, "choices": c}
|
||||
),
|
||||
timeout=_clarify_timeout_seconds(),
|
||||
),
|
||||
# read_terminal tool (desktop GUI): same blocking bridge as clarify — the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue