Thanks for the detailed report. This looks like the same issue tracked in issue #7754.
The exact broken build-agent value contains the OSC title fragment ready build. Issue 7754 documents the same stdout escape leak, failed agent selection, and persisted polluted value, with a more complete reproduction. This is not the separate plan-mode filter or custom-agent enumeration issue.
I'm closing this as a duplicate as part of an automated pass on all open issues. I linked this report from issue #7754 so its extra details remain available. This does not mean the underlying bug is fixed.