Puzzlet 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 SDK:

import { ToolPluginRegistry } from "@puzzlet/agentmark";

// 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 };
};

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

2. Define Tool Schema in Prompt

Then use the tool in your prompt:

---
name: weather-advisor
metadata:
  model:
    name: gpt-4
    settings:
      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 { ToolPluginRegistry } from "@puzzlet/agentmark";

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

2. Create Multi-Step Agent

Enable agent capabilities by setting max_llm_calls in your prompt:

---
name: travel-planner
metadata:
  model:
    name: gpt-4
    settings:
      max_llm_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 { runInference } from '@puzzlet/agentmark';

const result = await runInference(prompt, {
  // Your props here
});

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: