Applications
Keep a workflow running after you disconnect
Learn the host lifecycle with a real timer, then extend it with background research jobs.
View Markdown source ↗InputA daemon session and a scheduled event
OutputAn observable completion after client detach
Setup Generate a separate private daemon configuration using tutorial setup, select this prompt, and keep the daemon alive. Do not submit a model message.
- Create a hosted session
- Detach the client
- Observe the scheduled stop
Learn the host lifecycle with a real timer, then extend it with background research jobs.
Separate the lifetime of the work from the lifetime of the terminal. Background research uses the documented model-job recipe as an extension.
The outcome
Section titled “The outcome”Input: A daemon session and a scheduled event.
Output: An observable completion after client detach.
Start with the observable timer
Section titled “Start with the observable timer”Follow the background-agent tutorial. Its source bundle demonstrates a host-owned scheduled event that stops the session even when no TUI is attached. This timer needs no model request; it is a small, reproducible way to understand where the work lives.
Extend the pattern to research
Section titled “Extend the pattern to research”A daemon-hosted ChatML moderator can start a specialist job with
Model.spawn("agent_prompt_v1", payload). The recipe payload supplies prompt,
input, and is_local. Handle Model_job_succeeded and Model_job_failed events
to collect results or record failure. Follow the complete contracts and tested
recipe in ChatML orchestration.
For example, a workflow can dispatch a question to a researcher, remain alive while its client disconnects, and collect the result when the job completes. That research extension requires your prompt, provider configuration, job capacity, and completion handling; the included timer does not perform research.
Read the agent hosting overview for the deployment model and operations path.
Understand the lifetime
Section titled “Understand the lifetime”Use the documented job, schedule, and session views to inspect progress after reconnecting. Schedules are one-shot events, not a cron service. Restart recovery does not resume arbitrary process stacks or guarantee exactly-once external effects. Sessions and workspaces explains the host’s ownership and persistence boundaries.
Explore another application or follow the tutorial curriculum.
View source · Background timer2 files
Complete source files. Open a filename to read it here.
timer.chatmdStart here
<developer>This host demonstrates a background timer; no model request is needed.</developer>
<script language="chatml" kind="moderator">
type state = int
type event = [ `Session_start | `Tick ]
let initial_state = 0
let on_event : context -> state -> event -> state task =
fun ctx st ev ->
match ev with
| `Session_start ->
Task.bind(Schedule.after_ms(10000, `Tick), fun timer_id ->
Task.pure(st + 1))
| `Tick ->
Task.bind(Runtime.end_session("scheduled tutorial stop"), fun ignored_end ->
Task.pure(st + 1))
</script>
LICENSE.txtnotice
MIT License
Copyright (c) 2025
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.