omega-tool-model
First-party Omega tool-use model source, serving harnesses, and verification records
Brought by drakestapleton
omega-tool-model / native-training / reader.om
| 1 | note Two unseen real fixture reads. Count the first request, the isolated result reply and the complete cycle separately. |
| 2 | text qhead "Task: Read the note and report its value.\nFile: " |
| 3 | text q1 "notes/item97233.txt" |
| 4 | text q2 "notes/item97984.txt" |
| 5 | text ask "\nState: unread\nAnswer:\n" |
| 6 | text result "\nState: read\nTool result: value = " |
| 7 | text answer "\nAnswer:\n" |
| 8 | text req1 "{\"tool\":\"read_file\",\"path\":\"notes/item97233.txt\"}" |
| 9 | text req2 "{\"tool\":\"read_file\",\"path\":\"notes/item97984.txt\"}" |
| 10 | text denied "\nState: denied\nTool result: Permission denied.\nAnswer:\n" |
| 11 | text noauth "Permission denied." |
| 12 | text missing "\nState: missing\nTool result: File not found.\nAnswer:\n" |
| 13 | text nofile "File not found." |
| 14 | global qdata uchar 3 |
| 15 | fn qlen t ulong to ulong |
| 16 | if eq t 0 |
| 17 | ret len qhead |
| 18 | end |
| 19 | if eq t 1 |
| 20 | ret len q1 |
| 21 | end |
| 22 | if eq t 2 |
| 23 | ret len q2 |
| 24 | end |
| 25 | if eq t 3 |
| 26 | ret len ask |
| 27 | end |
| 28 | if eq t 4 |
| 29 | ret len result |
| 30 | end |
| 31 | if eq t 5 |
| 32 | ret len answer |
| 33 | end |
| 34 | if eq t 6 |
| 35 | ret len req1 |
| 36 | end |
| 37 | if eq t 7 |
| 38 | ret len req2 |
| 39 | end |
| 40 | if eq t 8 |
| 41 | ret len denied |
| 42 | end |
| 43 | if eq t 9 |
| 44 | ret len noauth |
| 45 | end |
| 46 | if eq t 10 |
| 47 | ret len missing |
| 48 | end |
| 49 | if eq t 11 |
| 50 | ret len nofile |
| 51 | end |
| 52 | if eq t 12 |
| 53 | ret len qdata |
| 54 | end |
| 55 | exit 77 |
| 56 | end |
| 57 | global sid ulong 1 |
| 58 | global spath uchar 19 |
| 59 | text mark1 "notes/item" |
| 60 | text mark2 "{\"tool\":\"read_file\",\"path\":\"notes/item" |
| 61 | fn sdig i ulong to uchar |
| 62 | v = get sid 0 |
| 63 | for j ulong sub 4 i |
| 64 | v = div v 10 |
| 65 | end |
| 66 | ret uchar add 48 rem v 10 |
| 67 | end |
| 68 | fn qbyte t ulong i ulong to uchar |
| 69 | if eq t 0 |
| 70 | ret get qhead i |
| 71 | end |
| 72 | if eq t 1 |
| 73 | if and ge i len mark1 lt i add len mark1 5 |
| 74 | ret sdig sub i len mark1 |
| 75 | end |
| 76 | ret get q1 i |
| 77 | end |
| 78 | if eq t 2 |
| 79 | ret get q2 i |
| 80 | end |
| 81 | if eq t 3 |
| 82 | ret get ask i |
| 83 | end |
| 84 | if eq t 4 |
| 85 | ret get result i |
| 86 | end |
| 87 | if eq t 5 |
| 88 | ret get answer i |
| 89 | end |
| 90 | if eq t 6 |
| 91 | if and ge i len mark2 lt i add len mark2 5 |
| 92 | ret sdig sub i len mark2 |
| 93 | end |
| 94 | ret get req1 i |
| 95 | end |
| 96 | if eq t 7 |
| 97 | ret get req2 i |
| 98 | end |
| 99 | if eq t 8 |
| 100 | ret get denied i |
| 101 | end |
| 102 | if eq t 9 |
| 103 | ret get noauth i |
| 104 | end |
| 105 | if eq t 10 |
| 106 | ret get missing i |
| 107 | end |
| 108 | if eq t 11 |
| 109 | ret get nofile i |
| 110 | end |
| 111 | if eq t 12 |
| 112 | ret get qdata i |
| 113 | end |
| 114 | exit 77 |
| 115 | end |
| 116 | fn qadd s ulong to void |
| 117 | n = get icount 0 |
| 118 | for i ulong qlen s |
| 119 | put iprom add n i qbyte s i |
| 120 | end |
| 121 | put icount 0 add n qlen s |
| 122 | end |
| 123 | fn qmake p ulong to void |
| 124 | put icount 0 0 |
| 125 | qadd 0 |
| 126 | qadd p |
| 127 | end |
| 128 | fn qinfer to void |
| 129 | put og 9 0 |
| 130 | ocpush 0 |
| 131 | n = obprompt 3 |
| 132 | for i ulong n |
| 133 | ocpush get obtk i |
| 134 | end |
| 135 | put oon 0 0 |
| 136 | for j ulong 64 |
| 137 | c = gsnext |
| 138 | if eq c 0 |
| 139 | ret |
| 140 | end |
| 141 | obtput c |
| 142 | ocpush c |
| 143 | end |
| 144 | end |
| 145 | fn qeq s ulong to bool |
| 146 | if ne get oon 0 qlen s |
| 147 | ret false |
| 148 | end |
| 149 | for i ulong qlen s |
| 150 | if ne get oout i qbyte s i |
| 151 | ret false |
| 152 | end |
| 153 | end |
| 154 | ret true |
| 155 | end |
| 156 | note Read one operator-selected note. Only notes/itemNNNNN.txt is admitted. Write only verified model replies. |
| 157 | global sbuf uchar 4 |
| 158 | fn rdval to int |
| 159 | fd = fopen spath 0 len spath 34816 0 |
| 160 | if lt fd 0 |
| 161 | ret 6 |
| 162 | end |
| 163 | n = ulong 0 |
| 164 | while lt n 4 bound 5 |
| 165 | r = read int fd sbuf n sub 4 n |
| 166 | if lt r 0 |
| 167 | cl = fclose int fd |
| 168 | ret 6 |
| 169 | end |
| 170 | if eq r 0 |
| 171 | break |
| 172 | end |
| 173 | n = add n ulong r |
| 174 | end |
| 175 | cl = fclose int fd |
| 176 | if ne n 3 |
| 177 | ret 6 |
| 178 | end |
| 179 | for i ulong 3 |
| 180 | v = get sbuf i |
| 181 | if or lt v 48 gt v 57 |
| 182 | ret 6 |
| 183 | end |
| 184 | put qdata i v |
| 185 | end |
| 186 | ret 0 |
| 187 | end |
| 188 | fn deliver to int |
| 189 | qmake 1 |
| 190 | qadd 3 |
| 191 | qinfer |
| 192 | if not qeq 6 |
| 193 | ret 5 |
| 194 | end |
| 195 | oputc 10 |
| 196 | oflush |
| 197 | rc = rdval |
| 198 | if ne rc 0 |
| 199 | ret rc |
| 200 | end |
| 201 | qmake 1 |
| 202 | qadd 4 |
| 203 | qadd 12 |
| 204 | qadd 5 |
| 205 | qinfer |
| 206 | if not qeq 12 |
| 207 | ret 7 |
| 208 | end |
| 209 | oputc 10 |
| 210 | oflush |
| 211 | ret 0 |
| 212 | end |
| 213 | global userarg uchar 21 |
| 214 | fn main to int |
| 215 | if ne argcnt 2 |
| 216 | ret 2 |
| 217 | end |
| 218 | n = argread 1 userarg 0 len userarg |
| 219 | if ne n long len spath |
| 220 | ret 2 |
| 221 | end |
| 222 | v = ulong 0 |
| 223 | for j ulong 5 |
| 224 | c = get userarg add len mark1 j |
| 225 | if or lt c 48 gt c 57 |
| 226 | ret 2 |
| 227 | end |
| 228 | v = add mul v 10 sub ulong c 48 |
| 229 | end |
| 230 | put sid 0 v |
| 231 | for i ulong len spath |
| 232 | c = qbyte 1 i |
| 233 | if ne get userarg i c |
| 234 | ret 2 |
| 235 | end |
| 236 | put spath i c |
| 237 | end |
| 238 | ockload 1 |
| 239 | put og 6 1 |
| 240 | obload 4 get og 0 |
| 241 | ggopen |
| 242 | ggupw |
| 243 | rc = deliver |
| 244 | r = nvstop |
| 245 | ret rc |
| 246 | end |