Python Quickstart
Copy
import asyncio
from icrl import Agent, LiteLLMProvider
class SimpleEnv:
def __init__(self):
self._goal = ""
def reset(self, goal: str) -> str:
self._goal = goal
return "Ready"
def step(self, action: str) -> tuple[str, bool, bool]:
if action.strip().lower() == "done":
return "Completed", True, True
return f"Observed action: {action}", False, False
agent = Agent(
llm=LiteLLMProvider(model="gpt-4o-mini"),
db_path="./trajectories",
plan_prompt="Goal: {goal}\n\nExamples:\n{examples}\n\nCreate a short plan.",
reason_prompt="Goal: {goal}\nPlan: {plan}\nObservation: {observation}\nHistory:\n{history}\nExamples:\n{examples}\n\nThink:",
act_prompt="Goal: {goal}\nPlan: {plan}\nReasoning: {reasoning}\nObservation: {observation}\n\nRespond with one action.",
)
async def main() -> None:
env = SimpleEnv()
await agent.train(env, "finish this task")
await agent.run(env, "finish this task again")
asyncio.run(main())
TypeScript Quickstart
Copy
import OpenAI from "openai";
import { Agent, FileSystemAdapter, OpenAIEmbedder, OpenAIProvider, type Environment } from "icrl";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
class SimpleEnv implements Environment {
reset(goal: string): string {
return `Goal: ${goal}`;
}
async step(action: string) {
if (action.trim().toLowerCase() === "done") {
return { observation: "Completed", done: true, success: true };
}
return { observation: `Observed action: ${action}`, done: false, success: false };
}
}
const agent = new Agent({
llm: new OpenAIProvider(openai, { model: "gpt-4o-mini" }),
embedder: new OpenAIEmbedder(openai),
storage: new FileSystemAdapter("./trajectories-ts"),
planPrompt: "Goal: {goal}\nExamples:\n{examples}\nCreate a short plan.",
reasonPrompt:
"Goal: {goal}\nPlan: {plan}\nObservation: {observation}\nHistory:\n{history}\nExamples:\n{examples}\nThink:",
actPrompt:
"Goal: {goal}\nPlan: {plan}\nReasoning: {reasoning}\nObservation: {observation}\nRespond with one action.",
});
await agent.init();
await agent.train(new SimpleEnv(), "finish this task");
await agent.run(new SimpleEnv(), "finish this task again");
Next
- CLI docs:
/guides/cli - Examples:
/examples/basic-openai-demo,/examples/file-system-agent - TypeScript package guide:
/guides/typescript-package - Web + Convex setup:
/guides/web-example

