Agent

This chapter describes the concept of agent.

Idea

Agent in Maia Framework represents the AI Agent in your agentic system. Agent is abstraction over the model, so agent itself does not know what kind of the model is using - thanks to that different agents can be used in the same way in tests.

You can have many agents in your tests. Every agent has its own name (assigned in test) and provider.

Usage in tests

Agents can be created in two places - in setup phase or in test.

Setup phase

class TestConversationSessions(MaiaTest):
    def setup_agents(self):
        self.create_agent(
            name="Alice",
            provider=self.get_provider("ollama"),
            system_message="You are a weather assistant. Only describe the weather.",
            ignore_trigger_prompt="You MUST NOT answer questions about any other topic, including what to wear. If the user asks about anything other than the weather, you MUST respond with only the exact text: IGNORE_MESSAGE",
        )

        self.create_agent(
            name="Bob",
            provider=GenericLiteLLMProvider(config={
                "model": "ollama/mistral",
                "api_base": "http://localhost:11434"
            }),
            system_message="You are a pirate assistant who only suggests clothing.",
            ignore_trigger_prompt="If the question is not about what to wear, you MUST respond with only the exact text: IGNORE_MESSAGE"
        )

In test

    @pytest.mark.asyncio
    async def test_conversation_direct_message(self):
        self.create_agent(
            name="Alice",
            provider=GenericLiteLLMProvider(config={
                "model": "ollama/mistral",
                "api_base": "http://localhost:11434"
            }),
            system_message="You are a weather assistant."
        )
        self.create_agent(
            name="Bob",
            provider=GenericLiteLLMProvider(config={
                "model": "ollama/mistral",
                "api_base": "http://localhost:11434"
            }),
            system_message="You are a assistant who only suggests clothing."
        )

Configuration

As in above examples, you can see there are couple of parameters when you are creating agent. Let's break them down here:

Name

This is assigned name to the agent. It is needs to be unique, because framework is using it to distinguish agents in communication. It is a free text.

Provider

The provider is one of the most important concept in Maia. It is used to configure agent to use a proper model. Because on the market we have plenty of models, the Maia framework itself does not provide implementation of all of them. However, it is solved by providing different solutions, including Generic Lite LLM provider which uses very popular library LiteLLM. It gives nice abstraction, so you need to only pass information about the model and API endpoint.

You can also implement your own provider or use our implementations, including Ollama, LiteLLM, Mock or even totally custom agent. More information can be found here: Provider

System message

It is used to configure the agent, for instance explaining the background or role.

Ignore trigger prompt

This special parameter is used for tests which have many AI Agents and you would like to have automatic orchestration. It lets you to broadcast the message and expect that proper AI Agent will respond. This is advanced concept which usage is explained in details in Advanced tests

Note:

Agent is one of the core concepts so its API is matter of change. MAIA framework is still MVP.