Skip to content

feat(sdk): expose terminal platform disconnects to hosts - #843

Closed
bandzalkin wants to merge 3 commits into
band-ai:mainfrom
bandzalkin:feat/host-disconnect-reason-refresh
Closed

bandzalkin wants to merge 3 commits into
band-ai:mainfrom
bandzalkin:feat/host-disconnect-reason-refresh

Conversation

@bandzalkin

@bandzalkin bandzalkin commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This gives managed hosts a public way to distinguish a terminal platform disconnect from an intentional stop or a temporary network outage, so they can respond to an identity conflict instead of blindly reconnecting.

  • Raise AgentDisconnectedError, a BandConnectionError carrying the typed WebSocketDisconnectReason, when the platform ends the connection lifecycle. The waiter wakes even if the server leaves the socket open.
  • Expose the same reason through Agent.last_disconnect_reason and PlatformRuntime.last_disconnect_reason; retain it after stop() and clear it on a fresh connection attempt.
  • Record host stop intent before asynchronous teardown, so an explicit stop returns normally even when a terminal event races room cleanup.
  • Preserve ordinary transport reconnection and waiter cancellation: cancelling run_forever() does not stop a live transport. Observe completed transport shutdown independently of the waiter, without letting an old transport affect a restarted run.

Hosts still need stop() or the existing context-managed lifecycle to settle owned resources. A terminal disconnect now raises rather than looking like a successful run_forever() return.

Validation

Loopback WebSocket tests cover terminal disconnects, stop races, cancelled waiters, reconnects, and stale transport generations.

github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 19, 2026
@bandzalkin
bandzalkin force-pushed the feat/host-disconnect-reason-refresh branch from 5ea3a0d to 92b0282 Compare October 20, 2026 06:36
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 20, 2026
@bandzalkin
bandzalkin force-pushed the feat/host-disconnect-reason-refresh branch from 92b0282 to e4387f2 Compare October 20, 2026 11:48
bandzalkin added a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 20, 2026
band-ai#763 deletes omp_acp.py while band-ai#841 edits it; every branch that carries
the stack's tree must apply its own changes before that deletion, so
band-ai#843-band-ai#852 precede band-ai#763 and the native OMP family follows it.
bandzalkin added a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 20, 2026
band-ai#763 deletes omp_acp.py while band-ai#841 edits it; every branch that carries
the stack's tree must apply its own changes before that deletion, so
band-ai#843-band-ai#852 precede band-ai#763 and the native OMP family follows it.
bandzalkin and others added 3 commits October 21, 2026 03:15
Main now reconnects on a peer normal close (reconnect_on_normal_close), so
transport completion is signal_cancel or a policy close: drop normal_close
from the completion matrices and let the linkclose model accept a run that
ends by raising AgentDisconnectedError with its typed reason, as the
surface feature specifies.
@bandzalkin
bandzalkin force-pushed the feat/host-disconnect-reason-refresh branch from e4387f2 to bf0828c Compare October 21, 2026 00:30
bandzalkin added a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
…main)

# Conflicts:
#	README.md
#	src/band/agent.py
#	src/band/runtime/platform_runtime.py
#	tests/agent/test_disconnect_real_wire.py
#	tests/agent/wirekit.py
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
@bandzalkin

Copy link
Copy Markdown
Contributor Author

Closing: band-agent does not consume this; may be re-proposed per feature.

@bandzalkin bandzalkin closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant