Build a task-list assistant
Before you start: the basics and host actions.
This walkthrough uses the included assistant to turn a request into a persistent task list. You can check off items in the generated card, then ask the assistant to reorganize the same list. We'll follow the data from the model's tool call to the native control and back to the backend.
The runnable example uses the shared Python backend and an iOS host. You'll need the iOS setup, a provider API key, and the matching Rust server CLI described in the distribution guide. Live generation uses your provider account.
1. Run the assistant
Place the server archive’s bin/relo at artifacts/rust/server/relo or set RELO_CHAT_VALIDATOR to its executable path. From the repository root:
scripts/backend setup
Put your provider settings in the ignored backend/.env.openai file:
OPENAI_API_KEY=your-key
Then restart the backend through the example launcher:
scripts/backend stop
scripts/ios examples --screen ai-chat
The key stays on the backend. The app receives documents and data, not provider credentials.
Send this message:
Build a todo app for my weekend with book tickets, pack my bag, and water plants.
Check an item, add another, and reopen the conversation. Then ask:
Show the same list with separate sections for completed and remaining tasks.
The completed items should remain completed. You're asking for a new view of existing data.
2. Create the data through a tool
In graph.py, create_list accepts a title and items_json, a JSON-encoded array of strings. The backend creates the list and returns a record with this shape:
{
"listId": "list-1",
"title": "Weekend tasks",
"items": [{"id": "task-1", "text": "Pack my bag", "checked": false}],
"summary": "0 of 1 completed"
}
The IDs above are example values; use the IDs returned by the service. For a later layout change, the agent calls read_list with the existing ID. This keeps the new response tied to the saved list.
There are two kinds of tools in this flow:
| Called by | Example | Purpose |
|---|---|---|
| Model during generation | create_list, read_list | Get the data needed to answer the user's request |
| UI after rendering | assistant.list | Apply a user's add, toggle, or remove action |
The second path goes straight to the backend. Checking a box doesn't regenerate the card or call the model.
3. Compose the response
The assistant's mini-apps skill recommends the app's shared ui:TaskList component:
<ui:TaskList xmlns:ui="urn:relo:local:components/relo-components" bind-list="data.app" />
The backend puts the returned list record in data.app. ui:TaskList supplies labeled checkboxes, an add field, remove buttons, loading state, and error handling. For the grouped version, the model can return:
<ui:TaskList xmlns:ui="urn:relo:local:components/relo-components" bind-list="data.app" bind-groupCompleted="true" />
These are subtrees, not complete network documents. The assistant assembler adds ui:Theme and the required component definitions. The model doesn't need to repeat those definitions in each response.
The model's final output has five fields, defined in OUTPUT_SCHEMA in graph.py:
| Field | Contents |
|---|---|
text | A short message shown beside the card |
source | The XML subtree |
data_json | JSON-encoded data, including the list in app |
steps_json | JSON-encoded interaction steps and assertions |
mocks_json | JSON-encoded service results used by the verifier |
The three *_json fields are strings in the model response. The backend decodes them before verification. For an ordinary text answer, source is empty and no card is created.
4. Verify a checkbox before rendering
For the one-item list above, a useful trace checks that toggling Pack my bag calls assistant.list and changes the summary. Run this complete example from the repository root after installing the Rust CLI. It uses the same verifier as the assistant and makes no model or live service calls:
PYTHONPATH=backend python3 - <<'PY'
from app.assistant.ui import verify
source = '<ui:TaskList xmlns:ui="urn:relo:local:components/relo-components" bind-list="data.app" />'
item = {"id": "task-1", "text": "Pack my bag", "checked": False}
app = {
"listId": "list-1",
"title": "Weekend tasks",
"items": [item],
"summary": "0 of 1 completed",
}
updated = {
**app,
"items": [{**item, "checked": True}],
"summary": "1 of 1 completed",
}
steps = [{
"label": "Pack my bag",
"value": True,
"assertAction": "assistant.list",
"assertText": "1 of 1 completed",
}]
mocks = {"assistant.list": {"result": updated}}
report = verify(source, {"app": app}, steps, mocks)
print(report)
assert report["valid"], report
PY
The mock contains the complete updated list, inside a result envelope. Returning only the changed checkbox value would leave the component without the title, IDs, and summary it expects.
Try changing assertText to an incorrect summary. The check should fail. You can also change the source to the grouped version and run the same trace.
During live generation, the graph performs these checks automatically. It applies recognized local corrections first, reruns the checks, and sends unresolved diagnostics back to the model within a bounded repair loop. See Skills, verification, and correction.
5. Save changes through the app
ui:TaskRow calls the registered assistant.list action with a payload such as:
{
"listId": "list-1",
"operation": "toggle",
"itemId": "task-1",
"checked": true
}
The service validates the operation, saves it, and returns the full updated list. The component assigns that result to its displayed state. Add and remove follow the same pattern.
List mutations persist automatically. The separate assistant.save action is available for additional card state, such as a selection that should survive reopening. Keep transient input drafts and loading flags outside data that gets replaced by a service result.
The example stores conversations and lists in artifacts/chat/conversations.sqlite3. It uses a local installation owner ID. When adapting it for a deployed app, connect list ownership to your authenticated users and use your application's HTTPS transport.
6. Keep each response's session
The iOS AssistantModel retains a Relo session for each card. AssistantViewController mounts the cards inside the transcript and owns scrolling and keyboard layout. Appending a response doesn't replace earlier cards, so their local interactions survive.
When a conversation is reopened, the host can restore its saved documents and data. Closing a session releases its local state; persistence comes from the backend. See Data, state, and bindings for that distinction.
Adapt the example
Start with these files:
| File | Change it to… |
|---|---|
| graph.py | Add model tools and define generation instructions |
| ui.py | Choose allowed components, assemble responses, and run verification |
| skills/ | Teach the agent your layouts and action patterns |
| domain.py | Implement application operations and validate their inputs |
| storage.py | Inspect conversation, card, and list persistence |
| TaskList.xml | Change the list's layout while reusing its action flow |
For another kind of app, follow the same sequence: expose a service, give the agent a component that uses it, and verify an interaction against the service's result shape. Add custom layouts where the existing components don't cover the task.
Run scripts/backend test for backend checks and scripts/ios chat-test for the deterministic native chat walkthroughs. These don't require live generation. The assistant implementation guide covers opt-in model evaluations, native layout replays, and latency measurements.