Python Quickstart
Get started with AgentForge in Python — install, configure, and run your first agent.
Install
pip install agentforgeFor development:
pip install agentforge[dev]Setup
export ANTHROPIC_API_KEY=your-key-hereCreate an Agent
import asyncio
from agentforge import define_agent, define_tool, create_llm
from pydantic import BaseModel, Field
# 1. Define a tool
class SearchInput(BaseModel):
query: str = Field(description="Search query")
class SearchOutput(BaseModel):
results: list[str]
search_tool = define_tool(
name="search",
description="Search the knowledge base",
input=SearchInput,
output=SearchOutput,
execute=lambda inp: SearchOutput(results=[f"Result for: {inp.query}"]),
)
# 2. Create an LLM
llm = create_llm(provider="anthropic", model="claude-sonnet-4-20250514")
# 3. Define the agent
agent = define_agent(
name="assistant",
description="A helpful assistant",
tools=[search_tool],
llm=llm,
system_prompt="You are a helpful assistant. Use search when needed.",
)
# 4. Run
async def main():
result = await agent.run(task="Find information about AI agents")
print(result.status)
print(result.output)
asyncio.run(main())Testing
from agentforge import create_mock_llm, create_test_harness
mock = create_mock_llm(responses=[
{"tool_calls": [{"name": "search", "input": {"query": "test"}}]},
{"text": "Found results."},
])
harness = create_test_harness(agent=agent_config, llm=mock)
result = await harness.run(task="Search for test")
assert result.status == "completed"
assert len(result.tool_calls("search")) == 1Next Steps
- API Parity — full mapping table
- Differences — Python-specific notes