agentleFS
lauren-frameworklauren-framework/lauren-ai/skills/building-agents/SKILL.md

building-agents

Skill0 starsChanged 6 months agoMITView on GitHub

Builds AI agents with the lauren-ai framework using @agent, @use_tools, and AgentRunner. Use when defining an agent class, setting up lifecycle hooks, streaming responses, implementing agent delegation, or configuring the agentic loop with tools, guardrails, and memory.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All parameters are passed as keyword arguments to @agent():

    line 85

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Use codemap find "SymbolName" to locate any symbol before reading — it gives exact file + line range and is faster than grep across the whole repo.

Building Agents with lauren-ai

Quick start

# agent.py — from __future__ import annotations IS allowed here (no @tool)
from __future__ import annotations

from lauren_ai import agent, use_tools
from .tools import get_price

@agent(model="claude-opus-4-6", system="You are a helpful shop assistant.")
@use_tools(get_price)
class ShopAgent: ...

Run it:

from lauren_ai import AgentRunnerBase, LLMConfig

cfg = LLMConfig(provider="anthropic", model="claude-opus-4-6")
runner = AgentRunnerBase(transport=transport)
result = await runner.run(ShopAgent(), "How much is a Widget?")
print(result.content)

Decorator order (mandatory)

Decorators are applied bottom-up in Python. Always write them top-to-bottom in this order so each decorator reads the metadata set by those below it:

@agent()           ← outermost (top)   — applied last, reads all metadata
@remember()        ← optional
@use_guardrails()  ← optional
@use_tools(...)    ← innermost (bottom) — applied first, sets USE_TOOLS_META
class MyAgent: ...

Full example with all optional layers:

from lauren_ai import agent, remember, use_guardrails, use_tools
from lauren_ai import PromptInjectionFilter, PIIRedactor
from .tools import search_database, send_email
from .memory import user_memory_store

@agent(model="claude-opus-4-6", system="You are a personal assistant.", max_turns=10)
@remember(store=user_memory_store, extract=True, inject=True, top_k=5)
@use_guardrails(
    input=[PromptInjectionFilter(), PIIRedactor()],
)
@use_tools(search_database, send_email)
class PersonalAssistant: ...

Safety invariants

RuleWhy it matters
@agent always outermost (top), @use_tools always innermost (bottom)Wrong order means @agent reads metadata before @use_tools writes it — tools silently disappear
Always call decorators with parentheses@agent() not @agent — bare form raises DecoratorUsageError at decoration time
Use @use_guardrails() to attach guardrails to agents@guardrail() is for making standalone DI-injectable guardrail classes; @use_guardrails() wires them into an agent
Never trust LLM-supplied identity in toolsUse ctx.execution_context.request.state.get("user_id") — see security.md
Tool annotations must resolve when schema generation runsFuture annotations are supported, but unresolved forward refs and circular imports in function-form tool files still break @tool() schema generation

AgentConfig parameters

All parameters are passed as keyword arguments to @agent():

ParameterTypeDefaultDescription
modelstrrequiredModel string, e.g. "claude-opus-4-6"
systemstr""System prompt for the agent
max_turnsint10Maximum agentic loop iterations
max_tokens_per_turnint4096Maximum output tokens per LLM call
temperaturefloat1.0Sampling temperature (0.0–1.0)
memory_window_tokensint40_000Rolling context window size in tokens
max_cost_usdfloat | NoneNoneHard cost cap; raises AgentBudgetExceededError
parallel_tool_callsboolTrueExecute multiple tool calls concurrently
tool_error_policystr"return_error""raise" | "return_error" | "skip"

Reference files

FileContents
agents.mdFull reference: minimal agent, lifecycle hooks, streaming, delegation, all AgentConfig params
../building-tools/tools.mdFunction-form and class-form tools, HITL, caching, built-in skills
../securing-agents/security.mdAuthentication via ToolContext.execution_context.request.state

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.