Repository navigation
Config: read safety flags strictly and normalize blocked_operations and the numeric limits - #149
Merged
Merged
Conversation
…umeric limits Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A3CSuaJkYYX2HyAsaXbLGH
kLOsk
added a commit
that referenced
this pull request
Dec 4, 2026
Follow-up to #149. blocked_operations given as text with commas or spaces between the names (update_campaign, remove_entity) was kept as one name and blocked nothing; before #149 it blocked by the substring accident. Such text is split into names now, nested lists are flattened, and a value that is not a name or a list of names (true, 5) is refused with the setting's name instead of a TypeError. A blank section (safety: with nothing below it) reads as empty instead of crashing the load, and a section that is not a mapping is refused by name. A confirmation dialog can be answered for an hour instead of the SDK's ten minutes. A later answer came back as a bare "Invalid or expired requestState", which is what someone who stepped away from the screen got. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jr3T22aqqRobKScfCwiyfY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
load_configpassed thesafety:values through untouched:allow_chat_approval: "false"(quoted) stayed the string"false", which is truthy, so it switched chat approval on (safety/approval.py).two_phase_applyandrequire_dry_runhad the same problem._flagalready exists for the GTM and views switches for this reason.blocked_operations: update_campaign(a bare name) was kept as a string, socheck_blocked_operationdid a substring match ("update"counted as blocked); an emptyblocked_operations:becameNoneand raised TypeError.max_daily_budget: "20"raisedTypeError: '>' not supported between 'float' and 'str'on the first budget check.What changed (src/adloop/config.py)
_safety_flag: real bool as is; true/yes/on/1 and false/no/off/0 as text; missing or blank gives the default; any other value keeps the stricter setting (chat approval off, two-phase apply on, dry run on)._number: converts text to a number (whole numbers stay ints, so the bid message reads "50%"); an unusable value, NaN or infinity (text"nan","inf","1e400"or YAML.nan/.inf) raisesValueError: safety.<key> must be a finite number, got .... NaN is refused becausebudget > nanis always False and would switch the cap off._operations: a bare name becomes a one-item list; blank orNonebecomes[].Behaviour notes
require_dry_run: "false"is now False. It follows the user's explicit setting; before, the text was truthy and was ignored.two_phase_applydefaults to False, so a missing value is unchanged; only an unrecognized value now means on. The approval.py readers (lines 151, 176, 654, 660) get a real bool.Tests
New tests/test_config_safety_types.py.
pytest tests: 2739 passed, 2 skipped (run with PYTHONPATH pointing at this checkout's src). No ruff config or lint command in the repo; none run.AI disclosure
Found, written and tested with Claude Code; I'm responsible for it.