-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
Description
Description
Add ability to access and modify the chat history through RunHooks/AgentHooks while the agent is running. This would allow adding custom messages or modifying the conversation context during execution.
Use Case
- Injecting context-specific messages during agent execution
- Modifying conversation history in response to specific events
Proposed Dummy Implementation
- Add message history to RunContextWrapper
- Expose methods to add/modify messages through hooks:
class SomeHooks(AgentHooks[SomeContext]):
async def on_tool_end(
self,
context: RunContextWrapper[SomeContext],
agent: Any,
tool: Tool,
) -> None:
agent.add_message({"role": "user", "content": "some text"})Roman-Kornev, fl2o, robbalian, DoctorReid, latifboubyan and 4 more