File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -243,5 +243,37 @@ WebSockets require passing the session key as a query parameter
243243[ sockets.py] ( https://github.com/OpenHands/software-agent-sdk/blob/HEAD/openhands-agent-server/openhands/agent_server/sockets.py ) .
244244</Note >
245245
246- Last updated: 2025-12-09 06:57 UTC
246+
247+ ### WebSocket streaming example (bash-events)
248+
249+ ``` python
250+ # Stream bash events over WebSocket
251+ # Endpoint: /sockets/bash-events?session_api_key=...
252+ # (source: sockets.py)
253+ # https://github.com/OpenHands/software-agent-sdk/blob/HEAD/openhands-agent-server/openhands/agent_server/sockets.py
254+
255+ import asyncio
256+ import json
257+ import websockets
258+
259+ BASE_WS = " wss://agent-server.example.com"
260+ API_KEY = " your-api-key"
261+
262+ async def stream_bash_events ():
263+ ws_url = f " { BASE_WS } /sockets/bash-events?session_api_key= { API_KEY } &resend_all=false "
264+ async with websockets.connect(ws_url) as ws:
265+ while True :
266+ raw = await ws.recv()
267+ event = json.loads(raw)
268+ print (event.get(" kind" ), event.get(" timestamp" ))
269+
270+ asyncio.run(stream_bash_events())
271+ ```
272+
273+ <Note >
274+ Bash WebSocket events include BashCommand and BashOutput items. For filtering or paging
275+ via REST, see the bash event routes in
276+ [ bash_router.py] ( https://github.com/OpenHands/software-agent-sdk/blob/HEAD/openhands-agent-server/openhands/agent_server/bash_router.py ) .
277+ </Note >
278+
247279Source commit (software-agent-sdk): ` 93d405c9 `
You can’t perform that action at this time.
0 commit comments