forked from sanbuphy/learn-coding-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolLimits.ts
More file actions
56 lines (50 loc) · 2.12 KB
/
toolLimits.ts
File metadata and controls
56 lines (50 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* 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