Providing Location

Add the running process's approximate public-IP location to an agent's context.

add_location_to_context=True looks up the public IP of the process running Agno and adds its approximate location. On a deployed service, this is the server or network gateway location, not the remote user's city. A failed lookup adds no location.

For user-specific location, pass a location supplied by your application explicitly, for example through dependencies. The HackerNews tool below retrieves top stories and user details; it does not perform geographic news search.

Code

location_instructions.py
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    add_location_to_context=True,
    tools=[HackerNewsTools(cache_results=True)],
)
agent.print_response("What approximate location is available for this running process?", stream=True)
agent.print_response("Summarize the top Hacker News stories.", stream=True)

Usage

Create a Python file

Create location_instructions.py with the code above.

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run Agent

python location_instructions.py