Skip to content

Commit 0c8eb77

Browse files
docs(options-load): clarify that [] short-circuits handlers (upstream parity)
Docstring said "first non-empty result wins" but the code (and upstream TS) actually short-circuits on any non-None result — including []. A handler returning [] is an explicit "I handled this action, show no options", and blocks catch-all handlers by design. Matches upstream chat.ts:920-923 where if(options) is truthy for []. No behavior change; docstring + PR body wording only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6e96891 commit 0c8eb77

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/chat_sdk/chat.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,12 @@ async def process_options_load(
956956
"""Process an options-load event (external-select suggestion lookup).
957957
958958
Runs specific-action-ID handlers before catch-all handlers and returns
959-
the first non-empty result. Errors are logged and skipped so later
960-
handlers still get a chance. Mirrors upstream ``processOptionsLoad``.
959+
the first handler result that isn't ``None`` — including an explicit
960+
``[]``, which short-circuits subsequent handlers (handler says "I
961+
handled this action, show no options"). Errors are logged and skipped
962+
so later handlers still get a chance. Mirrors upstream
963+
``processOptionsLoad`` (TS ``if (options) { return options; }``, where
964+
``[]`` is truthy and therefore short-circuits).
961965
"""
962966
matching_handlers = [
963967
pat for pat in self._options_load_handlers if pat.action_ids and event.action_id in pat.action_ids

0 commit comments

Comments
 (0)