You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
omitempty silently erases explicitly-configured zero values on max_result_size_chars, activity_max_size_mb and tracing.sample_rate #1175
Three config fields are tagged omitempty on a numeric type while 0 is a meaningful, documented value. SaveConfig (internal/config/loader.go:392) is json.MarshalIndent, so an operator's explicit 0 is deleted from mcp_config.json on the next save and the field silently reverts to its default.
This was found and fixed for activity_max_response_size while reviewing #1173/#1174. The same shape exists on three more fields that nobody has fixed.
Affected fields
Field
Line
Default
What 0 is documented to mean
max_result_size_chars
internal/config/config.go:261
500000
"Set to 0 to disable." — the field's own doc comment
activity_max_size_mb
internal/config/config.go:467
256
"0=disabled" — the field's own doc comment
observability.tracing.sample_rate
internal/config/config.go:1486
0.1
sample nothing
max_result_size_chars is the sharpest: it is advertised on every tool as _meta.anthropic/maxResultSizeChars and internal/server/mcp_max_result_size.go treats <= 0 as the opt-out. So an operator who deliberately disables the annotation gets it silently re-enabled at 500000 on the next config write.
sample_rate means an operator who turns trace sampling off gets 10% sampling back.
Reproduce
Set the field to 0, save the config through any path that calls SaveConfig — the Web UI raw-config editor (GET /api/v1/config → POST /api/v1/config/apply) is the easy one — then read the file back. The key is gone. Restart and the default is in force.
Verified empirically per field: set on DefaultConfig(), json.MarshalIndent, check whether the key survived.
Suggested fix
activity_max_response_size was fixed by making the field a *int with a single Effective…() reader: nil = absent (default applies), 0 = explicitly disabled, and both round-trip through marshal → decode without loss. Dropping omitempty from the int is not equivalent — it materialises an absent key as an explicit 0, which turns the feature off for every operator who never set it. There is a regression test pinning exactly that distinction (TestActivityMaxResponseSizeAbsentKeyStaysAbsentAndKeepsTheCap).
Worth adding alongside the fixes: a guard test that walks the Config struct by reflection and fails on any numeric field carrying omitempty unless it is on an allowlist with a stated reason. That is what stops this class coming back a fourth time.
Activity
chore(roadmap): mcp-2026-upgrade to P1, activity-storage-bounds task,…
docs(release): notice for the config.db bloat fix and its manual comp…
fix(storage): bound the tool-call history, stop erasing configured ze…
docs(specs): commit specs 104/105 and put both on the roadmap (#1232)
Merge upstream/main into feat/tool-response-save-to-file