## [Tools with ChatContext Dependency Injection](https://docs.ag2.ai/0.10.4/docs/blog/2025/01/22/Tools-ChatContext-Dependency-Injection/)

### [Introduction](https://docs.ag2.ai/0.10.4/docs/blog/2025/01/22/Tools-ChatContext-Dependency-Injection/#introduction)

In this post, we’ll build upon the concepts introduced in our previous blog on [Tools with Dependency Injection](https://docs.ag2.ai/0.10.4/docs/blog/2025/01/07/Tools-Dependency-Injection). We’ll take a deeper look at how [`ChatContext`](https://docs.ag2.ai/0.10.4/docs/api-reference/autogen/tools/ChatContext#autogen.tools.ChatContext.chatcontext) can be used to manage the flow of conversations in a more structured and secure way.

By using [`ChatContext`](https://docs.ag2.ai/0.10.4/docs/api-reference/autogen/tools/ChatContext#autogen.tools.ChatContext.chatcontext), we can track and control the sequence of function calls during a conversation. This is particularly useful in situations where one task must be completed before another — for example, ensuring that a user logs in before they can check their account balance. This approach helps to prevent errors and enhances the security of the system.

**Benefits of Using [`ChatContext`](https://docs.ag2.ai/0.10.4/docs/api-reference/autogen/tools/ChatContext#autogen.tools.ChatContext.chatcontext)**: 
- **Flow Control**: Ensures tasks are performed in the correct order, reducing the chance of mistakes. 
- **Enhanced Security**: Prevents unauthorized actions, such as accessing sensitive data before authentication. 
- **Simplified Debugging**: Logs the conversation history, making it easier to trace and resolve issues.

Note

This blog builds on the concepts shared in the [notebook](https://docs.ag2.ai/0.10.4/docs/use-cases/notebooks/notebooks/tools_chat_context_dependency_injection).
