Skip to content

Commit 9ae7eac

Browse files
Omit null Python send fields
Avoid serializing absent optional session.send fields as JSON null so resumed Python-created sessions do not fail CLI validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b0c1b8e commit 9ae7eac

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

python/copilot/session.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,16 @@ async def send(self, options: MessageOptions) -> str:
139139
... "attachments": [{"type": "file", "path": "./src/main.py"}]
140140
... })
141141
"""
142-
response = await self._client.request(
143-
"session.send",
144-
{
145-
"sessionId": self.session_id,
146-
"prompt": options["prompt"],
147-
"attachments": options.get("attachments"),
148-
"mode": options.get("mode"),
149-
},
150-
)
142+
params: dict[str, Any] = {
143+
"sessionId": self.session_id,
144+
"prompt": options["prompt"],
145+
}
146+
if "attachments" in options:
147+
params["attachments"] = options["attachments"]
148+
if "mode" in options:
149+
params["mode"] = options["mode"]
150+
151+
response = await self._client.request("session.send", params)
151152
return response["messageId"]
152153

153154
async def send_and_wait(

0 commit comments

Comments
 (0)