agx is a JSX agent development system.
Agents are large language models (LLMs) that use tools until the task is complete.
agx provides a declarative way to build AI agents using JSX syntax and AI SDK primitives.
- LLMs process input and decide the next action
- Tools extend capabilities beyond text generation (reading files, calling APIs, writing to databases)
- Loop orchestrates execution through:
- Context management - Maintaining conversation history and deciding what the model sees (input) at each step
- Stopping conditions - Determining when the loop (task) is complete
Define an agent by declaring a new component using the Agent component with
your desired configuration.
import { Agent, Tool } from "@fartlabs/agx";
import { stepCountIs } from "ai";
import { z } from "zod";
function WeatherAgent() {
return (
<Agent model="openai/gpt-4o" stopWhen={stepCountIs(20)}>
<Tool
name="weather"
description="Get the weather in a location (in Fahrenheit)"
inputSchema={z.object({
location: z.string().describe(
"The location to get the weather for",
),
})}
execute={(args) => ({
location: args.location,
temperature: 72 + Math.floor(Math.random() * 21) - 10,
})}
/>
<Tool
name="convertFahrenheitToCelsius"
description="Convert temperature from Fahrenheit to Celsius"
inputSchema={z.object({
temperature: z.number().describe(
"Temperature in Fahrenheit",
),
})}
execute={(args) => {
const celsius = Math.round((args.temperature - 32) * (5 / 9));
return { celsius };
}}
/>
</Agent>
);
}
const weatherAgent = <WeatherAgent />;Once defined, you can integrate the agent into your application.
const result = await weatherAgent.generate({
prompt: "What is the weather in San Francisco in celsius?",
});
console.log(result.text); // agent's final answer
console.log(result.steps); // steps taken by the agentFor more information on using an instance of the Agent component, see the AI SDK documentation.
See the examples directory for more examples.
Run the weather example:
deno --env -A examples/weather/main.tsx
Developed with 🧪 @FartLabs