File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1067,6 +1067,14 @@ async def _get_new_response(
1067
1067
model = cls ._get_model (agent , run_config )
1068
1068
model_settings = agent .model_settings .resolve (run_config .model_settings )
1069
1069
model_settings = RunImpl .maybe_reset_tool_choice (agent , tool_use_tracker , model_settings )
1070
+ # If the agent has hooks, we need to call them before and after the LLM call
1071
+ if agent .hooks :
1072
+ await agent .hooks .on_llm_start (
1073
+ context_wrapper ,
1074
+ agent ,
1075
+ system_prompt ,
1076
+ input
1077
+ )
1070
1078
1071
1079
new_response = await model .get_response (
1072
1080
system_instructions = system_prompt ,
@@ -1081,6 +1089,13 @@ async def _get_new_response(
1081
1089
previous_response_id = previous_response_id ,
1082
1090
prompt = prompt_config ,
1083
1091
)
1092
+ # If the agent has hooks, we need to call them after the LLM call
1093
+ if agent .hooks :
1094
+ await agent .hooks .on_llm_end (
1095
+ context_wrapper ,
1096
+ agent ,
1097
+ new_response
1098
+ )
1084
1099
1085
1100
context_wrapper .usage .add (new_response .usage )
1086
1101
You can’t perform that action at this time.
0 commit comments