File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,29 @@ class RunHooks(Generic[TContext]):
10
10
override the methods you need.
11
11
"""
12
12
13
+ #Two new hook methods added to the RunHooks class to handle LLM start and end events.
14
+ #These methods allow you to perform actions just before and after the LLM call for an agent.
15
+ #This is useful for logging, monitoring, or modifying the context before and after the LLM call.
16
+ async def on_llm_start (
17
+ self ,
18
+ context : RunContextWrapper [TContext ],
19
+ agent : Agent [TContext ],
20
+ system_prompt : str | None ,
21
+ input_items : List [TResponseInputItem ]
22
+ ) -> None :
23
+ """Called just before invoking the LLM for this agent."""
24
+ pass
25
+
26
+ async def on_llm_end (
27
+ self ,
28
+ context : RunContextWrapper [TContext ],
29
+ agent : Agent [TContext ],
30
+ response : ModelResponse
31
+ ) -> None :
32
+ """Called immediately after the LLM call returns for this agent."""
33
+ pass
34
+
35
+
13
36
async def on_agent_start (
14
37
self , context : RunContextWrapper [TContext ], agent : Agent [TContext ]
15
38
) -> None :
You can’t perform that action at this time.
0 commit comments