@@ -55,14 +55,21 @@ def _validate_limits(
5555 parser .error (f"--prefix-cache-entries must be between 0 and { _MAX_INT32 } " )
5656 if not 0 <= args .prefix_checkpoint_interval <= _MAX_INT32 :
5757 parser .error (f"--prefix-checkpoint-interval must be between 0 and { _MAX_INT32 } " )
58- if (args .prefix_checkpoint_interval or prefix_capture_prompt_end ) and not args .prefix_cache_entries :
59- parser .error ("--prefix-checkpoint-interval requires --prefix-cache-entries > 0" )
58+ if (
59+ args .prefix_checkpoint_interval or prefix_capture_prompt_end
60+ ) and not args .prefix_cache_entries :
61+ flag = (
62+ "--prefix-capture-prompt-end"
63+ if prefix_capture_prompt_end
64+ else "--prefix-checkpoint-interval"
65+ )
66+ parser .error (f"{ flag } requires --prefix-cache-entries > 0" )
6067 if not 0 <= prefix_capture_slots <= _MAX_INT32 :
6168 parser .error (f"--prefix-capture-slots must be between 0 and { _MAX_INT32 } " )
6269 # Mirrors ServingRuntimeConfig::resolved_prefix_captures for row validation.
6370 if prefix_capture_slots == 0 :
6471 prefix_capture_slots = min (args .max_sessions , args .max_inflight_requests )
65- if args .prefix_checkpoint_interval or prefix_capture_prompt_end :
72+ if args .prefix_checkpoint_interval :
6673 prefix_capture_slots = min (prefix_capture_slots , 2 )
6774 if not args .prefix_cache_entries :
6875 prefix_capture_slots = 0
@@ -108,8 +115,9 @@ def _parse_args(argv=None):
108115 parser .add_argument ("--max-inflight-requests" , type = int , default = 64 )
109116 parser .add_argument ("--prefix-cache-entries" , type = int , default = 0 )
110117 parser .add_argument (
111- "--prefix-capture-prompt-end" , action = "store_true" ,
112- help = "Retain each request's prompt end in the bounded prefix cache" ,
118+ "--prefix-capture-prompt-end" ,
119+ action = "store_true" ,
120+ help = "Best-effort retention of each request's prompt end in the bounded prefix cache" ,
113121 )
114122 parser .add_argument (
115123 "--prefix-capture-slots" ,
@@ -121,7 +129,7 @@ def _parse_args(argv=None):
121129 "--prefix-checkpoint-interval" ,
122130 type = int ,
123131 default = 0 ,
124- help = "Checkpoint interval in tokens; 0: initial prompt only. Uses global LRU ." ,
132+ help = "Periodic checkpoint interval in tokens; 0 disables periodic capture ." ,
125133 )
126134 parser .add_argument (
127135 "--api-dialect" , choices = ("openai" , "openrouter" ), default = "openai"
@@ -136,7 +144,12 @@ def _parse_args(argv=None):
136144 parser .add_argument ("--port" , type = int , default = 8000 )
137145 args = parser .parse_args (argv )
138146
139- _validate_limits (parser , args , prefix_capture_slots = args .prefix_capture_slots )
147+ _validate_limits (
148+ parser ,
149+ args ,
150+ prefix_capture_slots = args .prefix_capture_slots ,
151+ prefix_capture_prompt_end = args .prefix_capture_prompt_end ,
152+ )
140153
141154 args .worker_bin = os .path .expanduser (args .worker_bin )
142155 if shutil .which (args .worker_bin ) is None :
@@ -212,7 +225,11 @@ async def serving_factory():
212225 if args .prefix_checkpoint_interval
213226 else []
214227 )
215- + (["--prefix_capture_prompt_end=true" ] if args .prefix_capture_prompt_end else []),
228+ + (
229+ ["--prefix_capture_prompt_end=true" ]
230+ if args .prefix_capture_prompt_end
231+ else []
232+ ),
216233 stderr = stderr ,
217234 )
218235 runtime = None
0 commit comments