@@ -6,9 +6,6 @@ import { describe, expect, it } from "vitest";
66import type { OpenClawConfig } from "../config/config.js" ;
77import {
88 buildBootstrapContextFiles ,
9- DEFAULT_BOOTSTRAP_MAX_CHARS ,
10- DEFAULT_BOOTSTRAP_PROMPT_TRUNCATION_WARNING_MODE ,
11- DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS ,
129 ensureSessionHeader ,
1310 resolveBootstrapMaxChars ,
1411 resolveBootstrapPromptTruncationWarningMode ,
@@ -17,6 +14,10 @@ import {
1714import type { WorkspaceBootstrapFile } from "./workspace.js" ;
1815import { DEFAULT_AGENTS_FILENAME } from "./workspace.js" ;
1916
17+ const EXPECTED_DEFAULT_BOOTSTRAP_MAX_CHARS = 20_000 ;
18+ const EXPECTED_DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS = 60_000 ;
19+ const EXPECTED_DEFAULT_BOOTSTRAP_PROMPT_TRUNCATION_WARNING_MODE = "always" ;
20+
2021const makeFile = ( overrides : Partial < WorkspaceBootstrapFile > ) : WorkspaceBootstrapFile => ( {
2122 name : DEFAULT_AGENTS_FILENAME ,
2223 path : "/tmp/AGENTS.md" ,
@@ -124,7 +125,7 @@ describe("buildBootstrapContextFiles", () => {
124125 }
125126 } ) ;
126127 it ( "fits the rendered truncation marker inside the per-file budget" , ( ) => {
127- const maxChars = DEFAULT_BOOTSTRAP_MAX_CHARS ;
128+ const maxChars = EXPECTED_DEFAULT_BOOTSTRAP_MAX_CHARS ;
128129 const files = [
129130 makeFile ( {
130131 name : "HEARTBEAT.md" ,
@@ -190,7 +191,7 @@ describe("buildBootstrapContextFiles", () => {
190191 expect ( result ?. content ) . toContain ( "H" ) ;
191192 } ) ;
192193 it ( "keeps content under the default limit" , ( ) => {
193- const long = "a" . repeat ( DEFAULT_BOOTSTRAP_MAX_CHARS - 10 ) ;
194+ const long = "a" . repeat ( EXPECTED_DEFAULT_BOOTSTRAP_MAX_CHARS - 10 ) ;
194195 const files = [ makeFile ( { content : long } ) ] ;
195196 const [ result ] = buildBootstrapContextFiles ( files ) ;
196197 expect ( result ?. content ) . toBe ( long ) ;
@@ -203,7 +204,7 @@ describe("buildBootstrapContextFiles", () => {
203204 const files = createLargeBootstrapFiles ( ) ;
204205 const result = buildBootstrapContextFiles ( files ) ;
205206 const totalChars = result . reduce ( ( sum , entry ) => sum + entry . content . length , 0 ) ;
206- expect ( totalChars ) . toBeLessThanOrEqual ( DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS ) ;
207+ expect ( totalChars ) . toBeLessThanOrEqual ( EXPECTED_DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS ) ;
207208 expect ( result ) . toHaveLength ( 3 ) ;
208209 expect ( result [ 2 ] ?. content ) . toBe ( "c" . repeat ( 10_000 ) ) ;
209210 } ) ;
@@ -311,12 +312,12 @@ const BOOTSTRAP_LIMIT_RESOLVERS: BootstrapLimitResolverCase[] = [
311312 {
312313 name : "bootstrapMaxChars" ,
313314 resolve : resolveBootstrapMaxChars ,
314- defaultValue : DEFAULT_BOOTSTRAP_MAX_CHARS ,
315+ defaultValue : EXPECTED_DEFAULT_BOOTSTRAP_MAX_CHARS ,
315316 } ,
316317 {
317318 name : "bootstrapTotalMaxChars" ,
318319 resolve : resolveBootstrapTotalMaxChars ,
319- defaultValue : DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS ,
320+ defaultValue : EXPECTED_DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS ,
320321 } ,
321322] ;
322323
@@ -373,7 +374,7 @@ describe("bootstrap limit resolvers", () => {
373374describe ( "resolveBootstrapPromptTruncationWarningMode" , ( ) => {
374375 it ( "defaults to always" , ( ) => {
375376 expect ( resolveBootstrapPromptTruncationWarningMode ( ) ) . toBe ( "always" ) ;
376- expect ( DEFAULT_BOOTSTRAP_PROMPT_TRUNCATION_WARNING_MODE ) . toBe ( "always" ) ;
377+ expect ( EXPECTED_DEFAULT_BOOTSTRAP_PROMPT_TRUNCATION_WARNING_MODE ) . toBe ( "always" ) ;
377378 } ) ;
378379
379380 it ( "accepts explicit valid modes" , ( ) => {
@@ -399,6 +400,6 @@ describe("resolveBootstrapPromptTruncationWarningMode", () => {
399400 resolveBootstrapPromptTruncationWarningMode ( {
400401 agents : { defaults : { bootstrapPromptTruncationWarning : "invalid" } } ,
401402 } as unknown as OpenClawConfig ) ,
402- ) . toBe ( DEFAULT_BOOTSTRAP_PROMPT_TRUNCATION_WARNING_MODE ) ;
403+ ) . toBe ( EXPECTED_DEFAULT_BOOTSTRAP_PROMPT_TRUNCATION_WARNING_MODE ) ;
403404 } ) ;
404405} ) ;
0 commit comments