feature: Add the callbacks ready to be used by the agent#94
feature: Add the callbacks ready to be used by the agent#94edenreich merged 5 commits intoinference-gateway:mainfrom
Conversation
|
@edenreich any chance to get this in before more conflicts come up? And then I can work on implementing the logic into the agents |
|
@Joshswooft I think it looks good so far, do you think we can add an example? to demonstrate how does the server code looks like? when the a2a server for example process a request. Overall looks great, let me know. Otherwise I'm also happy with just merging it as is and I can add it later. |
|
@Joshswooft BTW, I can see that we have the CallbackExecutor definition but I can't find where we apply those? for example I couldn't find a reference for the usage of BeforeModelCallback in the default background or streaming task handlers. Maybe we should use those also in the default task handlers? I think the RunWithStream should have those callbacks invoked / executed if they are defined? |
"The callbacks are currently not in use by the agent, " - That will explain why you can't see them. It's going to be a pretty meaty PR if I add this all at once and chances are it's going to fall behind again as I'm away very soon for a few weeks. Adding the prep work in now lets others contribute or delegate to Claude etc. |
I'll add the example once it's hooked up to the agent. It can be a seperate PR |
|
Sounds good! |
## [0.14.0](v0.13.1...v0.14.0) (2025-10-11) ### ✨ Features * Add the callbacks ready to be used by the agent ([#94](#94)) ([84632f3](84632f3)) * **types:** Refactor Part deserialization to use concrete types ([#104](#104)) ([22d192e](22d192e)), closes [#102](#102) ### ♻️ Improvements * Consolidate the logic of the agent and remove redundancy ([#93](#93)) ([54e5e71](54e5e71)) * **docker-compose:** Remove port mappings for server service to avoid confusion ([3df7b08](3df7b08)) * **server:** Remove handler duplication between A2AServerImpl and DefaultA2AProtocolHandler ([#101](#101)) ([75b9c20](75b9c20)) ### 🐛 Bug Fixes * Improve validation logic for task handler configuration ([#98](#98)) ([34d6354](34d6354)) ### 👷 CI * Add Prettier setup and formatting steps for Go and markdown files ([#105](#105)) ([f2a1994](f2a1994)) ### 📚 Documentation * **examples:** Add input-required flow examples ([#96](#96)) ([17764f3](17764f3)) ### 🔧 Miscellaneous * **deps:** Update claude-code to 2.0.8 and install gh cli version 2.81.0 in flox environment ([4d6e41a](4d6e41a))
|
🎉 This PR is included in version 0.14.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This commit integrates the callback infrastructure (from PR #94) into the actual agent execution flow. Callbacks are now invoked at key execution points: - BeforeAgent/AfterAgent: Hook into overall agent execution lifecycle - BeforeModel/AfterModel: Hook into LLM calls for caching, guardrails, etc. - BeforeTool/AfterTool: Hook into tool execution for authorization, logging, etc. Changes include: - Add WithCallbacks() method to AgentBuilder for fluent callback configuration - Integrate BeforeAgent callback at start of RunWithStream (can skip execution) - Integrate AfterAgent callback at completion (can modify final output) - Integrate BeforeModel callback before LLM calls (can skip and return cached response) - Integrate AfterModel callback after LLM responses (can modify response) - Integrate BeforeTool/AfterTool callbacks around tool execution - Add AgentName field to AgentConfig for callback context - Add helper methods createCallbackContext and createToolContext - Create callbacks example with comprehensive documentation - Regenerate AgentBuilder mock Closes #71 Co-authored-by: Eden Reich <edenreich@users.noreply.github.com>
…118) * feat(callbacks): Integrate callback hooks into agent execution flow This commit integrates the callback infrastructure (from PR #94) into the actual agent execution flow. Callbacks are now invoked at key execution points: - BeforeAgent/AfterAgent: Hook into overall agent execution lifecycle - BeforeModel/AfterModel: Hook into LLM calls for caching, guardrails, etc. - BeforeTool/AfterTool: Hook into tool execution for authorization, logging, etc. Changes include: - Add WithCallbacks() method to AgentBuilder for fluent callback configuration - Integrate BeforeAgent callback at start of RunWithStream (can skip execution) - Integrate AfterAgent callback at completion (can modify final output) - Integrate BeforeModel callback before LLM calls (can skip and return cached response) - Integrate AfterModel callback after LLM responses (can modify response) - Integrate BeforeTool/AfterTool callbacks around tool execution - Add AgentName field to AgentConfig for callback context - Add helper methods createCallbackContext and createToolContext - Create callbacks example with comprehensive documentation - Regenerate AgentBuilder mock Closes #71 Co-authored-by: Eden Reich <edenreich@users.noreply.github.com> * fix(callbacks): Fix formatting and remove self-explanatory comments - Fix markdown table alignment in README.md (prettier formatting) - Add blank lines before code blocks/lists per prettier style - Fix struct field alignment in agent_builder.go (gofmt) - Remove redundant inline comments from agent_streamable.go - Remove section comments from callbacks example main.go Co-authored-by: Eden Reich <edenreich@users.noreply.github.com> * fix(callbacks): Add blank lines before lists per prettier formatting 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-authored-by: Eden Reich <edenreich@users.noreply.github.com> * refactor(callbacks): Address review comments - Remove repetitive "Use Cases" section from callbacks README - Add GetTool method to ToolBox interface for cleaner tool access - Simplify agent_streamable.go to use new GetTool method - Regenerate mocks for updated interface 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Eden Reich <edenreich@users.noreply.github.com> * docs: Document callback system and update examples * docs: Simplify the example to support docker-compose Signed-off-by: Eden Reich <eden.reich@gmail.com> --------- Signed-off-by: Eden Reich <eden.reich@gmail.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Eden Reich <edenreich@users.noreply.github.com>
Adds callbacks by following the ADK docs: https://google.github.io/adk-docs/callbacks/
The callbacks are currently not in use by the agent, I will wait until the refactoring of the
RunWithStreammethod is complete before adding. Consider this the initial plumbing done