Skip to content

Reference

Agents reference

Look up the full agent.run() surface, from sessions, visibility and scopes to notifications, scheduling notes and where an agent runs.

This is the complete reference. For a short guide, start with Agents.

An agent is an autonomous LLM run that LimiLake executes server-side in a sandbox. The same primitive backs an interactive chat, a code-invoked run, and a scheduled run: there is one kind of thing, reached three ways. From code you invoke one with the agent capability, exactly like lake and connections:

python
from limilake import agent

result = agent.run("Summarize yesterday's invoices and flag anything materially off")
print(result.output)

agent.run() is a thin API client, not a local process spawn: it POSTs the prompt to the backend, which authorizes the caller, mints a narrowed token, launches the agent headless, blocks until it finishes, and returns the final assistant message. Because the agent runs server-side, the same call works from a laptop, from CI, and from inside a scheduled sandbox.

SurfaceLink to this section

python
agent.run(prompt, *, session=None, scope=None, timeout=None, model=None) -> AgentResult
agent.start(prompt, *, session=None, scope=None, timeout=None, model=None) -> AgentHandle
  • agent.run(prompt, ...) blocks until the agent reaches a terminal state and returns an AgentResult. This is the default for the "check, then invoke, then act" pattern below.
  • agent.start(prompt, ...) returns an AgentHandle; call handle.result() to get the AgentResult. The v1 server is synchronous, so the run is already complete when the handle is returned; start exists so calling code is forward-compatible with the deferred async launch/poll path.

AgentResult is a frozen dataclass:

  • .output: the agent's final assistant message text.
  • .session: the durable agent id the run resolved to. Pass it back as session= to resume.
  • .status: the terminal run status: completed, failed, or timeout.
  • .usage: an opaque per-run usage dict (model, tokens) in v1; treat it as a pass-through.

A failed invocation raises AgentInvokeError, which carries the backend HTTP status_code and a machine-readable code so you can branch on a permission denial versus a transient failure.

Model rolesLink to this section

By default an agent runs on the agent's default model. Pass model to run it on a model role instead:

python
result = agent.run("Classify this support ticket as billing, bug, or question", model="light")
RoleUse it for
frontierThe highest-quality hosted model, for hard reasoning
standardThe everyday workhorse for structured output and agent loops
lightA light, fast hosted model for simple, high-volume agent work

model takes a role name only, never a provider model name: anything else is refused with HTTP 422, raised as AgentInvokeError. The platform maps each role to its current model, so a model upgrade needs no code change. The run's model usage is billed to llm:<role> under that role's plan limits. A run that resumes a session without model keeps the model that session last ran on.

Sessions and Tier-1 memoryLink to this section

The session argument is the continuity handle. It is a stable name, resolved per workspace as a create-if-missing idempotency key:

  • The first call with a given name creates the durable agent and runs it fresh.
  • Later calls with the same name resume the same agent and append the prompt, so "check again" reasons against everything that came before.
python
first = agent.run("Investigate this week's churn", session="churn-watch")
again = agent.run("Now compare against last week", session="churn-watch")  # resumes

The transcript lives on a persistent volume, so continuity survives the sandbox being torn down once it has been idle. This is Tier-1 memory: the session is the memory, exactly like a human returning to a chat. There is no separate memory file to manage in v1.

A session name is an idempotency key scoped to the workspace and the run-as owner. It is not a global handle, so two functions using the same name do not cross-resume into each other's transcript. Omit session for a fresh, ephemeral run with no continuity.

Visibility and trigger typesLink to this section

Every agent carries a trigger (how it was started) and an is_private (incognito) flag.

  • Trigger is how the agent was started: interactive (a chat), on_demand (run-now from a user or the CLI), or code (an agent.run() from a notebook or function body, including a scheduled function whose body calls agent.run()). All trigger types render in the same unified Agents list, filterable by type.
  • is_private (incognito) scopes an agent's reads to its creator. Agents are workspace-visible by default; an incognito agent is hidden from other members. Visibility only broadens reads: attaching to, driving, or mutating a running agent stays owner-only.

Set incognito at create time in the UI, or toggle it per agent. Existing transcripts predating this feature are all private.

Scope and what a code-invoked agent can doLink to this section

A code-invoked agent.run() does not run with your full rights. The backend mints a narrowed token, server-side, that is never trusted to the SDK. Its credential scopes are dotted names, and the data-plane scopes come from your live Workspace Access Level in the run's Workspace:

