larzagent
Zero-dependency AI agents.
A tool-calling agent framework against any OpenAI-compatible chat-completions API: register_tool() takes an explicit JSON-schema parameter spec (no decorators or type-hint introspection to derive one from), a defensive loop where a tool that throws never crashes the run, and a fully injectable transport so tests never touch a real network.
larzscript pkg install agent
What you get
- Explicit JSON-schema tool specs
- Defensive tool-calling loop
- Any OpenAI-compatible API
- Pluggable transport for tests
Try it
import "agent" as agent
let a = agent.new({"model": "gpt-4"})
agent.register_tool(a, "add", "Add two numbers", {
"type": "object", "properties": {"a": {"type": "number"}, "b": {"type": "number"}}, "required": ["a", "b"]
}, fn(args) { return args["a"] + args["b"] })
fn fake_transport(payload) {
return {"choices": [{"message": {"content": "2 + 3 = 5", "tool_calls": nil}}]}
}
let result = agent.chat(a, "what is 2 + 3?", fake_transport)
print(result["content"])Output
2 + 3 = 5
Why it's in the Larz Stack
larzagent is a real Larzscript package (larzscript pkg install agent) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.