@@ -19,6 +19,7 @@ import (
1919
2020 "trpc.group/trpc-go/trpc-agent-go/agent"
2121 "trpc.group/trpc-go/trpc-agent-go/event"
22+ "trpc.group/trpc-go/trpc-agent-go/internal/flow/processor"
2223 "trpc.group/trpc-go/trpc-agent-go/knowledge"
2324 "trpc.group/trpc-go/trpc-agent-go/knowledge/document"
2425 "trpc.group/trpc-go/trpc-agent-go/model"
@@ -45,6 +46,90 @@ func TestLLMAgent_SubAgents(t *testing.T) {
4546 }
4647}
4748
49+ // Test that buildRequestProcessors wires AddSessionSummary into
50+ // ContentRequestProcessor correctly.
51+ func TestBuildRequestProcessors_AddSessionSummaryWiring (t * testing.T ) {
52+ // true case - test that WithAddSessionSummary(true) is properly wired.
53+ optsTrue := & Options {}
54+ WithAddSessionSummary (true )(optsTrue )
55+ procs := buildRequestProcessors ("test-agent" , optsTrue )
56+ var crp * processor.ContentRequestProcessor
57+ for _ , p := range procs {
58+ if v , ok := p .(* processor.ContentRequestProcessor ); ok {
59+ crp = v
60+ }
61+ }
62+ require .NotNil (t , crp )
63+ require .True (t , crp .AddSessionSummary )
64+
65+ // false case - test that WithAddSessionSummary(false) is properly wired.
66+ optsFalse := & Options {}
67+ WithAddSessionSummary (false )(optsFalse )
68+ procs = buildRequestProcessors ("test-agent" , optsFalse )
69+ crp = nil
70+ for _ , p := range procs {
71+ if v , ok := p .(* processor.ContentRequestProcessor ); ok {
72+ crp = v
73+ }
74+ }
75+ require .NotNil (t , crp )
76+ require .False (t , crp .AddSessionSummary )
77+ }
78+
79+ // Test that buildRequestProcessors wires MaxHistoryRuns into
80+ // ContentRequestProcessor correctly.
81+ func TestBuildRequestProcessors_MaxHistoryRunsWiring (t * testing.T ) {
82+ // Test with MaxHistoryRuns set - test that WithMaxHistoryRuns(10) is properly wired.
83+ optsWithMax := & Options {}
84+ WithMaxHistoryRuns (10 )(optsWithMax )
85+ procs := buildRequestProcessors ("test-agent" , optsWithMax )
86+ var crp * processor.ContentRequestProcessor
87+ for _ , p := range procs {
88+ if v , ok := p .(* processor.ContentRequestProcessor ); ok {
89+ crp = v
90+ }
91+ }
92+ require .NotNil (t , crp )
93+ require .Equal (t , 10 , crp .MaxHistoryRuns )
94+
95+ // Test with default value (0) - test that WithMaxHistoryRuns(0) is properly wired.
96+ optsDefault := & Options {}
97+ WithMaxHistoryRuns (0 )(optsDefault )
98+ procs = buildRequestProcessors ("test-agent" , optsDefault )
99+ crp = nil
100+ for _ , p := range procs {
101+ if v , ok := p .(* processor.ContentRequestProcessor ); ok {
102+ crp = v
103+ }
104+ }
105+ require .NotNil (t , crp )
106+ require .Equal (t , 0 , crp .MaxHistoryRuns )
107+ }
108+
109+ // Test that WithAddSessionSummary option sets the AddSessionSummary field correctly.
110+ func TestWithAddSessionSummary_Option (t * testing.T ) {
111+ opts := & Options {}
112+ WithAddSessionSummary (true )(opts )
113+ require .True (t , opts .AddSessionSummary )
114+
115+ // Test with false value
116+ opts = & Options {}
117+ WithAddSessionSummary (false )(opts )
118+ require .False (t , opts .AddSessionSummary )
119+ }
120+
121+ // Test that WithMaxHistoryRuns option sets the MaxHistoryRuns field correctly.
122+ func TestWithMaxHistoryRuns_Option (t * testing.T ) {
123+ opts := & Options {}
124+ WithMaxHistoryRuns (5 )(opts )
125+ require .Equal (t , 5 , opts .MaxHistoryRuns )
126+
127+ // Test with zero value
128+ opts = & Options {}
129+ WithMaxHistoryRuns (0 )(opts )
130+ require .Equal (t , 0 , opts .MaxHistoryRuns )
131+ }
132+
48133func TestLLMAgent_Run_BeforeAgentShort (t * testing.T ) {
49134 // BeforeAgentCallback returns a custom response, should short-circuit.
50135 agentCallbacks := agent .NewCallbacks ()
0 commit comments