3722544c00
Bug: Phase 11 sites 5+6 migration extracted _set_tool_preset_result and
_set_bias_profile_result helpers. The _set_tool_preset_result helper
modifies _active_tool_preset, _tool_approval_modes, _agent_tools without
declaring them as global, which causes the assignments to create LOCAL
variables instead of modifying the module-level globals.
This regression broke tests/test_bias_integration.py::test_set_tool_preset_with_objects:
preset = ToolPreset(name='ObjTest', categories={'General': [Tool(name='read_file', approval='auto')]})
with patch('src.tool_presets.ToolPresetManager.load_all', return_value={'ObjTest': preset}):
ai_client.set_tool_preset('ObjTest')
assert ai_client._agent_tools['read_file'] is True
# Fails: KeyError 'read_file' (the helper created a local _agent_tools,
# not modifying the module global; set_tool_preset legacy then ran
# cache-invalidation but never assigned _agent_tools to the test's view)
Fix: Add 'global _active_tool_preset, _tool_approval_modes, _agent_tools'
declaration to _set_tool_preset_result. The original set_tool_preset had
this declaration at the top; the helper extraction lost it.
Audit: no audit change (the helper still classifies as BOUNDARY_CONVERSION
via Heuristic A 'returns Result' pattern).