docs: fix Python examples passing dict to session.send() instead of positional str + keyword args#1128
Open
Akhand-99 wants to merge 1 commit intogithub:mainfrom
Open
docs: fix Python examples passing dict to session.send() instead of positional str + keyword args#1128Akhand-99 wants to merge 1 commit intogithub:mainfrom
Akhand-99 wants to merge 1 commit intogithub:mainfrom
Conversation
…tr and keyword args
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1127
What does this change do?
Fixes broken Python code examples in two docs files where
session.send()is called with adictinstead of the correct positionalstrand keyword arguments.docs/auth/byok.md— 1 line changed:docs/features/steering-and-queueing.md— 3 Python blocks, 8 lines changed:Why is this needed?
session.send()has this signature:Python does not enforce type hints at runtime. When a dict is passed as
prompt, two things silently break:1.
promptbug (both files): The dict is forwarded verbatim as thepromptvalue in the JSON-RPC payload to the CLI binary:{ "sessionId": "...", "prompt": { "prompt": "What is 2+2?" } }The CLI receives
promptas a JSON object instead of a string and calls.asString()on it, throwingTypeError: t.asString is not a function. This surfaces as asession.errorevent — no Python exception is raised, making it extremely difficult to diagnose:2.
modebug (steering-and-queueing.mdonly): The*in the signature makesmodea keyword-only argument. Whenmodeis buried inside a dict, it is never actually passed tosend()— the steering and queueing behaviour silently does nothing. The agent receives no delivery mode instruction at all.Both issues are caused by the same issue in the docs: using a dict where the Python SDK expects positional and keyword arguments.
Notes for maintainers
byok.mdfix is a single line. In that example I kept the existingasyncio.Event/on_eventhandler pattern unchanged to keep the diff minimal. If you prefer to align it with the other language tabs by switching tosend_and_wait("..."), I am happy to update.if not isinstance(prompt, str): raise TypeError(...)insession.pysend()would surface this class of mistake immediately at the Python level rather than as a cryptic CLI error. Happy to follow up with a separate issue or PR if that would be useful.