Problem
Event._accept_convenience_kwargs() consumes convenience inputs such as message, state, route, and node_path in a mode="before" model validator.
When callers use Event.model_validate(payload) with a dict they still own, Pydantic passes that dict into the before validator. The validator currently calls pop() directly on that mapping, so validation rewrites the caller's original payload in place.
Minimal reproduction:
from google.adk.events.event import Event
payload = {
"message": "Hello!",
"state": {"key": "value"},
"route": "next",
"node_path": "root.node",
}
Event.model_validate(payload)
print(payload)
Current behavior: payload is mutated from the convenience-key shape into a canonical event shape containing content, actions, and node_info.
Expected behavior: validation should produce the canonical Event output without modifying the caller-provided input dictionary.
Impact
Callers that reuse the same payload for logging, retrying, comparing, or validating elsewhere can observe unexpected top-level mutation after Event.model_validate().
Proposed fix
Copy the incoming dict inside the before validator before consuming convenience keys. This preserves the existing routing behavior while avoiding mutation of caller-owned input.
Related PR
A focused fix and regression test are proposed in #6314.
Problem
Event._accept_convenience_kwargs()consumes convenience inputs such asmessage,state,route, andnode_pathin amode="before"model validator.When callers use
Event.model_validate(payload)with a dict they still own, Pydantic passes that dict into the before validator. The validator currently callspop()directly on that mapping, so validation rewrites the caller's original payload in place.Minimal reproduction:
Current behavior:
payloadis mutated from the convenience-key shape into a canonical event shape containingcontent,actions, andnode_info.Expected behavior: validation should produce the canonical
Eventoutput without modifying the caller-provided input dictionary.Impact
Callers that reuse the same payload for logging, retrying, comparing, or validating elsewhere can observe unexpected top-level mutation after
Event.model_validate().Proposed fix
Copy the incoming dict inside the before validator before consuming convenience keys. This preserves the existing routing behavior while avoiding mutation of caller-owned input.
Related PR
A focused fix and regression test are proposed in #6314.