**Related issue:** Resolves#35615
# Checklist for submitter
## Testing
- [x] Added/updated automated tests
- [x] QA'd all new/changed functionality manually
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Refactor**
* Improved YAML output generation for agent options. Empty command line
flags are now cleanly omitted, and unnecessary comment blocks are
removed for a more concise output structure.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->