mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-24 14:38:01 -05:00
fix(backend): merge settings instead of replacing on partial updates
When updating graph settings (e.g., toggling HITL safe mode), the backend was replacing ALL settings with defaults instead of merging the update. This caused toggling human_in_the_loop_safe_mode to also reset sensitive_action_safe_mode to its default value (false). Fix: Fetch existing settings, merge with new values using model_dump(exclude_unset=True), then save the merged result. This preserves unchanged settings.
This commit is contained in:
@@ -583,7 +583,13 @@ async def update_library_agent(
|
||||
)
|
||||
update_fields["isDeleted"] = is_deleted
|
||||
if settings is not None:
|
||||
update_fields["settings"] = SafeJson(settings.model_dump())
|
||||
existing_agent = await get_library_agent(id=library_agent_id, user_id=user_id)
|
||||
current_settings_dict = (
|
||||
existing_agent.settings.model_dump() if existing_agent.settings else {}
|
||||
)
|
||||
new_settings = settings.model_dump(exclude_unset=True)
|
||||
merged_settings = {**current_settings_dict, **new_settings}
|
||||
update_fields["settings"] = SafeJson(merged_settings)
|
||||
|
||||
try:
|
||||
# If graph_version is provided, update to that specific version
|
||||
|
||||
Reference in New Issue
Block a user