Skip to content

AgentProfile

Represents an individual agent in the multi-agent system.

Creating an Agent

from gmas.core import AgentProfile

agent = AgentProfile(
    agent_id="researcher",
    display_name="Senior Researcher",
    description="Conducts thorough research on given topics",
    persona="You are an experienced researcher with attention to detail",
    tools=["search", "browse", "calculator"],
)

Agent Properties

agent.agent_id          # Unique identifier
agent.display_name      # Human-readable name
agent.description       # Functional description
agent.persona           # Agent personality/role
agent.tools             # Available tools
agent.state             # Local state dict
agent.embedding         # Encoded representation

Agent State

Each agent maintains its own state (decentralized memory):

# Read state
current_state = agent.state

# Append messages immutably
agent = agent.append_state({"role": "user", "content": "example query"})
agent = agent.append_state({"role": "assistant", "content": "example result"})

# Check if key exists
if agent.state:
    latest_message = agent.state[-1]

Agent with Hidden State

For GNN routing and advanced features:

import torch

hidden = torch.randn(128)  # Hidden state vector
agent = agent.with_hidden_state(hidden)

LLM Configuration

from gmas.core import AgentProfile, AgentLLMConfig

config = AgentLLMConfig(
    model="gpt-4",
    temperature=0.7,
    max_tokens=1000,
)

agent = AgentProfile(
    agent_id="agent",
    display_name="Agent",
    llm_config=config,
)

Tools

Assign tools to agents:

agent = AgentProfile(
    agent_id="analyst",
    display_name="Data Analyst",
    tools=[
        "python",           # Code execution
        "calculator",       # Math operations
        "web_search",      # Search the web
    ],
)

# Check available tools
if "web_search" in agent.tools:
    # Agent can search the web
    pass

Cloning and Updating

# Update specific fields
updated = agent.model_copy(update={
    "display_name": "New Name",
    "description": "New description",
})

# Or use with methods
updated = agent.with_state({"key": "value"})