Search
Search docs, blog posts, and ecosystem packages with citations.
Enter a query to see grounded citations.
We can't find the internet
Attempting to reconnect
Search docs, blog posts, and ecosystem packages with citations.
Canonical format for contributor-authored runnable Livebook docs, including setup cells, runtime pattern, metadata, and drift tests.
Use this page as the canonical standard when writing or reviewing .livemd tutorials, cookbook recipes, and other runnable docs notebooks in Jido. Package Quality Standards defines the package bar. This page defines the notebook bar.
Mix.install(...) and Logger.configure(level: :warning)Jido.start() and Jido.start_agent(Jido.default_instance(), ...)livebook: metadata and a matching drift test under test/livebooks/docsFor beginner-friendly notebooks, use this sequence:
Do not make readers learn strategy internals before they can run the first successful example.
Every runnable notebook should start with a complete dependency cell:
Mix.install([
{:jido, "~> 2.1"},
{:jido_ai, "~> 2.0"},
{:req_llm, "~> 1.7"}
])
Logger.configure(level: :warning)
If the notebook needs more packages, add them here rather than assuming previous setup cells from another notebook.
For provider-backed beginner notebooks, prefer a friendly configured? gate instead of crashing immediately:
openai_key = System.get_env("LB_OPENAI_API_KEY") || System.get_env("OPENAI_API_KEY")
configured? =
if is_binary(openai_key) do
ReqLLM.put_key(:openai_api_key, openai_key)
true
else
IO.puts("Set OPENAI_API_KEY as a Livebook Secret or environment variable to run this notebook.")
false
end
This pattern keeps the notebook readable for beginners who are still wiring credentials. Use a hard failure only when the notebook is explicitly external-only or advanced enough that a partial run is not useful.
For beginner notebooks, prefer the default Jido runtime:
{:ok, _} = Jido.start()
runtime = Jido.default_instance()
agent_id = "chat-demo-#{System.unique_integer([:positive])}"
{:ok, pid} = Jido.start_agent(
runtime,
MyApp.ChatAgent,
id: agent_id
)
This is the canonical Livebook pattern because it is rerunnable and avoids named-runtime confusion. Jido.AgentServer.start_link/1 is still fine in application code and targeted tests, but beginner notebooks should not depend on the reader understanding custom runtime naming first.
Use stable public APIs in the main path:
Jido.Exec.run/2 for action recipes ask/3, await/2, and ask_sync/3 for agent tutorials Jido.AgentServer.status/1 for inspection and verification Keep these out of the critical path unless the notebook is explicitly advanced:
:ai_react_starton_before_cmd/2 and on_after_cmd/3request_transformerThe rule is simple: readers should get one successful run before they are asked to learn internals.
The first runnable example should prove the notebook works. Only after that should the notebook show state inspection or debugging.
For an AI chat notebook, the first two cells after setup should usually be:
pidThen add one inspection cell, for example:
{:ok, status} = Jido.AgentServer.status(pid)
status.snapshot.details.conversation
That demonstrates multi-turn state without forcing the reader to intercept lifecycle hooks first.
Runnable notebooks should include Livebook-oriented metadata in the frontmatter:
%{
tags: [:docs, :guides, :livebook],
livebook: %{
runnable: true,
required_env_vars: ["OPENAI_API_KEY"],
requires_network: true,
setup_instructions: "Set OPENAI_API_KEY or LB_OPENAI_API_KEY before running the request cell."
}
}
Use required_env_vars and setup_instructions to make external requirements explicit instead of burying them deep in the prose.
Every runnable notebook should have one matching drift test under test/livebooks/docs.
Use AgentJido.LivebookCase and keep the test small:
defmodule AgentJido.Livebooks.Docs.MyNotebookLivebookTest do
use AgentJido.LivebookCase,
livebook: "priv/pages/docs/learn/my-notebook.livemd",
timeout: 120_000,
external: true,
required_any_env: ["OPENAI_API_KEY", "LB_OPENAI_API_KEY"]
test "runs cleanly" do
assert :ok = run_livebook()
end
end
The standard is one runnable notebook, one drift test.
Some docs pages may remain explanatory rather than runnable. If a notebook is not meant to run end to end:
livebook: %{runnable: false}Explanatory pages are acceptable. Ambiguous pages are not.