@@ -48,8 +48,6 @@ const GENERATION_KEYS = new Set(Object.keys(GenerationOptions.fields))
4848const OUTPUT_TOKEN_FALLBACK = 32_000
4949// No reply needs more, however much the model allows.
5050const OUTPUT_TOKEN_MAX = 256_000
51- // A summary never needs more, and a request asking for more cannot be shrunk to fit a window the catalog overstates.
52- const SUMMARY_OUTPUT_MAX = 32_000
5351// Prompt text is estimated at about 4 characters per token, which can run low on dense text such as code.
5452const ESTIMATE_ERROR = 0.15
5553// Never ask for less; only reachable with automatic compaction off, since it keeps the window from filling this far.
@@ -84,13 +82,8 @@ export interface Input {
8482}
8583
8684/** The default output limit: the catalog limit, fitted to the room the prompt leaves in the context window. */
87- export const outputLimit = (
88- limit : Model . Info [ "limit" ] ,
89- kind : "primary" | "compaction" ,
90- inputTokens ?: Input [ "inputTokens" ] ,
91- ) => {
92- const model = Math . min ( limit . output > 0 ? limit . output : OUTPUT_TOKEN_FALLBACK , OUTPUT_TOKEN_MAX )
93- const requested = kind === "compaction" ? Math . min ( model , SUMMARY_OUTPUT_MAX ) : model
85+ export const outputLimit = ( limit : Model . Info [ "limit" ] , inputTokens ?: Input [ "inputTokens" ] ) => {
86+ const requested = Math . min ( limit . output > 0 ? limit . output : OUTPUT_TOKEN_FALLBACK , OUTPUT_TOKEN_MAX )
9487 if ( inputTokens === undefined || limit . context <= 0 ) return requested
9588 const room = limit . context - inputTokens . measured - Math . ceil ( inputTokens . estimated * ( 1 + ESTIMATE_ERROR ) )
9689 return Math . min ( requested , Math . max ( OUTPUT_TOKEN_MIN , room ) )
@@ -258,7 +251,7 @@ export const layer = Layer.effect(
258251 messages : input . messages ,
259252 options :
260253 kind === "primary" || kind === "compaction"
261- ? { maxTokens : outputLimit ( model . limit , kind , input . inputTokens ) }
254+ ? { maxTokens : outputLimit ( model . limit , input . inputTokens ) }
262255 : { } ,
263256 } ,
264257 Object . fromEntries ( Array . from ( given , ( [ d , t ] ) => [ t . name , d ] ) ) ,
0 commit comments