Agentick AI Component Framework

0.14.47 · active · verified Tue Apr 21

Agentick is a component-based framework for building AI applications, currently at version 0.14.47. It operates on a rapid release cadence with frequent patch updates across its monorepo packages, indicating active development. A key differentiator is its novel approach as a React reconciler, where the render target is a language model itself. Developers construct the model's context window using familiar JSX syntax, React components, and hooks, abstracting away traditional prompt templating. The framework compiles this JSX into what the language model 'sees,' providing fine-grained control over the model's perception and interaction. This paradigm shifts AI application development from pipeline or chain configurations to a more declarative, component-driven style.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates creating a simple research agent using Agentick's JSX components to define system instructions, include conversation history, and integrate a custom search tool, then running it with an OpenAI model.

import { createApp, System, Timeline, createTool, useContinuation } from "@agentick/core";
import { openai } from "@agentick/openai";
import { z } from "zod";

const knowledgeBase = {
  search: async (query: string) => {
    // Simulate a search against a knowledge base
    console.log(`Searching for: ${query}`);
    if (query.includes("quantum computing")) {
      return [{ title: "Quantum computing advances", snippet: "Recent breakthroughs in error correction and qubit stability." }];
    }
    return [{ title: "General AI trends", snippet: "Overview of current AI research directions." }];
  }
};

const Search = createTool({
  name: "search",
  description: "Search the knowledge base",
  input: z.object({ query: z.string() }),
  handler: async ({ query }) => {
    const results = await knowledgeBase.search(query);
    return [{ type: "text", text: JSON.stringify(results) }];
  }
});

function ResearchAgent() {
  useContinuation((result) => result.tick < 10); // Limit ticks to prevent infinite loops

  return (
    <>
      <System>Search thoroughly, then write a summary based on the findings.</System>
      <Timeline />
      <Search />
    </>
  );
}

// Ensure process.env.OPENAI_API_KEY is set or passed securely
const openAIApiKey = process.env.OPENAI_API_KEY ?? ''; 

const app = createApp(ResearchAgent, { model: openai({ model: "gpt-4o", apiKey: openAIApiKey }) });

(async () => {
  if (!openAIApiKey) {
    console.error("OPENAI_API_KEY environment variable is not set. Please set it to run the example.");
    return;
  }
  const result = await app.run({
    messages: [
      { role: "user", content: [{ type: "text", text: "What's new in quantum computing?" }] }
    ]
  });
  console.log("Agent Response:", result.response);
})();

view raw JSON →