Skip to content

Conversation

@hi-pender
Copy link
Contributor

Summary

Fix the return value in modelPostHandle function to return the last message from st.Messages instead of the original input.

Problem

The modelPostHandle was returning the original input message, but the afterChatModel callbacks may modify s.Messages. This caused the subsequent nodes to receive the unmodified input instead of the processed message.

Solution

Changed the return statement from:

return input, nil

to:

return st.Messages[len(st.Messages)-1], nil

This ensures that any modifications made by afterChatModel callbacks are properly propagated to subsequent nodes in the graph.

The modelPostHandle should return the last message from st.Messages
instead of the original input, because afterChatModel callbacks may
modify the messages. This ensures the correct message is passed to
subsequent nodes.
@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.25%. Comparing base (47ddc7e) to head (641a75d).

Files with missing lines Patch % Lines
adk/chatmodel.go 33.33% 1 Missing and 1 partial ⚠️
adk/react.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #651      +/-   ##
==========================================
+ Coverage   80.23%   80.25%   +0.02%     
==========================================
  Files         124      124              
  Lines       11829    11833       +4     
==========================================
+ Hits         9491     9497       +6     
+ Misses       1612     1608       -4     
- Partials      726      728       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add length check before accessing the last message. Return error
when messages slice is empty after afterChatModel callbacks.
@hi-pender hi-pender force-pushed the feat/modify_tool_call branch from bc54553 to 2dba7fc Compare December 29, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants