Skip to content
Open
Prev Previous commit
Next Next commit
Merge origin/main into feature/ts-pr-765-port
Resolved conflicts in src/runloop_api_client/resources/axons/axons.py by:
- Keeping auto-reconnection logic from feature branch (ReconnectingStream)
- Adding support for user-provided after_sequence parameter from main
- Initial stream uses user's after_sequence, reconnections use last received sequence
- Both sync and async subscribe_sse methods now properly support both features

Changes from origin/main (v1.15.0):
- Updated version to 1.15.0
- Added axon_subscribe_sse_params type
- Updated benchmark_runs and related tests

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
  • Loading branch information
tode-rl and claude committed Apr 2, 2026
commit 8ced8257e17fb9ea2af0e878012d2932b91d01ff
32 changes: 23 additions & 9 deletions src/runloop_api_client/resources/axons/axons.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,22 @@ def subscribe_sse(
return self._get(
path_template("/v1/axons/{id}/subscribe/sse", id=id),
options=make_request_options(
extra_headers=merged_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
extra_headers=merged_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{"after_sequence": after_sequence}, axon_subscribe_sse_params.AxonSubscribeSseParams
),
),
cast_to=AxonEventView,
stream=True,
stream_cls=Stream[AxonEventView],
)

def create_stream(last_sequence: str | None) -> Stream[AxonEventView]:
# after_sequence is used internally for reconnection only
sequence_int = int(last_sequence) if last_sequence is not None else None
# Use user-provided after_sequence for initial stream, then use last_sequence for reconnections
sequence_to_use = after_sequence if last_sequence is None else int(last_sequence)
return self._get(
path_template("/v1/axons/{id}/subscribe/sse", id=id),
options=make_request_options(
Expand All @@ -314,7 +320,7 @@ def create_stream(last_sequence: str | None) -> Stream[AxonEventView]:
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{"after_sequence": sequence_int},
{"after_sequence": sequence_to_use},
axon_subscribe_sse_params.AxonSubscribeSseParams,
),
),
Expand All @@ -341,6 +347,7 @@ def get_sequence(item: AxonEventView) -> str | None:
)



class AsyncAxonsResource(AsyncAPIResource):
@cached_property
def sql(self) -> AsyncSqlResource:
Expand Down Expand Up @@ -599,25 +606,31 @@ async def subscribe_sse(
return await self._get(
path_template("/v1/axons/{id}/subscribe/sse", id=id),
options=make_request_options(
extra_headers=merged_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
extra_headers=merged_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{"after_sequence": after_sequence}, axon_subscribe_sse_params.AxonSubscribeSseParams
),
),
cast_to=AxonEventView,
stream=True,
stream_cls=AsyncStream[AxonEventView],
)

async def create_stream(last_sequence: str | None) -> AsyncStream[AxonEventView]:
# after_sequence is used internally for reconnection only
sequence_int = int(last_sequence) if last_sequence is not None else None
# Use user-provided after_sequence for initial stream, then use last_sequence for reconnections
sequence_to_use = after_sequence if last_sequence is None else int(last_sequence)
return await self._get(
path_template("/v1/axons/{id}/subscribe/sse", id=id),
options=make_request_options(
extra_headers=merged_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{"after_sequence": sequence_int},
query=await async_maybe_transform(
{"after_sequence": sequence_to_use},
axon_subscribe_sse_params.AxonSubscribeSseParams,
),
),
Expand All @@ -644,6 +657,7 @@ def get_sequence(item: AxonEventView) -> str | None:
)



class AxonsResourceWithRawResponse:
def __init__(self, axons: AxonsResource) -> None:
self._axons = axons
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.