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(
10671067 model = cls ._get_model (agent , run_config )
10681068 model_settings = agent .model_settings .resolve (run_config .model_settings )
10691069 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+ )
10701078
10711079 new_response = await model .get_response (
10721080 system_instructions = system_prompt ,
@@ -1081,6 +1089,13 @@ async def _get_new_response(
10811089 previous_response_id = previous_response_id ,
10821090 prompt = prompt_config ,
10831091 )
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+ )
10841099
10851100 context_wrapper .usage .add (new_response .usage )
10861101
You can’t perform that action at this time.
0 commit comments