the_context_company.py
"""
The Context Company
===================
Demonstrates instrumenting an Agno agent with The Context Company.
Setup:
pip install "contextcompany[agno]>=1.9.1" agno openai yfinance
Set TCC_API_KEY and OPENAI_API_KEY before running this example.
See https://docs.thecontextcompany.com/frameworks/agno for the complete setup guide.
"""
import asyncio
from contextcompany.agno import instrument_agno
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
# Initialize instrumentation before importing Agno.
instrument_agno()
from agno.agent import Agent # noqa: E402
from agno.models.openai import OpenAIChat # noqa: E402
from agno.tools.yfinance import YFinanceTools # noqa: E402
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
name="Stock Price Agent",
model=OpenAIChat(id="gpt-5.2"),
tools=[YFinanceTools()],
instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
)
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
async def main() -> None:
await agent.aprint_response(
"What is the current price of Tesla? Then find the current price of NVIDIA.",
stream=True,
)
if __name__ == "__main__":
asyncio.run(main())
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U "contextcompany[agno]>=1.9.1" agno openai yfinance
3
Export your API keys
export TCC_API_KEY="your_tcc_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:TCC_API_KEY="your_tcc_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4
Run the example
Save the code above as
the_context_company.py, then run:python the_context_company.py