Skip to main content
Dependencies is a way to inject variables into your Agent Context. dependencies is a dictionary that contains a set of functions (or static variables) that are resolved before the agent runs.
You can use dependencies to inject memories, dynamic few-shot examples, “retrieved” documents, etc.

Basic usage

You can reference the dependencies in your agent instructions or user message.
dependencies.py
You can set dependencies on Agent initialization, or pass it to the run() and arun() methods.

Using functions as dependencies

You can specify a callable function as a dependency. The dependency will be automatically resolved by the agent at runtime.
dependencies.py
Dependencies are automatically resolved when the agent is run.

Adding dependencies to context

Set add_dependencies_to_context=True to add the entire list of dependencies to the user message. This way you don’t have to manually add the dependencies to the instructions.
dependencies_instructions.py
This adds the entire dependencies dictionary to the user message between <additional context> tags. The new user message looks like this:
You can pass dependencies and add_dependencies_to_context to the run, arun, print_response and aprint_response methods.

Access dependencies in tool calls and hooks

You can access the dependencies in tool calls and hooks by using the RunContext object.
See the RunContext schema for more information.

Developer Resources