Vote: Which Hook System API Do You Prefer? #33
Replies: 2 comments 1 reply
-
|
Hook 1 and 2 feels the most natural to me. In the order of development, TypeDict can be prioritised first (for best practice and maximal adoption), followed by Even Wrappers. We can analyse our users following that to determine if we choose sub class pattern (in case the users are teams building for complex workflows/ enterprise systems), or startups/solo devs preferring intuitiveness and flexibility. For sub class pattern, agent subclass or hook classes both look equally good. I would vote for hook classes as agent subclass structure might violate DRY? |
Beta Was this translation helpful? Give feedback.
-
|
Waiting for developer to complete implementation on PR https://github.com/CrossTerra/monorepo/pull/2008. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🗳️ Vote: Which Hook System API Do You Prefer?
We're adding hooks to ConnectOnion and need your input on the API design!
What are hooks?
Hooks let you observe and modify agent behavior at key lifecycle points:
The Five Options
Vote by reacting to this discussion:
Option 1: TypedDict Hooks (
hooks=dict(...))Why you might like it:
hooks: HookEvents = dict(...)React with 👍 if this is your favorite
Option 2: Event Wrappers (
hooks=[...])Why you might like it:
before_llm,after_llmReact with ❤️ if this is your favorite
Option 3: Decorator Pattern (
@hook('event_name'))Why you might like it:
@xray,@replay)React with 🚀 if this is your favorite
Option 4: Event Emitter (
agent.on(...))Why you might like it:
React with 👀 if this is your favorite
Option 5: Sub-class Pattern (OOP style)
Alternative: Agent Subclass
Why you might like it:
pip install connectonion-cost-tracker)React with 🎯 if this is your favorite
Common Use Cases
Cost Tracking (Simple)
Smart Caching (With State)
Custom Logging (With Configuration)
Hook Data Reference
Each hook receives a
datadictionary with relevant context:before_llm(data){'messages': [...], 'tools': [...], 'iteration': 1}after_llm(data){'response': LLMResponse, 'usage': {'total_tokens': 150}, 'timing': 234.5}before_tool(data)/after_tool(data){'tool_name': 'search', 'tool_args': {...}, 'result': '...', 'status': 'success'}🗳️ How to Vote
React to this discussion:
Or comment with:
📚 More Information
Detailed examples: docs/hook-system-options.md
Design journey: docs/design-decisions/010-hook-system-design.md
Technical discussion: Issue #31
Your vote shapes the API! 🙏
We're especially interested in:
Beta Was this translation helpful? Give feedback.
All reactions