Skip to content

Fix unused proto fields and hardcoded year in agent logic - #22

Open
KshitijKaushik123 wants to merge 1 commit into
IABTechLab:mainfrom
KshitijKaushik123:fix/agent-bugs
Open

Fix unused proto fields and hardcoded year in agent logic#22
KshitijKaushik123 wants to merge 1 commit into
IABTechLab:mainfrom
KshitijKaushik123:fix/agent-bugs

Conversation

@KshitijKaushik123

Copy link
Copy Markdown

Summary

Found several bugs where proto-defined fields were being parsed but never actually used, plus a hardcoded year that'll silently break demographic targeting every January.

Bug 1 — applicable_intents ignored in gRPC path

The agent was supposed to filter mutations based on applicable_intents from the request, but the code had a var applicableIntents []pb.Intent (always nil) with a TODO comment saying the field wasn't in the generated code yet. The field is in the proto and just needed a regen. With nil, every request got all mutation types back regardless of what was asked for — so a caller requesting only ACTIVATE_SEGMENTS would also get ACTIVATE_DEALS, ADJUST_DEAL_FLOOR, etc.

Bug 2 — MCP handler dropped lifecycle, originator, and applicable_intents

The MCP extend_rtb handler carefully parsed all three fields from the tool arguments but then built the gRPC request without any of them:

  • lifecycle was always LIFECYCLE_UNSPECIFIED regardless of input
  • originator was never set on the request
  • applicable_intents were parsed as strings but never converted to proto enums or attached to the request

This meant the entire MCP path had no intent filtering and no lifecycle/originator context.

Bug 3 — Missing parsers and ADD_CIDS case

parseIntent() had ADD_CIDS commented out, and parseLifecycle() / parseOriginatorType() didn't exist at all — they were referenced in TODO comments but never written. Added all three.

Bug 4 — Hardcoded year 2024 in age calculation

determineUserSegments() used 2024 - user.GetYob() to calculate age for demographic bucketing. This means starting January 2025, a user born in 2000 would be calculated as 24 instead of 25, putting them in the wrong segment bucket. Changed to time.Now().Year().

Proto regeneration

The generated Go code was out of sync with the proto definitions — fields like applicable_intents, originator, and the full Lifecycle enum weren't in the generated structs. Regenerated with current protoc to bring them in sync. This overlaps somewhat with #11 but is included here because the code fixes depend on the regenerated fields being available.

Testing

  • go build ./... passes
  • go vet ./... passes
  • Proto regeneration is idempotent (running scripts/generate.sh twice produces same output)

Note on #11

This PR includes the proto regeneration and sample JSON fixes that overlap with #11. If #11 lands first, the proto/sample changes here will merge cleanly since they produce the same result. The unique changes in this PR are the agent logic fixes (handlers.go, agent.go, mcp.go).

…nd MCP paths

Several fields defined in the proto were not being used in the Go implementation,
causing the agent to silently ignore request parameters:

1. applicable_intents was never read from the gRPC request — the agent returned
   all mutation types regardless of what the caller asked for. Now reads
   req.GetApplicableIntents() and passes it through to handlers for filtering.

2. MCP handler parsed lifecycle, originator, and applicable_intents from the
   tool arguments but never attached them to the gRPC request. Lifecycle was
   always UNSPECIFIED, originator was always nil, and intent filtering was
   completely bypassed through the MCP path. All three are now properly parsed
   and set on the request.

3. parseIntent was missing the ADD_CIDS case and parseLifecycle/parseOriginatorType
   functions didn't exist — added both.

4. Hardcoded year 2024 in demographic segment calculation meant age buckets
   would drift wrong every year. Now uses time.Now().Year().

Also includes proto regeneration (import path fix, go_package, Metric type path)
and sample JSON bool fixes needed for the generated code to be in sync —
these overlap with IABTechLab#11 but are included here since the code changes depend
on the regenerated proto having the full field set.
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.

1 participant