ScopeLets the runviewereditor or owner
workspace.readRead Workspace content and metadatayesyes
lake.readQuery the Workspace's Lakehousesyesyes
egress.proxyCall Connections through the egress proxy, with credentials injected server-sideyesyes
workspace.writeChange Workspace contentnoyes
lake.writeWrite Lakehouse datanoyes
egress.revealRead raw Connection material where the Connection allows itnoyes
git.readRead the Workspace's Git repositoryyesyes
agent.toolsUse the agent toolingyesyes
llm.invokeCall the language modelyesyes
  • The scopes are fixed when the token is minted and every use is still checked against your live Access Level, so a run never exceeds what you hold at that moment.
  • git.read, agent.tools, and llm.invoke are always kept, so every run can start and reason.
  • The prompt is data that an attacker may influence. When a run only needs to read, narrow it so a prompt-injected agent cannot write.

The optional scope argument can only narrow the data-plane scopes further (intersect-only). It keeps only the listed data-plane scopes that your Access Level allows; it can never add authority you do not already hold. It also never exceeds the scopes of the credential your code runs with, so a run started from a read-only Function token gets read scopes only. Pass dotted scope names from the table above; a value that is not one of them grants nothing.

python
# Restrict this run's data plane to lake reads only: no writes and no egress.
# (LLM and agent tooling stay available, so the agent can still run.)
result = agent.run(prompt, scope=["lake.read"])

An agent cannot invoke another agent: a call made from inside an agent sandbox is rejected server-side.

Notifying via connectionsLink to this section

There is no separate notification API. An agent "notifies" by calling an HTTP Connection (a Slack webhook, an email provider, PagerDuty) through the egress proxy, with the credential injected server-side, the same path any provider call takes. To let an agent alert a channel, grant it the connection and mention it in the prompt:

python
agent.run(
    "If today's revenue dropped more than 20% vs the 7-day average, "
    "post a one-line summary to the 'slack-finance' connection.",
)

A run without egress.reveal, such as a viewer's run or one narrowed with scope=, can still post: posting to a connection uses egress.proxy (server-side injection), not reveal. See limilake docs connections.

Scheduling an agentLink to this section

Scheduling is not a new CLI verb. A scheduled agent is just a normal function with a schedule= whose body calls agent.run(). It rides the existing cron spine: the same leases, concurrency policy, and retry behavior every function gets.

python
from limilake import function, lake, agent

fn = function(name="invoice-watch", schedule="0 7 * * *")  # daily at 07:00


@fn.action
def run() -> dict[str, object]:
    # Deterministic check FIRST: cheap, no LLM, fully programmable.
    n = lake.query("select count(*) n from bronze.invoices where date = current_date")[0]["n"]
    if n == 0:
        return {"skipped": "no new invoices"}  # never spend an agent

    # Escalate to an agent only when warranted.
    r = agent.run(
        "Investigate today's invoices and report anything materially off. "
        "If something needs attention, post a summary via the 'slack-finance' connection.",
        session="invoice-watch",  # stable name => same durable agent each fire
    )
    return {"checked": n, "summary": r.output}

This deterministic-check-then-invoke shape is the intended pattern: do the cheap, fully-programmable check in plain code, and only pay for an agent when the check says it is worth it. The agent's session name keeps every fire continuous with the last.

Notes for scheduled agents:

  • Cadence. Keep a schedule that drives an agent to at most one fire every 15 minutes; daily or weekly is the economic sweet spot, since each fire is a sandbox plus a multi-turn LLM loop. The platform's limit is one fire every 5 minutes for any schedule.
  • Concurrency. A schedule never overlaps itself: a fire while the previous run is still running is skipped, not stacked. There is nothing to set; concurrency_limit= limits concurrent HTTP requests, not scheduled runs.
  • Dedup. Do your own "did I already handle this?" check in code (for example a high-water-mark in a lake table). There is no dedicated cursor subsystem in v1.

See limilake docs functions for the full function/scheduling surface.

Where it runsLink to this section

pi (the agent runtime) lives only server-side. agent.run() carries no local LLM; it authorizes against the backend, which launches the agent headless in a managed sandbox and captures the result. Inside a managed sandbox the token and workspace are injected automatically; from a laptop or CI, set LIMILAKE_TOKEN (or LIMILAKE_TOKEN_FILE) and LIMILAKE_WORKSPACE_ID.