Build
Agents
Run an agent from code with agent.run(), choose its model role, resume it by session, and schedule it as a normal function.
An agent is an LLM that works through a task on its own, with tools, in a sandbox on the server. You start one from code with agent.run(), and it returns the agent's final answer.
Run an agent from codeLink to this section
import limilake
from limilake import agent
fn = limilake.function(
id="123e4567-e89b-42d3-a456-426614174006", # keep the id the CLI generated
name="invoice-review",
)
@fn.action
def run() -> dict[str, str]:
result = agent.run("Summarize yesterday's invoices and flag anything materially off")
return {"status": result.status, "summary": result.output}agent.run() blocks until the agent finishes and returns an AgentResult with .output (the final message), .status (completed, failed or timeout), .session and .usage. A refused or failed call raises AgentInvokeError with an HTTP status_code and a code.
The same call works from your laptop or CI: set LIMILAKE_TOKEN (or LIMILAKE_TOKEN_FILE) and LIMILAKE_WORKSPACE_ID. Inside a sandbox both are set for you.
Pick a model roleLink to this section
result = agent.run("Classify this support ticket as billing, bug, or question", model="light")| Role | Use it for |
|---|---|
frontier | Hard reasoning, highest quality |
standard | Everyday structured output and agent loops |
light | Simple, high-volume work |
model takes a role, never a provider model name; anything else is refused with HTTP 422. Without model, the agent's default model runs.
Resume a sessionLink to this section
Pass the same session= name to continue where the last run stopped:
first = agent.run("Investigate this week's churn", session="churn-watch")
again = agent.run("Now compare against last week", session="churn-watch")The first call with a name creates the agent; later calls resume it with everything that came before. Leave session out for a fresh run with no memory.
Scheduling an agentLink to this section
There is no separate agent scheduler. Give the Function a schedule= and call agent.run() from its handler, after a cheap check in plain code:
from limilake import agent, function, lake
fn = function(
id="123e4567-e89b-42d3-a456-426614174007",
name="invoice-watch",
schedule="0 7 * * *", # daily at 07:00 UTC
)
@fn.action
def run() -> dict[str, object]:
n = lake.query("select count(*) n from bronze.invoices where date = current_date")[0]["n"]
if n == 0:
return {"skipped": "no new invoices"}
r = agent.run("Investigate today's invoices and report anything off.", session="invoice-watch")
return {"checked": n, "summary": r.output}Keep it to at most one fire every 15 minutes; daily or weekly is cheaper. See Schedules.
Limits and gotchasLink to this section
- An agent runs with a narrowed copy of your access: a
viewer's run cannot write, and no run exceeds your live Access Level. Passscope=["lake.read"]to narrow it further when the prompt could be influenced by others. - An agent cannot start another agent.
- There is no notification API: an agent notifies people by calling a Connection, so name a Slack or email Connection in the prompt.
- A scheduled run never overlaps the previous one: a fire while it still runs is skipped.
Next stepsLink to this section
- Agents reference: the full surface, sessions, visibility, scopes and where an agent runs.
- Schedules: run a Function on a schedule and keep it healthy.
- Connections: let an agent call external services.