train
Trains the agent using the provided session, which gives access to a TrainingSession.use block where the training scope (agent, dataset, tracked execution methods) is available.
Implementation note: when writing to the filesystem (artifact storage paths), use ResilientPath (and its methods writeText, createParentDirectories, deleteIfExists) instead of bare java.nio.file.Path stdlib equivalents. On GCS-fuse mounts in the cluster, bare I/O operations can fail with transient errors that ResilientPath handles automatically via retry with exponential backoff.
Training produces optimizer-specific artifacts (saved to disk). Use loadOptimizedAgent to apply those artifacts to a base agent.
Return
The TrainingResult of the training session -- a wrapper around the root stage record and the execution metadata (pod name / timestamps).