Skip to main content
The source omits the keyword-only run_context parameter accepted by ContextProvider.query() and ContextProvider.aquery(). The generated query_faq tool calls aquery(..., run_context=...), so it returns a serialized TypeError instead of the FAQ answer. Update both signatures before running.
custom_provider.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Accept the run context

Add from agno.run import RunContext. Change query to def query(self, question: str, *, run_context: RunContext | None = None) -> Answer: and aquery to async def aquery(self, question: str, *, run_context: RunContext | None = None) -> Answer:. In aquery, return self.query(question, run_context=run_context).
5

Run the example

Save the code above as custom_provider.py, then run:
Full source: cookbook/12_context/10_custom_provider.py