π File detail
constants/toolLimits.ts
π§© .tsπ 57 linesπΎ 2,169 bytesπ text
β Back to All Filesπ― Use case
This file lives under βconstants/β, which covers static strings, built-in prompts, spinners, and style constants. On the API surface it exposes DEFAULT_MAX_RESULT_SIZE_CHARS, MAX_TOOL_RESULT_TOKENS, BYTES_PER_TOKEN, MAX_TOOL_RESULT_BYTES, and MAX_TOOL_RESULTS_PER_MESSAGE_CHARS (and more) β mainly types, interfaces, or factory objects. What the file header says: Constants related to tool result size limits.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
Constants related to tool result size limits
π€ Exports (heuristic)
DEFAULT_MAX_RESULT_SIZE_CHARSMAX_TOOL_RESULT_TOKENSBYTES_PER_TOKENMAX_TOOL_RESULT_BYTESMAX_TOOL_RESULTS_PER_MESSAGE_CHARSTOOL_SUMMARY_MAX_LENGTH
π₯οΈ Source preview
/** * Constants related to tool result size limits */ /** * Default maximum size in characters for tool results before they get persisted * to disk. When exceeded, the result is saved to a file and the model receives * a preview with the file path instead of the full content. * * Individual tools may declare a lower maxResultSizeChars, but this constant * acts as a system-wide cap regardless of what tools declare. */ export const DEFAULT_MAX_RESULT_SIZE_CHARS = 50_000 /** * Maximum size for tool results in tokens. * Based on analysis of tool result sizes, we set this to a reasonable upper bound * to prevent excessively large tool results from consuming too much context. * * This is approximately 400KB of text (assuming ~4 bytes per token). */ export const MAX_TOOL_RESULT_TOKENS = 100_000 /** * Bytes per token estimate for calculating token count from byte size. * This is a conservative estimate - actual token count may vary. */ export const BYTES_PER_TOKEN = 4 /** * Maximum size for tool results in bytes (derived from token limit). */ export const MAX_TOOL_RESULT_BYTES = MAX_TOOL_RESULT_TOKENS * BYTES_PER_TOKEN /** * Default maximum aggregate size in characters for tool_result blocks within * a SINGLE user message (one turn's batch of parallel tool results). When a * message's blocks together exceed this, the largest blocks in that message * are persisted to disk and replaced with previews until under budget. * Messages are evaluated independently β a 150K result in one turn and a * 150K result in the next are both untouched. * * This prevents N parallel tools from each hitting the per-tool max and * collectively producing e.g. 10 Γ 40K = 400K in one turn's user message. * * Overridable at runtime via GrowthBook flag tengu_hawthorn_window β see * getPerMessageBudgetLimit() in toolResultStorage.ts. */ export const MAX_TOOL_RESULTS_PER_MESSAGE_CHARS = 200_000 /** * Maximum character length for tool summary strings in compact views. * Used by getToolUseSummary() implementations to truncate long inputs * for display in grouped agent rendering. */ export const TOOL_SUMMARY_MAX_LENGTH = 50