Agent

Agents are the core building block in your agentic application

Agents Overview

An agent is configuration object that defines the tools, instructions, and model settings - it's not a running process but rather a blueprint or template. The actual execution of tasks happens separately when you invoke this agent configuration, keeping the definition distinct from its runtime behavior. Think of an agent as a recipe that specifies ingredients and instructions: the recipe itself doesn't cook the meal, but it provides all the necessary information for someone (or something) to execute the cooking process when needed.

Creating an Agent

The most common properties of an agent you'll configure are:

name: A required string that identifies your agent.instructions: Also known as a developer message or system prompt. These are the guiding instructions for your agentmodel: which LLM to use as base modeltools: Tools that the agent can use to achieve its tasks.

from seekrai.types import CreateAgentRequest
from seekrai import SeekrFlow
api_key = "your_api_key"
client = SeekrFlow(api_key=api_key)

agent = client.agents.create(
    CreateAgentRequest(
        name="homework_tutor_bot",
        instructions="You are a tutor bot for middle schoolers. Answers the questions in a way middle schoolers can understand",
        model_id="meta-llama/Llama-3.1-8B-Instruct",
        tools=[]
    )
)
print(f"Agent created with ID: {agent.id}")
print(f"Agent status: {agent.status}")

Note: Agents can be configured to use any base or fine-tuned model available on the SeekrFlow platform.

Instructions Best Practices

When formulating the agent's instruction's we suggest the following best practices:

  1. Define Role, Goal, and Context
    Clearly state the agent’s persona, objective, and any relevant background.

“You are a procurement research assistant tasked with finding active government contracts based on user input.”

  1. Be Specific and Prescriptive
    Break complex tasks into simpler, step-by-step subgoals, and ensure the instruction includes how each tool is to be leveraged.

"Use the search_contracts tool only after collecting both a state and keyword.”

  1. Call Out Edge Cases and Desired Behavior Explicitly
    If the agent should not respond to certain queries or behaviors, say so directly.

“Do not answer legal or compliance questions — respond with: ‘I’m not able to help with that.’”

  1. Output Guidelines
    If not using structured outputs, be extremely clear about the desired format and tone.

“Respond in a numbered list with no more than 3 items. Use plain language and avoid technical jargon.”

Agent Status

Each agent has an associated status.

  • Active indicates the agent is ready to serve active traffic
  • Pending indicates the agent has recently been promoted and will soon become active
  • Inactive indicates the agent is not currently deployed, and needs to be activated before it can service traffic

List Your Agents and Their Status

To list all of the agent's you've created and their associated status, you can use the below code snippet:

available_agents = client.agents.list_agents()

print("Available agents:")
for agent in available_agents:
    print(f"ID: {agent.id}, Name: {agent.name}, Status: {agent.status}"

Promote an agent

Note: Agent create requests will promote an agent automatically. Agents only need to be promoted after they've been demoted and are in an inactive state.

agent = client.agents.promote(agent.id)
print(f"Agent promoted. Agent ID: {agent.id}")

Demote an agent

Demoting an agent moves it to an inactive state. This is useful when you want to retain the agent's definition without allowing it to handle inference requests.

agent = client.agents.demote(agent.id)
print(f"Agent demoted. Agent ID: {agent.id}")

Delete an agent

This permanently removes an agent from the SeekrFlow platform.

del_response = client.agents.delete(agent.id)
print(f"Agent deleted. Agent ID: {agent.id}")