Skip to content

Conversation

Abbas-Asad
Copy link
Contributor

Summary

This PR defines correct lifecycle order of hooks for both RunHooksBase and AgentHooksBase, aligning with the logical execution flow of an agent run.

Changes Made

I have simply reordered the hooks to reflect their chronological execution sequence during an agent run.

RunHooksBase

on_agent_start
on_llm_start
on_llm_end
on_tool_start
on_tool_end
on_handoff
on_agent_end

AgentHooksBase

on_start
on_llm_start
on_llm_end
on_tool_start
on_tool_end
on_handoff
on_end

Enhancement

  • Establishes a clear and logical sequence for hook execution.
  • Improves developer understanding by reflecting the actual lifecycle:
    • Start → LLM Call → Tool Call → Handoff (if any) → End

This ordering provides consistency and clarity to understand the correct agent execution flow.

## Summary
This PR defines correct lifecycle order of hooks for both `RunHooksBase` and `AgentHooksBase`, aligning with the logical execution flow of an agent run.

## Changes Made
I have simply **reordered the hooks** to reflect their chronological execution sequence during an agent run.

### RunHooksBase 
```
on_agent_start
on_llm_start
on_llm_end
on_tool_start
on_tool_end
on_handoff
on_agent_end
```



### AgentHooksBase 
```
on_start
on_llm_start
on_llm_end
on_tool_start
on_tool_end
on_handoff
on_end
```



## Enhancement
- Establishes a clear and **logical sequence** for hook execution.
- Improves developer understanding by reflecting the **actual lifecycle**:
  - **Start → LLM Call → Tool Call  → Handoff (if any) → End**

This ordering provides consistency and clarity to understand the correct agent execution flow.
@seratch
Copy link
Member

seratch commented Sep 8, 2025

Thanks for the suggestion. To me, either is fine but if you resolve the CI errors, we may merge this.

@seratch seratch marked this pull request as draft September 8, 2025 23:06
Resolved all CI linting errors in lifecycle.py to comply with project style guidelines and unblock the failing lint check in CI.
@Abbas-Asad Abbas-Asad closed this Sep 9, 2025
@Abbas-Asad Abbas-Asad deleted the patch-12 branch September 9, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants