Handler runtime
The handler preset runs Python 3.12 and imports /app/handler.py as a module. The module must expose
handle(input).
Contract
Section titled “Contract”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 |
siloga_agent.secret
Section titled “siloga_agent.secret”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
Section titled “siloga_agent.log”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
Section titled “siloga_agent.event”siloga_agent.event("document.classified", category="invoice")Emits a named point-in-time domain event.
siloga_agent.metric
Section titled “siloga_agent.metric”siloga_agent.metric("model.tokens", 842, model="example-model")Emits a named measurement. The value is stored inside the event’s structured data.
siloga_agent.span
Section titled “siloga_agent.span”with siloga_agent.span("fetch.context"): context = fetch_context()Emits one timed span when the block exits, including when it exits through an exception.
Event data coercion
Section titled “Event data coercion”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.
Concurrency and mutable state
Section titled “Concurrency and mutable state”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.
Files and entrypoint
Section titled “Files and entrypoint”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.