@@ -1425,11 +1425,10 @@ func TestPostProcessSummary(t *testing.T) {
14251425func TestEventHelpers (t * testing.T ) {
14261426 ctx := context .Background ()
14271427
1428- t .Run ("emitEvent returns wrapped error outside execution context" , func (t * testing.T ) {
1428+ t .Run ("emitEvent is no-op outside execution context" , func (t * testing.T ) {
14291429 mw := & TypedMiddleware [* schema.Message ]{cfg : & Config {}}
14301430 err := mw .emitEvent (ctx , & CustomizedAction {Type : ActionTypeBeforeSummarize })
1431- assert .Error (t , err )
1432- assert .Contains (t , err .Error (), "failed to send internal event" )
1431+ assert .NoError (t , err )
14331432 })
14341433
14351434 t .Run ("emitGenerateSummaryEvent is skipped when internal events are disabled" , func (t * testing.T ) {
@@ -1438,11 +1437,10 @@ func TestEventHelpers(t *testing.T) {
14381437 assert .NoError (t , err )
14391438 })
14401439
1441- t .Run ("emitGenerateSummaryEvent returns wrapped error when enabled outside execution context" , func (t * testing.T ) {
1440+ t .Run ("emitGenerateSummaryEvent is no-op when enabled outside execution context" , func (t * testing.T ) {
14421441 mw := & TypedMiddleware [* schema.Message ]{cfg : & Config {EmitInternalEvents : true }}
14431442 err := mw .emitGenerateSummaryEvent (ctx , 1 , GenerateSummaryPhasePrimary , schema .AssistantMessage ("ok" , nil ), nil )
1444- assert .Error (t , err )
1445- assert .Contains (t , err .Error (), "failed to send internal event" )
1443+ assert .NoError (t , err )
14461444 })
14471445}
14481446
@@ -1937,7 +1935,7 @@ func TestSummarizationGeneric(t *testing.T) {
19371935 })
19381936}
19391937
1940- func TestEmitInternalEvents_AgenticMessage_RequiresExecContext (t * testing.T ) {
1938+ func TestEmitInternalEvents_AgenticMessage_NoopOutsideExecContext (t * testing.T ) {
19411939 ctx := context .Background ()
19421940
19431941 longContent := strings .Repeat ("x" , 800000 )
@@ -1967,9 +1965,12 @@ func TestEmitInternalEvents_AgenticMessage_RequiresExecContext(t *testing.T) {
19671965 require .NoError (t , err )
19681966
19691967 state := & adk.TypedChatModelAgentState [* schema.AgenticMessage ]{Messages : msgs }
1970- _ , _ , err = mw .BeforeModelRewriteState (ctx , state , nil )
1971- assert .Error (t , err , "should error without exec context when EmitInternalEvents is true" )
1972- assert .Contains (t , err .Error (), "send internal event" )
1968+ _ , gotState , err := mw .BeforeModelRewriteState (ctx , state , nil )
1969+ require .NoError (t , err )
1970+ require .NotNil (t , gotState )
1971+ require .Len (t , gotState .Messages , 2 )
1972+ assert .Equal (t , schema .AgenticRoleTypeSystem , gotState .Messages [0 ].Role )
1973+ assert .Equal (t , schema .AgenticRoleTypeUser , gotState .Messages [1 ].Role )
19731974}
19741975
19751976func testSummarizationHelpers [M adk.MessageType ](t * testing.T ) {
0 commit comments