# Providing Location (/context/agent/location-instructions)



`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](/dependencies/overview). The HackerNews tool below retrieves top stories and user details; it does not perform geographic news search.

## Code [#code]

```python title="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 [#usage]

<Steps>
  <Step title="Create a Python file">
    Create `location_instructions.py` with the code above.
  </Step>

    <Step title="Set up your virtual environment">
      <CodeBlockTabs defaultValue="Mac">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="Mac">
            Mac
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="Windows">
            Windows
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="Mac">
          ```bash
          uv venv --python 3.12
          source .venv/bin/activate
          ```
        </CodeBlockTab>

        <CodeBlockTab value="Windows">
          ```bash
          uv venv --python 3.12
          .venv\Scripts\activate
          ```
        </CodeBlockTab>
      </CodeBlockTabs>
    </Step>

  <Step title="Install dependencies">
    ```bash
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeBlockTabs defaultValue="Mac/Linux">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac/Linux">
          Mac/Linux
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac/Linux">
        ```bash
        export OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```bash
        $Env:OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Step>

  <Step title="Run Agent">
    ```bash
    python location_instructions.py
    ```
  </Step>
</Steps>
