Skip to content

Commit 509240f

Browse files
committed
cursor feedback
1 parent 806b564 commit 509240f

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

packages/optimization/src/ldai_optimizer/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ async def optimize_from_config(
18151815
else:
18161816
result = await self._run_optimization(agent_config, optimization_options)
18171817

1818-
if options.auto_commit and self._last_run_succeeded and self._last_succeeded_context:
1818+
if optimization_options.auto_commit and options.auto_commit and self._last_run_succeeded and self._last_succeeded_context:
18191819
created_key = self._commit_variation(
18201820
self._last_succeeded_context,
18211821
project_key=options.project_key,

packages/optimization/tests/test_client.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4813,6 +4813,21 @@ async def test_commit_not_called_when_auto_commit_false(self):
48134813

48144814
mock_commit.assert_not_called()
48154815

4816+
async def test_commit_not_called_when_api_config_auto_commit_false(self):
4817+
"""autoCommit: false in the API config suppresses the commit even when
4818+
OptimizationFromConfigOptions.auto_commit is True (the default)."""
4819+
client = self._make_client_with_key()
4820+
mock_api = _make_mock_api_client()
4821+
api_config_no_commit = {**_API_CONFIG, "autoCommit": False}
4822+
mock_api.get_agent_optimization = MagicMock(return_value=api_config_no_commit)
4823+
4824+
with patch("ldai_optimizer.client.LDApiClient", return_value=mock_api):
4825+
with patch.object(client, "_commit_variation") as mock_commit:
4826+
# options.auto_commit is True (default); commit must still be skipped
4827+
await client.optimize_from_config("my-opt", _make_from_config_options())
4828+
4829+
mock_commit.assert_not_called()
4830+
48164831
async def test_commit_receives_pre_built_api_client(self):
48174832
"""The api_client created for fetching config is reused for _commit_variation."""
48184833
client = self._make_client_with_key()

0 commit comments

Comments
 (0)