fixInstruction function
What a tool result tells a model to do about rejected ops and pending ids: fix the document as it is now, by patching it.
Implementation
String fixInstruction({required int rev, Set<String> pending = const {}}) =>
'The UI exists as described (rev $rev): fix it by patching it, in one ui_apply call. Resend only the rejected '
'ops, corrected, with the same ids; '
'${pending.isEmpty ? '' : 'send a set for each pending id (${pending.take(12).join(', ')}${pending.length > 12 ? '...' : ''}) under the node that lists it, or drop it from that node\'s children; '}'
'patch fields of nodes that exist. Never start over: no new roots, no new canvas, no re-sending nodes that applied.';