Add agent middleware

Inspired by langchain’s middleware system, I know this would be extremely helpful.

For example, being able to edit the system prompt from a middleware is a useful feature which allows users to make plugin like system to modify agent behavior easily. Please consider adding this to v7.