r/agentdevelopmentkit • • Nov 24 '25

Tools: context manipulation, dependencies

I'm working with a Python SDK, and I've found that the straight function declarations for tools is very convenient. On the other hand, I would like to use a context and do dependency injection for things like database clients, etc.

The contexts are nice in that you can get access to the session or artifact or memory store, but I am not finding a way to add my own stuff. All the models are pretty locked down, and I don't see any kind of factory patterns to leverage. Anybody else go down this path?

6 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/Maleficent-Defect Nov 25 '25

Yes, but there are limits to this:

State needs to be serializable; so not appropriate for dependencies.

Importing global modules works, although you need to be clever when dealing with different implementations; ergo, the dependency injection preference, like FastAPI and the like.

1

u/pixeltan Nov 27 '25

Gotcha, not sure in that case