( toolName: string, declaredMaxResultSizeChars: number, )
| 53 | * to the hardcoded default instead of throwing on index or returning 0. |
| 54 | */ |
| 55 | export function getPersistenceThreshold( |
| 56 | toolName: string, |
| 57 | declaredMaxResultSizeChars: number, |
| 58 | ): number { |
| 59 | // Infinity = hard opt-out. Read self-bounds via maxTokens; persisting its |
| 60 | // output to a file the model reads back with Read is circular. Checked |
| 61 | // before the GB override so tengu_satin_quoll can't force it back on. |
| 62 | if (!Number.isFinite(declaredMaxResultSizeChars)) { |
| 63 | return declaredMaxResultSizeChars |
| 64 | } |
| 65 | const overrides = getFeatureValue_CACHED_MAY_BE_STALE<Record< |
| 66 | string, |
| 67 | number |
| 68 | > | null>(PERSIST_THRESHOLD_OVERRIDE_FLAG, {}) |
| 69 | const override = overrides?.[toolName] |
| 70 | if ( |
| 71 | typeof override === 'number' && |
| 72 | Number.isFinite(override) && |
| 73 | override > 0 |
| 74 | ) { |
| 75 | return override |
| 76 | } |
| 77 | return Math.min(declaredMaxResultSizeChars, DEFAULT_MAX_RESULT_SIZE_CHARS) |
| 78 | } |
| 79 | |
| 80 | // Result of persisting a tool result to disk |
| 81 | export type PersistedToolResult = { |
no test coverage detected