fix: send empty JSON body in session.create()

The OpenCode server's POST /session endpoint requires a JSON request
body (Content-Type: application/json), even when no parameters are
provided. Without a body, the server returns 400 'Malformed JSON in
request body'.

Both the sync and async create() methods now send body={} so that the
SDK serializes an empty JSON object, matching what the server expects.
This commit is contained in:
Alberto Garcia Illera 2026-02-21 12:35:11 -08:00
parent 817f1a0816
commit f0dfcbc9f9
No known key found for this signature in database

View file

@ -63,6 +63,7 @@ class SessionResource(SyncAPIResource):
"""Create a new session"""
return self._post(
"/session",
body={},
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
@ -508,6 +509,7 @@ class AsyncSessionResource(AsyncAPIResource):
"""Create a new session"""
return await self._post(
"/session",
body={},
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),