Suppose I want this behavior when using Software A...
# proj-sdk
q
Suppose I want this behavior when using Software Agent SDK: Take some action after every file edit like running the tests. We can of course substitute the entire FileEditorTool, but it's pretty big and not easy to wrap. This feels like a job for something like Claude Code hooks. The closest I found was our callbacks, which didn't quite do the trick because they don't feed information back into the outcome of the tool call. What I ended up doing was using a callback to pause the conversation, then once the step finished run the actions, and add messages to the conversation based on the outcome. Any advice here or thoughts about a hook-like feature?
c
So glad you brought up the idea of hooks. The thought occurred to me when I was working on alternative visualizations that it would be cool to be able subscribe to events at a pretty granular level. For example, I wanted a hook that would fire before an LLM call was made but all I could find was an event after we got the response. If you could have hooks that could even mutate state, one example might be manipulate a prompt before jinga eval, after jinga eval but before sent to llm, etc. you could do some fancy stuff. I didn't get as far as even finding the event callbacks you mentioned, so perhaps there is more in the SDK than I realize around this.
q
Yeah what would you say is the difference between a callback and a visualizer?
c
I do not know the SDK code base well. I assume that visualizer is intended to produce output for the user, not be general extension mechanism. Whether it is appropriately situated to become a more general mechanism I couldn't say.
q
Yeah it seems like if I add a callback that displays output, I've made a visualizer
(just conceptually, haven't looked hard at the logic)
c
If you are trying to create output--definitely look at custom visualizers. I have a branch that has several more interesting examples than the one on main. One sec. I'll find it.
w
There was another "hook" like use case brought up elsewhere, I'll try and find it
IMO we should definitely add this
c
I think maybe the way we could go about it is to make a minimal code design or implementation, to look at. 🤔 We have some behaviors we do in code today that are "Claude Code hooks material", like the keyword matching for skills (on user prompt, do a thing), or the startup script. In other words, maybe they could be expressed as hooks, and at least in the first case, it would give a little more space for user customization.
q
Cool it sounds like there's enough interest to put together a more detailed issue or draft PR, I can start that or lmk if someones interested in pairing thanks all!
c
Musssst... resist... temptation... I'd love to, I just can't promise much right now. I literally just told my OH secretary this evening to help me with my list of on-going conversations, to finalize work asap, in the hope it will warn me if it sees me start something new. 😂 It's a GPT-5 raw, who is not a nice guy, and that's good! 🫣 (yes, I'm this bad, I use an agent to keep me on track)
Maybe we can figure it out easier next week though, thank you for picking this up!
🎉 1
Example seen on Claude Code (cloud): when the agent finishes, or thinks it did, a "stop" hooks is activated, to make sure it really did
This is one way it could look like: https://github.com/OpenHands/OpenHands/issues/11943
q
Thanks, I've also asked a few people I consider very adept at Claude Hooks what they would want in the feature and will share what I learned. Balancing that against brittleness/maintainability as you've mentioned. Like people will always want the most flexibility in theory but full access to event details is probably asking for trouble.
c
nod I hear you, but to be honest, I would rather take the brittleness comment back in some measure: I had in mind a pretty extreme case, imagine we'd add points in the middle of the runtime execution or initialization (not before or after, during) - such thing would be terrible, and it would prove the fragility point. But we only need to start small, with several extension points, the most obvious ones; and that's really it, see where it takes us. Later, benefitting from community feedback as well, we can adjust, remove/add. We also have in agent-sdk a deprecation mechanism now, so we can easily and reasonably even remove compatibility, while downstream client apps are notified and given a few releases to adapt. So, it seems to me, we can experiment fairly safely 😊
q
Far as I can see, the main desires: Hook on Before/After tool call, status change Must be able to: run something async, or run sync and fail (potentially blocking the tool call), or add a message to the conversation
I don't think about it as much but I guess Claude also can hook on user message content
nod 1