dari.yml
kind: customRuntimeServer. It runs an HTTP server inside the session sandbox. Dari starts the server, checks its health endpoint, and calls its advance endpoint when a message needs a response. Your server process should listen on the PORT environment variable that Dari provides; customRuntimeServer.port tells Dari which sandbox port to expose for hosted sandboxes.
What Your Code Owns
Your runtime receives the latest input and the state returned from the previous turn. For the common case, return assistant text and JSON state:text as an assistant message, saves state, and waits for the next user message. If a response omits state, Dari keeps the previous state unchanged. Return "state": null only when you want to clear saved state. If you need more control, the response can return explicit events and action fields, but most custom runtimes should start with text and state.
llm is optional for a custom runtime server. Omit it when your runtime calls its own model provider or SDK. Use sandbox.secrets to expose provider credentials to your runtime process.
When To Use It
Use a custom runtime server when you need to bring your own model SDK, preserve provider-specific conversation state, run a custom planner, integrate an existing agent framework, or emit events that the managed Pi runtime does not produce. Do not use a custom runtime server just to change the system prompt, choose a model, or enable built-in file and shell tools. Those are managed Pi runtime use cases. KeepcustomRuntimeServer.command fast. Install dependencies with sandbox.setup or a Dockerfile, then use command only to start the server.