Child agency is portrayed both through Tom, the protagonist of the novel, and Hatty, the young orphaned girl from an earlier time who becomes his good friend.
Child agency simply means the power of child characters to influence and change their environment. Both Tom and Hatty are unhappy in the situations in which they find themselves. Tom is bored and frustrated at being quarantined for measles with his childless aunt and uncle in a 'poky flat' while Hatty is oppressed by life as a Victorian orphan in the house of a monstrously uncaring relative. However, through intense longing and the power of imagination, both the children manage to conjure up an escape from their uncongenial circumstances.
Tom's longing to be free from his dull life with his aunt and uncle is said to be so strong it seems that it would 'burst the walls and set him free indeed'. It is this overwhelming, and essentially childlike desire to to find a more appealing place and like-minded companions with whom to play that allows him to enter into the older Hatty's dreams. As the old Mrs Bartholomew - the landlady to Tom's uncle and aunt - Hatty dreams vividly of her childhood living with her aunt and cousins and taking refuge in their beautiful old rambling garden. It is this garden, re-created in Hatty's dreaming mind, that Tom literally enters in some enchanted hour of the night. This garden is the perfect place to play for Tom, and the young Hatty, with her fervent imagination, is the ideal companion.
For both Tom and Hatty, then, the garden of Hatty's youth becomes the place of pure delight that they both dream of. In this way, both these young people are able to transform the dreary circumstances that they find themselves in. In fact, they exert such power through their dreams and longings that they are able to mesh together the past and present in the shape of this old Victorian garden that magically appears to Tom at night. This is an example of child agency.
What lends the story such poignancy, of course, is the realization that the enchanted place and time of childhood, represented by the garden, can never last. The garden itself has disappeared in the modern age. However, Hatty, as an old woman, has kept the secret delight and wonder of childhood in her heart. In the book's beautifully moving conclusion, Tom finds that even as an old widowed woman, Hatty has essentially not changed; in old Mrs. Bartholomew, Tom rediscovers his young companion of the enchanted midnight garden.