Skip to content

Handler runtime

The handler preset runs Python 3.12 and imports /app/handler.py as a module. The module must expose handle(input).

def handle(input: dict):
...
Behavior Contract
Input A JSON object; defaults to {}
Output Any JSON-serializable Python value
Success handle returns normally
Failure handle raises an exception or returns a non-serializable value
Initialization Module imported once per runtime process
value = siloga_agent.secret("NAME")

Returns the current invocation’s string value or None. Secret context is removed after the invocation finishes.

siloga_agent.log("message", level="default", key="value")

Emits a structured log. Supported levels are debug, default, warning, and error. An invalid level is normalized to default.

siloga_agent.event("document.classified", category="invoice")

Emits a named point-in-time domain event.

siloga_agent.metric("model.tokens", 842, model="example-model")

Emits a named measurement. The value is stored inside the event’s structured data.

with siloga_agent.span("fetch.context"):
context = fetch_context()

Emits one timed span when the block exits, including when it exits through an exception.

The runtime converts event data to JSON when it is emitted. Values supported by json.dumps are preserved. Other values are converted to a bounded fallback string. Non-finite numbers and payloads larger than the per-event limit are replaced with diagnostic markers so they cannot break the full invocation response.

The runtime server can accept invocations on worker threads. Do not place request-specific mutable state in module globals. Python ContextVar scopes secret and event data to each invocation, but your own global objects remain your responsibility.

Deployment source currently accepts flat filenames only. Nested or absolute paths are rejected. Only the handler preset is available and custom entrypoints are rejected. Ordered, single-line setup steps are supported during the build; see Setup and dependencies.