Skip to content

request

request

RequestModel

Bases: BaseModel

The JSON routing envelope for a remote request.

The execution payload (the interventions plus how to invoke the model) is not stored here; serialize builds it from a tracer on demand. The model itself is never carried — it's identified by model_key.

model_key instance-attribute

model_key: str

session_id class-attribute instance-attribute

session_id: str = ''

compress class-attribute instance-attribute

compress: bool = False

env class-attribute instance-attribute

env: dict[str, Any] = {}

metadata

metadata() -> str

serialize classmethod

serialize(tracer: Any, compress: bool = False) -> bytes

Turn a tracer into the binary execution payload.

Reduces the traced block with reduce_block — its source (unparsed from the tracer's AST) plus only the globals/locals it references — so it ships as text rather than version-fragile bytecode, and hands that tuple, with the tracer (which carries the model invocation), to the serialization module.

deserialize staticmethod

deserialize(blob: bytes, persistent_objects: Optional[dict] = None, compress: bool = False, unpickler: type = CustomCloudUnpickler) -> Any

Inverse of serialize: rebuild the ready-to-run tracer.

Recompiles the traced block from its source (under the original filename/name so tracebacks point somewhere sensible) and injects it back as tracer.info.code, then restores the captured globals/locals onto the tracer's frame — so the server can run tracer.execute(tracer.info. code) against this actor's live model. The source is also registered in linecache so a traceback can show the offending line even though the user's file isn't present on the server.