Agent with Tools

Quickstart

1from kern.agent import Agent
2from kern.models.openai import OpenAIResponses
3from kern.tools.duckduckgo import DuckDuckGoTools
4
5# ---------------------------------------------------------------------------
6# Create Agent
7# ---------------------------------------------------------------------------
8agent = Agent(
9 name="Tool-Enabled Agent",
10 model=OpenAIResponses(id="gpt-5.2"),
11 tools=[DuckDuckGoTools()],
12)
13
14# ---------------------------------------------------------------------------
15# Run Agent
16# ---------------------------------------------------------------------------
17if __name__ == "__main__":
18 agent.print_response(
19 "Find one recent AI safety headline and summarize it.", stream=True
20 )

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/01_quickstart
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python agent_with_tools.py