Improve buyer booking flow and integrate Meta and GAM Reporting#87
Open
Sirajmx wants to merge 9 commits into
Open
Improve buyer booking flow and integrate Meta and GAM Reporting#87Sirajmx wants to merge 9 commits into
Sirajmx wants to merge 9 commits into
Conversation
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.
Meta Ads Integration, Booking Workflow Fixes & Reporting Architecture
Meta Ads Integration (commits 68b96cf, db60b68)
deal_booking_flow.py — Social channel bookings go through the Meta Graph API (graph.facebook.com) directly via
_book_via_meta_api(): creates campaign → ad set per recommendation. Campaigns are created in paused state awaiting
creative review. MetaAdsClient wraps the Graph API calls.
settings.py — META_ACCESS_TOKEN, META_AD_ACCOUNT_ID, META_PAGE_ID, META_API_VERSION added.
docs/integration/meta-ads.md — Public MkDocs page covering setup, Graph API booking flow (sequence diagram), reach
estimate configuration, and reporting.
Buyer Booking Workflow Fix (commit 88e9965)
Resolved booking flow failures when calling the seller agent.
deal_booking_flow.py — Rewired the full quote → deal → order sequence against the seller's IAB Deals API v1.0
endpoints (/api/v1/quotes, /api/v1/deals, /api/v1/orders). Added _book_via_meta_api() and _book_via_seller_api() as
separate booking paths per channel type.
opendirect_client.py — Migrated from a persistent self._client to per-request _make_client() pattern, fixing "Event
loop is closed" errors when CrewAI crews run kickoff() in worker threads with their own event loops.
channel_crews.py, portfolio_crew.py — Channel research crews now call the seller's product search and avails
endpoints correctly. Budget allocation prompt updated to enforce the channels field from the campaign brief,
preventing the LLM from allocating to channels not requested.
Budget Allocation Fix (commit 1da09b7)
portfolio_crew.py — LLM prompt now injects a hard constraint when channels is specified in the brief ("MUST allocate
across ONLY these channels"). deal_booking_flow.py adds an Option B proportional rescale fallback in case the LLM
still returns wrong channels.
Reporting Architecture: GAM moved to seller (commits 43b1dfe, ba7d433, b86083d)
GAM is a sell-side ad server — buyers don't have GAM accounts. The architectural correction:
delivery without a separate API call
endpoint (the correct A2A path), keeping Meta Graph API for social lines
Lint, Formatting & Test Fixes (commit 7801146)
opendirect_client.py — Completed _make_client() migration for all remaining account/order/line/creative methods (14
methods still used self._client after the partial May 2 migration).
Test fixes: test_client.py, test_deal_booking_flow.py, test_error_propagation.py — replaced
patch.object(client._client, ...) with proper async context manager mock via patch.object(client, "_make_client",
...). TestApprovalAndBooking patched _book_via_seller_api to mock the HTTP call; corrected booking_status assertion
from "pending_execution" → "booked".
Ruff E501, F401, N806 violations fixed across modified files.