Security advisory — Malicious litellm versions 1.82.7 and 1.82.8 were removed from PyPI (potential API key exfiltration). Uninstall them, rotate exposed credentials, and upgrade to a safe release (e.g. 1.82.9+). Run pip show litellm to verify. PyPI · README

Building Your First Agent

Step-by-step guide to building a research agent.

Building Your First Agent

Build a research agent that takes a topic, calls tools, and returns a structured report. This is the SDK path: Agent + Task + AgentExecutor. For Near chat, start agx serve instead — see Quickstart.

Diagram: Task into AgentExecutor.run; tool_calls loop until a text report.

Step 1: Set up

bash
1pip install agenticx
2export OPENAI_API_KEY="your-key"

Step 2: Define tools

python
1from agenticx.tools import tool
2import httpx
3
4@tool
5def search_web(query: str) -> str:
6 """Search the web for information about a topic.
7
8 Args:
9 query: The search query
10 """
11 response = httpx.get(
12 "https://api.search.com/search",
13 params={"q": query, "key": "your-api-key"},
14 timeout=30,
15 )
16 return response.text
17
18@tool
19def fetch_page(url: str) -> str:
20 """Fetch the first 5000 characters of a web page.
21
22 Args:
23 url: The URL to fetch
24 """
25 response = httpx.get(url, follow_redirects=True, timeout=30)
26 return response.text[:5000]

Replace the search URL with a real API. @tool wraps a function as a FunctionTool / BaseTool.


Step 3: Define the agent

python
1from agenticx import Agent
2
3research_agent = Agent(
4 id="research-agent",
5 name="Research Assistant",
6 role="Senior Research Analyst",
7 goal=(
8 "Conduct thorough research on any given topic. "
9 "Find authoritative sources, synthesize information, "
10 "and produce clear, well-structured reports."
11 ),
12 backstory=(
13 "You are an expert researcher with a background in "
14 "information synthesis and critical analysis."
15 ),
16 organization_id="my-research-org",
17 max_iterations=15,
18 tools=[search_web, fetch_page],
19)

Step 4: Run a task

python
1from agenticx import Task, AgentExecutor
2from agenticx.llms import OpenAIProvider
3
4task = Task(
5 description="Research: Multi-agent AI systems and software development",
6 expected_output=(
7 "A structured research report with:\n"
8 "1. Executive summary\n"
9 "2. Key findings\n"
10 "3. Detailed analysis\n"
11 "4. Sources and references"
12 ),
13)
14
15executor = AgentExecutor(
16 llm_provider=OpenAIProvider(model="gpt-4o"),
17 tools=[search_web, fetch_page],
18)
19result = executor.run(agent=research_agent, task=task)
20print(result)

run returns a dict with the final output and metadata, not a bare string.


Next