AgentMark supports extending prompts with custom tools (like API calls or calculations) and creating agents that can make multiple LLM calls to solve complex tasks.

Tools

Tools are custom functions that your prompts can use to interact with external systems or perform specific operations.

1. Create and Register Tools

First, create and register your tools with the adapter tool registry:

import { VercelAIToolRegistry, createAgentMarkClient } from "@agentmark/vercel-ai-v4-adapter";

// Create your tool function
const checkWeather = async (input: { location: string, date?: string }) => {
  // Your weather checking logic here
  const weather = await weatherAPI.get(input.location, input.date);
  return { temperature: weather.temp, conditions: weather.conditions };
};

// create tool registry
const toolRegistry = new VercelAIToolRegistry();

// Register the tool
toolRegistry.register("check_weather", checkWeather);

// create agentmark client
const agentmarkClient = createAgentMarkClient({
  toolRegistry,
});

2. Define Tool Schema in Prompt

Then use the tool in your prompt:

---
name: weather-advisor
text_config:
  model_name: gpt-4
  tools:
    check_weather:
      description: Get current weather for a location
      parameters:
        type: object
        properties:
          location:
            type: string
            description: City or location name
          date:
            type: string
            description: Date to check (YYYY-MM-DD)
        required: ["location"]
---

<System>
You are a travel advisor that can check weather conditions. Use the weather tool to provide accurate forecasts.
</System>

<User>What's the weather like in Paris today?</User>

Agents

Agents can make multiple LLM calls and use tools to solve complex tasks.

1. Register Multiple Tools

import { VercelAIToolRegistry, createAgentMarkClient } from "@agentmark/vercel-ai-v4-adapter";

// create tool registry
const toolRegistry = new VercelAIToolRegistry();

// Register all your tools
toolRegistry.register("search_flights", searchFlights);
toolRegistry.register("check_weather", checkWeather);

// create agentmark client
const agentmarkClient = createAgentMarkClient({
  toolRegistry,
});

2. Create Multi-Step Agent

Enable agent capabilities by setting max_calls in your prompt:

---
name: travel-planner
text_config:
  model_name: gpt-4
  max_calls: 3  # Allow multiple LLM calls
  tools:
    search_flights:
      description: Search available flights
      parameters:
        type: object
        properties:
          from:
            type: string
          to:
            type: string
          date:
            type: string
        required: ["from", "to"]
    check_weather:
      description: Check weather forecast
      parameters:
        type: object
        properties:
          location:
            type: string
        required: ["location"]
---

<System>
You are a travel planner that can:
1. Search for flights
2. Check destination weather
3. Make travel recommendations
</System>

<User>Help me plan a trip from NYC to Miami next week.</User>

3. Run the Agent

import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { createAgentMarkClient, VercelAIToolRegistry } from "@agentmark/vercel-ai-v4-adapter";  
import { FileLoader } from "@agentmark/agentmark-core";

// create tool registry
const toolRegistry = new VercelAIToolRegistry();

const prompt = await agentmarkClient.loadTextPrompt("travel-planner.prompt.mdx");

const vercelInput = prompt.format({
  props: {
    // your props here
  }
});

const result = await generateText(vercelInput);

Learn More

For detailed information about implementing tools, creating agents, and best practices, see the AgentMark Tools and Agents Documentation.

Key features include:

  • Custom tool creation
  • Multiple tool support
  • Multi-step agent workflows
  • Error handling
  • Parameter validation

Have Questions?

We’re here to help! Choose the best way to reach us: