yr.ManagedSessionObj

yr.ManagedSessionObj#

class yr.ManagedSessionObj(session_id: str, session_json: str)[source]#

Bases: object

Managed Session Object.

Session Data Structure:

{
    "sessionID": "s-123",
    "histories": ["user: hello", "assistant: hi"]
}

Note

  • Internally holds sessionId and the latest sessionData JSON string

  • get_histories() returns a copy to prevent users from directly modifying internal list and bypassing sync

  • set_histories() immediately calls bridge to sync to libruntime, runtime auto-persists at request end

  • Multiple load_session() calls with same sessionId return the same managed object

Construct managed Session Object.

Parameters:
  • session_id – Session ID

  • session_json – JSON string of Session data

Methods

__init__

Construct managed Session Object.

get_histories

Get history list (copy).

get_id

Get Session ID.

is_interrupted

Whether this session has been interrupted (e.g. cancellation).

notify

Send notify payload to the session wait/notify channel (UTF-8 JSON bytes to native).

set_histories

Set history list and immediately sync to libruntime.

wait_for_notify

Block until notify arrives for this session or timeout.