Configuration¶
The frozen config dataclasses (GazeConfig, SearchConfig,
ImageProcessingConfig, and related) plus config_context(), a ContextVar-based
helper for task-scoped overrides without mutating globals. For the available
settings and usage patterns, see Configuration.
config ¶
Configuration classes for GAZE.
Centralized, frozen configuration for the constants, limits, and tunable parameters used across the framework.
ImageProcessingConfig
dataclass
¶
Configuration for image processing operations.
Attributes:
| Name | Type | Description |
|---|---|---|
min_image_size |
int
|
Minimum dimension for images and crops (pixels) |
max_image_dimension |
int
|
Maximum allowed width or height in pixels |
min_zoom_factor |
float
|
Minimum allowed zoom factor |
max_zoom_factor |
float
|
Maximum allowed zoom factor |
min_contrast_factor |
float
|
Minimum allowed contrast factor |
max_contrast_factor |
float
|
Maximum allowed contrast factor |
min_threshold_window |
int
|
Minimum intensity window width for threshold tool. Prevents destructive narrow windowing that destroys diagnostic info. |
min_window_width |
int
|
Minimum intensity window width for the window_level tool (distinct from the threshold tool's min_threshold_window). |
default_jpeg_quality |
int
|
Default JPEG quality for encoding (1-100) |
max_tool_encode_dimension |
int
|
Longest side, in pixels, of an image sent back to the model in a tool result. The ImageManager keeps the full-resolution image for subsequent operations and measurements; this only bounds the base64 payload, which otherwise reaches megabytes after successive zooms and is re-sent every turn. |
Source code in src/gaze/config.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
CacheConfig
dataclass
¶
Configuration for caching behavior.
Attributes:
| Name | Type | Description |
|---|---|---|
max_cache_size |
int
|
Maximum number of cached entries |
cache_duration_seconds |
int
|
Time-to-live for cache entries in seconds |
evict_ratio |
float
|
Fraction of cache to evict when over limit (0.0-1.0) |
Source code in src/gaze/config.py
SearchConfig
dataclass
¶
Configuration for search operations.
Attributes:
| Name | Type | Description |
|---|---|---|
timeout_seconds |
int
|
Request timeout in seconds |
max_retries |
int
|
Maximum number of retry attempts |
rate_limit_delay_seconds |
float
|
Delay between API calls in seconds |
max_content_preview_length |
int
|
Maximum characters for content preview |
max_snippet_length |
int
|
Maximum characters for snippet extraction |
max_content_for_llm |
int
|
Maximum characters for LLM formatting |
ncbi_base_url |
str
|
Base URL for NCBI E-utilities API |
openi_base_url |
str
|
Base URL for OpenI API |
Source code in src/gaze/config.py
AgenticConfig
dataclass
¶
Configuration for the multi-turn agentic loop.
Holds the tunable parameters of AgenticProcessorBase. Processor
constructor arguments (max_turns, max_tokens, temperature)
override the corresponding defaults here for a single processor; values
that are not exposed as constructor arguments (the hard turn limit, nudge
and idle-tool budgets, tool-content cap) are taken from this config.
Attributes:
| Name | Type | Description |
|---|---|---|
max_turns_limit |
int
|
Hard upper bound on |
default_max_turns |
int
|
Default number of turns when none is given. |
default_max_tokens |
int
|
Default completion-token budget per turn. |
default_temperature |
float
|
Default sampling temperature (0.0 = greedy). |
max_consecutive_nudges |
int
|
Recovery nudges before sending the force-finalize message. |
idle_tool_turns_limit |
int
|
Turns with zero tool calls (in agentic mode) before force-finalizing to avoid token waste. |
max_tool_content_chars |
int
|
Maximum characters retained from a single tool result before truncation (limits prompt-injection surface). |
Source code in src/gaze/config.py
GazeConfig
dataclass
¶
Root configuration for GAZE.
Provides access to all sub-configurations. Can be customized by passing individual config objects or by modifying the defaults.
Example
Use defaults¶
config = GazeConfig()
Customize specific settings¶
config = GazeConfig( cache=CacheConfig(max_cache_size=1000), search=SearchConfig(timeout_seconds=60), )
Access settings¶
print(config.image.max_zoom_factor) # 4.0 print(config.cache.cache_duration_seconds) # 300
Source code in src/gaze/config.py
get_config ¶
Get the current default configuration.
Returns the context-local override when one is active, otherwise the process-wide default configuration.
Returns:
| Type | Description |
|---|---|
GazeConfig
|
The global default GazeConfig instance |
Source code in src/gaze/config.py
set_config ¶
Set the global default configuration.
Thread-safe replacement of the global configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GazeConfig
|
New configuration to use as default |
required |
Example
from gaze.config import set_config, GazeConfig, CacheConfig
custom_config = GazeConfig( cache=CacheConfig(max_cache_size=1000) ) set_config(custom_config)
Source code in src/gaze/config.py
reset_config ¶
Reset the global configuration to defaults.
Convenience wrapper that restores a fresh GazeConfig().
Useful in test teardown to prevent config leakage between tests.
Source code in src/gaze/config.py
config_context ¶
Temporarily override configuration for the current thread/task only.
This does not mutate the process-wide default set by :func:set_config.
Nested contexts restore correctly, and concurrent threads/tasks keep their
own overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GazeConfig
|
Temporary configuration to use inside the block. |
required |
Yields:
| Type | Description |
|---|---|
GazeConfig
|
The temporary configuration (same object as config). |
Example
from gaze.config import config_context, GazeConfig, CacheConfig
with config_context(GazeConfig(cache=CacheConfig(max_cache_size=1000))): # get_config() returns the temporary config here ...