A real world agent

See how it works in real

This tutorial walks you through creating a Daily Update Agent using AXAR AI. The agent retrieves activities from JIRA and Bitbucket, summarizes them, and presents a concise daily update. This example demonstrates AXAR’s features like dynamic prompts, tools, and dependency injection.

The Problem

Keeping track of daily team activities across tools like JIRA and Bitbucket can be time-consuming. Let’s automate this by building an agent that:

  1. Fetches team members.

  2. Collects their JIRA and Bitbucket activities.

  3. Summarizes the activities in a readable format.

The Solution

We'll use AXAR AI to create a Daily Update Agent. Here’s the full code:

import { model, systemPrompt, Agent, tool } from "@axarai/axar";
import { JiraClient } from "./tools/jira";
import { BitbucketClient } from "./tools/bitbucket";

/**
 * An AI agent that generates daily team updates by collecting and summarizing
 * activities from JIRA and Bitbucket. The agent follows a structured approach
 * to gather information about team members and their activities.
 *
 * @model openai:gpt-4o-mini - Uses GPT-4 for natural language processing
 * @systemPrompt - Main system prompt for the agent
 */
@model("openai:gpt-4o-mini")
@systemPrompt(`
# Objective
Your task is to create a daily team update summarizing the activities of each team member.

# Steps

## 1. Retrieve Team Members
- Use the appropriate tools to fetch the list of team members.

## 2. Collect Activities
- Use the tools to gather each member's **JIRA activities** for the day.
- Use the tools to gather each member's **Bitbucket activities** for the day.

## 3. Summarize Activities
- Create a **short, readable summary** of the activities for each team member in a **TL;DR format**.
- If a team member has **no activities**, include the message: "No activities for the day."

# Output Format
- Organize the output into **separate sections** for each team member.
- Present the information in **Markdown format**.
`)
export class DailyUpdateAgent extends Agent<string, string> {
  /**
   * Creates a new instance of DailyUpdateAgent
   * @param jiraClient - Client for interacting with JIRA API
   * @param bitbucketClient - Client for interacting with Bitbucket API
   */
  constructor(
    private jiraClient: JiraClient,
    private bitbucketClient: BitbucketClient
  ) {
    super();
  }

  /**
   * Fetches all active members from the JIRA workspace
   * @returns Markdown formatted string containing workspace member details
   */
  @tool("Fetch all active members from the JIRA workspace")
  async getWorkspaceMembers(): Promise<string> {
    return this.jiraClient.fetchWorkspaceMembers();
  }

  /**
   * Retrieves JIRA activities (issues, updates) from the last 24 hours
   * @returns Markdown formatted string containing recent JIRA activities
   */
  @tool("Retrieve recent JIRA activities (issues, updates)")
  async getRecentJiraActivities(): Promise<string> {
    return this.jiraClient.fetchRecentActivities();
  }

  /**
   * Retrieves Bitbucket activities (commits) from the last 24 hours
   * @returns Markdown formatted string containing recent Bitbucket activities
   */
  @tool("Retrieve recent Bitbucket activities")
  async getRecentBitbucketActivities(): Promise<string> {
    return this.bitbucketClient.fetchRecentActivities();
  }
}

/**
 * Main function to run the daily update agent
 * Initializes JIRA and Bitbucket clients with authentication details
 * and executes the agent to generate the daily update
 */
async function main() {
  // Initialize JIRA client with authentication details
  const jiraClient = new JiraClient({
    baseUrl: "https://timetackle-team.atlassian.net",
    email: "your@email.com",
    apiToken: "YOUR-API-KEY",
    projectKey: "YOUR-PROJECT-KEY",
  });

  // Initialize Bitbucket client with authentication details
  const bitbucketClient = new BitbucketClient({
    auth: {
      username: "YOUR-USER-NAME",
      password: "YOUR-APP-PASSWORD",
    },
    workspace: "YOUR-WORKSPACE-ID",
  });

  // Create and run the agent
  const agent = new DailyUpdateAgent(jiraClient, bitbucketClient);
  const response = await agent.run("Give me the daily update for the team");
  console.log(response);
}

// Execute the main function and handle any errors
main().catch(console.error);

For brevity, the implementation of BitbucketClient and JiraClient is not included here. We will publish them soon in our axar-examples repository.

💡 What just happened?

Let’s break this down step by step:

1

Define the agent

We created a class DailyUpdateAgent that extends Agent from AXAR. It specifies:

  • Model: The AI model using the @model decorator (openai:gpt-4o-mini in this case).

  • Prompt: A detailed system-level instruction using @systemPrompt.

The prompt defines:

  • What the agent should do.

  • The format of the output.

2

Dependency injection

The agent is initialized with two clients:

  • JiraClient: Manages JIRA interactions.

  • BitbucketClient: Manages Bitbucket interactions.

This makes the agent modular and testable.

constructor(
  private jiraClient: JiraClient,
  private bitbucketClient: BitbucketClient
) {
  super();
}
3

Add tools

Tools are decorated with @tool, allowing the agent to interact with external world. We added three tools:

  1. Get Workspace Members: Fetches the list of team members from JIRA.

    @tool("Fetch all active members from the JIRA workspace")
    async getWorkspaceMembers(): Promise<string> // ...
  2. Get Recent JIRA Activities: Retrieves activities from JIRA.

    @tool("Retrieve recent JIRA activities (issues, updates)")
    async getRecentJiraActivities(): Promise<string> // ...
  3. Get Recent Bitbucket Activities: Retrieves activities from Bitbucket.

    @tool("Retrieve recent Bitbucket activities")
    async getRecentBitbucketActivities(): Promise<string> // ...
4

Run the agent

In main(), we:

  1. Instantiate JiraClient and BitbucketClient with their respective configurations.

  2. Create a DailyUpdateAgent using the clients.

  3. Call agent.run() to execute the prompt logic.

const agent = new DailyUpdateAgent(jiraClient, bitbucketClient);
const response = await agent.run("Give me the daily update for the team");
console.log(response);
5

Output

The agent:

  • Fetches the list of members.

  • Retrieves their activities from JIRA and Bitbucket.

  • Summarizes these in Markdown format, with placeholders for team members with no activity.

Conclusion

This example demonstrated how to use AXAR AI to automate summarizing daily activities from across multiple external platforms. By leveraging tools and a clear system prompt, we created a modular, scalable agent that integrates with external APIs.

Now, extend this agent for additional workflows or integrate other platforms!

Last updated