Skip to content

draft_campaign / update_campaign: location option - #115

Merged
kLOsk merged 1 commit into
kLOsk:mainfrom
xgp:feat/location-option
Oct 27, 2026
Merged

kLOsk merged 1 commit into
kLOsk:mainfrom
xgp:feat/location-option

Conversation

@xgp

@xgp xgp commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Closes #104.

Adds optional location_option and negative_location_option to draft_campaign and update_campaign, in the shape agreed on the issue.

Parameters

Parameter Values Field
location_option PRESENCE, PRESENCE_OR_INTEREST, SEARCH_INTEREST campaign.geo_target_type_setting.positive_geo_target_type
negative_location_option PRESENCE, PRESENCE_OR_INTEREST campaign.geo_target_type_setting.negative_geo_target_type

Values are case-insensitive. Empty leaves the value as it is: on draft_campaign that means Google's default, so existing callers get the same request and the same preview as before. A test pins that.

Preview

  • update_campaign reads the campaign's current options and puts them next to the new ones in changes: current_location_option → location_option, and current_negative_location_option → negative_location_option. This follows the current_daily_budget pattern. An unknown campaign is refused at draft time.
  • Positive option: any value other than PRESENCE adds a warning that the change widens reach.
  • Negative option: PRESENCE adds a warning that the exclusions now exclude fewer people. The negative side runs the other way round: PRESENCE_OR_INTEREST is the wider exclusion.
  • No change, no warning. On update_campaign, a value the campaign already has produces no warning.
  • Confirmation: a single confirmation everywhere; requires_double_confirm stays false.

Apply and dry run

Both options go on the campaign operation the tool already builds:

  • on create, alongside network_settings;
  • on update, with their own update_mask paths: geo_target_type_setting.positive_geo_target_type / .negative_geo_target_type.

So the dry run is the existing validate_only path; nothing new.

I ran a validate-only dry run against a paused Search campaign in a live account. It came back DRY_RUN_SUCCESS with validated_calls: 1. Nothing was applied.

Rules and tests

  • Rules: .cursor/rules/adloop.mdc now has the tool table entries and one bullet on what the options mean. Synced with scripts/sync-rules.py.
  • Tests: tests/test_location_option.py (16 tests) covers:
    • drafts with the option omitted, PRESENCE, and the wider values;
    • invalid values, refused before any read;
    • old → new in the preview, warnings only on an actual widening change, and an unknown campaign;
    • the create and update operations and the update mask;
    • parameter descriptions on both tools.
  • Suite: uv run pytest gives 1679 passed, 2 skipped.

get_campaign_settings reads both fields back, as you noted. Docs left for you to regenerate after the release, as with #110.

…ce-or-interest)

Optional location_option (PRESENCE, PRESENCE_OR_INTEREST, SEARCH_INTEREST) and negative_location_option (PRESENCE, PRESENCE_OR_INTEREST) on both tools. Empty leaves Google's default, so existing callers see no change. The update_campaign preview shows the current value next to the new one and warns when the change widens reach; a single confirmation. The dry run goes through validate_only with the other campaign fields.

Fixes kLOsk#104.

@kLOsk kLOsk left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging, thanks. One correction we'll make in a follow-up commit: the rules bullet says "anything but PRESENCE widens reach", which is right for the positive option and reversed for the negative one (negative PRESENCE excludes fewer people). The code already warns correctly; only the text was wrong. Also, the "unchanged, no warning" case isn't re-checked at apply, so a UI change in between would go through silently. That's fine for now, same as search partners today.

@kLOsk
kLOsk merged commit b41d76b into kLOsk:main Oct 27, 2026
3 checks passed
kLOsk added a commit that referenced this pull request Oct 27, 2026
Follow-up to #115: the rules said "anything but PRESENCE widens reach",
which holds for location_option and is reversed for
negative_location_option, where PRESENCE excludes only people physically
in the excluded places. The code already warned correctly; the rules and
both tool descriptions now say the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TiC3mRmhzUVXgCexry7GJ3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update_campaign / draft_campaign: set the location option (presence vs presence-or-interest)

2 participants