@@ -263,10 +263,12 @@ func TestDefaultBuilderBuildPlacesRulesBeforeMemo(t *testing.T) {
263263 }
264264
265265 builder := & DefaultBuilder {
266- promptSources : []promptSectionSource {
266+ stablePromptSources : []promptSectionSource {
267267 corePromptSource {},
268268 newRulesPromptSource (rules .NewLoader (baseDir )),
269269 stubPromptSectionSource {sections : []promptSection {{Title : "Memo" , Content : "remember this" }}},
270+ },
271+ dynamicPromptSources : []promptSectionSource {
270272 & systemStateSource {},
271273 },
272274 }
@@ -312,7 +314,7 @@ func TestDefaultBuilderBuildUsesSpanTrimPolicyWhenTrimPolicyIsUnset(t *testing.T
312314 }
313315
314316 builder := & DefaultBuilder {
315- promptSources : []promptSectionSource {
317+ stablePromptSources : []promptSectionSource {
316318 stubPromptSectionSource {sections : []promptSection {{Title : "Stub" , Content : "body" }}},
317319 },
318320 }
@@ -337,7 +339,7 @@ func TestDefaultBuilderBuildReturnsPromptSourceError(t *testing.T) {
337339 t .Parallel ()
338340
339341 builder := & DefaultBuilder {
340- promptSources : []promptSectionSource {
342+ stablePromptSources : []promptSectionSource {
341343 stubPromptSectionSource {err : fmt .Errorf ("source failed" )},
342344 },
343345 }
@@ -643,10 +645,12 @@ func TestNewConfiguredBuilder(t *testing.T) {
643645 }
644646 })
645647
646- t .Run ("nil section sources are skipped" , func (t * testing.T ) {
647- builder := NewConfiguredBuilder (nil , stubPromptSectionSource {
648+ t .Run ("multiple extra section sources are appended" , func (t * testing.T ) {
649+ builder := NewConfiguredBuilder (stubPromptSectionSource {
650+ sections : []promptSection {{Title : "First" , Content : "first body" }},
651+ }, stubPromptSectionSource {
648652 sections : []promptSection {{Title : "Extra" , Content : "extra body" }},
649- }, nil )
653+ })
650654 input := BuildInput {
651655 Messages : []providertypes.Message {{Role : "user" , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("hello" )}}},
652656 Metadata : testMetadata (t .TempDir ()),
@@ -658,6 +662,9 @@ func TestNewConfiguredBuilder(t *testing.T) {
658662 if ! strings .Contains (result .SystemPrompt , "## Extra" ) {
659663 t .Errorf ("expected Extra section in system prompt" )
660664 }
665+ if ! strings .Contains (result .SystemPrompt , "## First" ) {
666+ t .Errorf ("expected First section in system prompt" )
667+ }
661668 })
662669}
663670
@@ -895,23 +902,30 @@ func TestDefaultBuilderBuildMemoIsStable(t *testing.T) {
895902 }
896903}
897904
898- func TestDefaultBuilderBuildStableAndDynamicPreservesBackwardCompat (t * testing.T ) {
905+ func TestDefaultBuilderBuildStableAndDynamicFields (t * testing.T ) {
899906 t .Parallel ()
900907
901908 builder := & DefaultBuilder {
902- promptSources : []promptSectionSource {
903- stubPromptSectionSource {sections : []promptSection {{Title : "Old " , Content : "old style" }}},
909+ stablePromptSources : []promptSectionSource {
910+ stubPromptSectionSource {sections : []promptSection {{Title : "Stable " , Content : "stable style" }}},
904911 },
912+ dynamicPromptSources : []promptSectionSource {
913+ stubPromptSectionSource {sections : []promptSection {{Title : "Dynamic" , Content : "dynamic style" }}},
914+ },
915+ trimPolicy : spanMessageTrimPolicy {},
905916 }
906917
907918 result , err := builder .Build (stdcontext .Background (), BuildInput {})
908919 if err != nil {
909920 t .Fatalf ("Build() error = %v" , err )
910921 }
911- if ! strings .Contains (result .SystemPrompt , "old style" ) {
912- t .Fatalf ("expected old style content in system prompt, got %q" , result .SystemPrompt )
922+ if ! strings .Contains (result .SystemPrompt , "stable style" ) || ! strings .Contains (result .SystemPrompt , "dynamic style" ) {
923+ t .Fatalf ("expected stable and dynamic content in system prompt, got %q" , result .SystemPrompt )
924+ }
925+ if ! strings .Contains (result .StableSystemPrompt , "stable style" ) {
926+ t .Fatalf ("expected stable content in StableSystemPrompt, got %q" , result .StableSystemPrompt )
913927 }
914- if ! strings .Contains (result .StableSystemPrompt , "old style" ) {
915- t .Fatalf ("expected old style content in StableSystemPrompt , got %q" , result .StableSystemPrompt )
928+ if ! strings .Contains (result .DynamicSystemPrompt , "dynamic style" ) {
929+ t .Fatalf ("expected dynamic content in DynamicSystemPrompt , got %q" , result .DynamicSystemPrompt )
916930 }
917931}
0 commit comments