Skip to content

test(adkrest/models): add EventActions field mapping coverage - #726

Merged
wolo-lab merged 3 commits into
google:mainfrom
nuthalapativarun:test/509-event-actions-field-mapping
Sep 11, 2026
Merged

wolo-lab merged 3 commits into
google:mainfrom
nuthalapativarun:test/509-event-actions-field-mapping

Conversation

@nuthalapativarun

Copy link
Copy Markdown
Contributor

Description of Change

Problem:
FromSessionEvent and ToSessionEvent were missing TransferToAgent, Escalate, and SkipSummarization fields in the REST API EventActions struct (issue #509). The fix was merged in #609, but there were no tests to prevent regressions.

Solution:
Add table-driven tests covering all three fields for both FromSessionEvent and ToSessionEvent, plus a round-trip test (FromSessionEventToSessionEvent) to verify no EventActions fields are lost.

Closes #509

Testing Plan

Unit Tests:

  • Added TestFromSessionEvent_EventActions — 5 table cases (all fields, each field individually, zero value)
  • Added TestToSessionEvent_EventActions — same 5 cases for reverse direction
  • Added TestFromSessionEvent_RoundTrip — full round-trip test
  • All unit tests pass locally
$ go test ./server/adkrest/internal/models/...
ok  	google.golang.org/adk/server/adkrest/internal/models	0.209s

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Additional context

This PR adds regression test coverage only — no production code changes. The underlying fix was already merged in #609.


Authored by Varun Nuthalapati using AI coding assistance (Claude)

@nuthalapativarun

Copy link
Copy Markdown
Contributor Author

Hi, just checking in on this one — happy to make any adjustments if something needs to change. Let me know if there's anything blocking review. Thanks!

@nuthalapativarun

Copy link
Copy Markdown
Contributor Author

Hi, following up on this PR. Happy to make any changes needed — let me know if there's anything blocking review. Thanks!

@nuthalapativarun

Copy link
Copy Markdown
Contributor Author

Hi, just following up on this PR. Happy to make any adjustments needed — let me know if there's anything blocking review. Thanks!

@nuthalapativarun
nuthalapativarun force-pushed the test/509-event-actions-field-mapping branch from c3498fb to 65d131f Compare May 17, 2026 16:02
@nuthalapativarun

Copy link
Copy Markdown
Contributor Author

Hi, just following up on this PR. Happy to make any adjustments needed — let me know if there's anything blocking review. Thanks!

@karolpiotrowicz

Copy link
Copy Markdown
Contributor

Thanks for adding this coverage — it's a useful gap to close, and the tests look clean: both conversion directions plus a round-trip, fully offline, and passing locally.

One thing I'd like to tighten before approving:

The doc comments say the tests verify "all EventActions fields" / that an event round-trips "without losing any EventActions fields", but session.EventActions.RequestedToolConfirmations isn't carried by the REST EventActions model in server/adkrest/internal/models/event.go, so it's silently dropped in the conversion and isn't exercised here. As written, the comments overclaim what's actually covered.

Could you either:

  • soften the wording to something like "the mapped EventActions fields", or
  • add a case that populates RequestedToolConfirmations and documents the intended omission?

(If dropping that field on the REST surface is not intended, that's worth a separate issue/follow-up rather than folding it into this PR.)

A couple of minor, optional notes:

  • The all-zero-value table rows are essentially tautological — fine to keep, but they don't add much beyond the populated cases.
  • I wasn't able to run golangci-lint locally, so I'll defer to CI on lint.

Once the comment/coverage is tightened up I'm happy to approve. Thanks again!

@nuthalapativarun
nuthalapativarun force-pushed the test/509-event-actions-field-mapping branch from 82bbe25 to d00ae7b Compare June 28, 2026 19:45
@nuthalapativarun

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review @karolpiotrowicz! You're right — the wording overclaimed. I've updated the comments to say "the mapped EventActions fields" instead of "all EventActions fields", which accurately reflects that RequestedToolConfirmations is intentionally not carried in the REST conversion. Happy to open a follow-up issue for that field if you think it's worth tracking. Ready for re-review when you get a chance!

Add table-driven tests for FromSessionEvent and ToSessionEvent to verify
that TransferToAgent, Escalate, and SkipSummarization are correctly mapped
in both directions. Includes a round-trip test.

Closes google#509
@nuthalapativarun
nuthalapativarun force-pushed the test/509-event-actions-field-mapping branch from d00ae7b to 693fe7b Compare July 25, 2026 04:34

@karolpiotrowicz karolpiotrowicz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apologies for the long silence here — you made the change I asked for back in June and this then sat for far too long. I've re-validated it against current main rather than the base it was written on, and it holds up.

It still works after the drift. Your branch is 123 commits behind, so I rebased it locally onto 53a0bc0 and ran it there: clean rebase with no conflict, go build ./... and the package suite both green, five tests passing — your three alongside the two that landed on main in the meantime.

It still pins real behaviour. I broke the mapping code nine different ways and re-ran the package suite twice for each, once with your file and once without. All nine fail with your file and pass without it, so every one is coverage main does not have today. The nicest of them is the Escalate/SkipSummarization source swap: your "all fields populated" case sets both to true and your "zero value" case sets both to false, so neither can see a swap — it is caught only because you also wrote the isolated single-field cases. Those cases look redundant next to the combined one, which is exactly why they usually get dropped.

No overlap with what landed since. event_test.go grew while this was waiting, but it covers RequestedToolConfirmations, Compaction and the workflow fields. Yours covers TransferToAgent, Escalate, SkipSummarization, StateDelta and ArtifactDelta. The two files are disjoint.

One thing worth knowing, since it changes the reasoning behind the wording fix rather than the fix itself. When I raised RequestedToolConfirmations in June it genuinely was not carried by the REST model. It is now, in both directions, and main has since added a seventh field, Compaction, which is deliberately outbound-only — FromSessionEvent maps it and ToSessionEvent drops it, so a client cannot erase conversation history and speak into the gap. Your hedged "the mapped EventActions fields" is still accurate, just for a different reason than when you wrote it.

That does leave one sharp edge in TestFromSessionEvent_RoundTrip. Its comment says the event round-trips "without losing any mapped EventActions fields", and Compaction is a mapped field that intentionally does not survive the trip. If someone later adds Compaction to that fixture to make the test match its own comment, the failure they get reads like data loss in ToSessionEvent, and the obvious repair is the one that removes the protection. I checked both steps and the guard rail holds — TestCompactionIsReadOnlyOverREST fails loudly if anyone tries it — so this costs a future contributor an hour, not a security hole. Worth noting too that event_test.go on main makes a stronger unqualified version of the same claim, so this is ours as much as yours. A clause naming Compaction as the exception would close it, in either file.

I've left two smaller notes on the lines themselves, about a subtest name and an unasserted fixture. Both are optional.

None of this blocks. If you'd rather not do another round after this wait, say so and I'll take the polish as a follow-up — please just rebase onto current main so it can go in.

Separately, and not for this PR: while checking what your tests pin I found several gaps that predate them. Nothing in the package marshals anything, so renaming a JSON tag on EventActions passes the entire suite while breaking every REST client. The nil-versus-empty map distinction that session.EventActions.MarshalJSON deliberately preserves is untested, as is whether the mappers alias or copy the caller's maps, and a new field mapped in only one direction would go unnoticed. I'll open an issue against the package for those — they are not yours to fix.

@wolo-lab
wolo-lab merged commit 5385117 into google:main Sep 11, 2026
14 checks passed
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.

[bug] REST API EventActions doesn't include TransferToAgent, Escalate, SkipSummarization fields

3 participants