「会走进哪一格」那半句里的盒数,抄这一圈认名字贴上的那一行,不抄你写进 cartons.txt、这一圈还没贴上的那个数;那一行还没写下,半句留着;贴上的数和上一圈不同,才按那一行重写半句,再拿这一圈问那三句

AI 系列第 35 篇。上一篇:第一行没变、盒数变了的那一圈,拼页记下的句子仍是旧的,图上目标那一句留着;「会走进哪一格」那半句按这一次的盒数重写,再拿这一圈问那三句。上一篇停在一句:盒数变了,半句按这一次重写。这一篇做这个数从哪一行抄。

中文

还是那句目标,还是那几扇门。上一篇结束时,三句在那份八行上过了。loop.txt 的第一行仍是「少于 3 才写入」,图上目标也是这一句。半句写着牛奶是 5、这一次不走进 shopping.add。那一圈对得上。这一篇不改第一行。不添新的门。半句里的盒数,抄这一圈认名字贴上的那一行。

[系统] 确认牛奶和鸡蛋的盒数。少于 2 盒的写进购物清单。
盒数请调用 fridge.count。写清单请调用 shopping.add。
不要编造盒数。步数上限 8。同一扇门同一组参数失败 3 次就停。
下单不在这份名单里。
[用户] 冰箱里牛奶和鸡蛋够不够?不够的列进清单。
[模型]

第十四篇那一圈,更早的中文单篇写成过组装、决定、执行、写回、检查是否停止:AI 智能体的执行原理。那一篇不算本系列的第一篇。这一篇仍从冰箱写起。开头那一块是原来的任务。拼上页的是 loop.txt 的第一行。贴上盒数的是 doors/fridge.count。要分开的是你写进 cartons.txt 的数,和这一圈已经贴上的那一行。

那一行还没写下,半句留着

今晚把 cartons.txt 从牛奶 5、鸡蛋 4 改成牛奶 2、鸡蛋 4。第一行、名单、停都不动。文件末尾可以加一句「改成牛奶 2」,盒数那一行也可以已经是 2。diagram.txt 先留着。它还写着牛奶是 5、不走进 shopping.add。

新的 trace.txt 还没有。认名字还没跑,没有贴上的那一行。你打下的 2 在文件里,不在这一圈的轨迹里。半句不抄这个 2。半句留着上一圈贴上的牛奶 5。

第三十一篇写过:没读到的字,这一格仍是旧的。门还没贴,你也不知道它读到的是盒数那一行,还是末尾那句。行还没写下,半句不改。

贴上的数和上一圈不同,才按那一行重写,再问这十二行

盒数那一行这次是牛奶 2、鸡蛋 4。fridge.count 仍去读 cartons.txt。run 走一圈。这一圈的 trace.txt 是这十二行:

1   拼页      读 loop.txt 第一行「少于 3 才写入」。名单仍是 fridge.count,shopping.add。页上没有注
2   放回模型  放回次数 1
3   认名字    跑了 doors/fridge.count。贴上「牛奶 2」「鸡蛋 4」
4   还放回吗  走否则
5   拼页      第一行仍是「少于 3 才写入」。名单没变
6   放回模型  放回次数 2
7   认名字    交出 shopping.add,参数是牛奶。贴上「已写入:牛奶。」
8   还放回吗  走否则
9   拼页      第一行仍是「少于 3 才写入」。名单没变
10  放回模型  放回次数 3
11  收口      「今晚牛奶 2 盒已列进清单,鸡蛋 4 盒够。」和 history 对得上
12  停        气泡交出去

上一圈第 3 行贴的是「牛奶 5」。这一圈第 3 行贴的是「牛奶 2」「鸡蛋 4」。贴上的数和上一圈不同。现在才改半句。从第 3 行抄。不从你保存进 cartons.txt 的那一稿抄。两稿这次一样,抄的仍是贴上的那一行。

diagram.txt 里拼页那一格
旧:目标:少于 3 才写入。牛奶是 5,不小于 3,这一次不走进 shopping.add
新:目标:少于 3 才写入。牛奶是 2,少于 3,这一次走进 shopping.add
右边仍是 loop.txt。名单仍是 fridge.count,shopping.add

「少于 3 才写入」不动。拼页记下的仍是这一句。2 少于 3,这一次走进 shopping.add。鸡蛋是 4,不写。十二行不添到图上。这扇门仍是认名字那一格。走进了,就写在半句里。放回从两次变成三次,是多走一扇门。第二十二篇那笔账上,多一扇门就多一次放回。多出来的那一次,不改盒数从哪一行抄。

三句是第二十九篇那三句。每一行在图上找得到格。图上那一句配上这一次的盒数,说会走进的格,轨迹里有。格子里的句子,和这一行读到的句子,是同一句。

问的是这十二行。1、5、9 是拼页,2、6、10 是放回,3 和 7 是认名字,4 和 8 是否则,11 是收口,12 是停。都有。没有多出来的一行。

图上现在是「少于 3 才写入」,牛奶是 2,走进 shopping.add。这十二行里有。鸡蛋是 4,轨迹里没有给鸡蛋的写入。这一句过了。

拼页指着 loop.txt,第 1 行记下的是「少于 3 才写入」。认名字先跑 doors/fridge.count,贴上「牛奶 2」「鸡蛋 4」,再跑 doors/shopping.add。这一句也过了。半句里的 2 来自第 3 行。第三句比的是读到的那一句。半句对不对,看的是第二句。

三句都过。图追上了这一次。追上说的是这十二行。八行留着,只用来比:贴上的牛奶从 5 变成了 2。

盒数那一行仍是牛奶 5,你只在末尾加了「改成 2」。run 再走。第 3 行仍贴「牛奶 5」「鸡蛋 4」,后面没有 shopping.add。贴上的数和上一圈相同。半句留着牛奶是 5、不走进。这一圈仍是八行,三句仍然过。末尾那个 2 没有贴上,不进半句。你若按末尾改成牛奶 2、走进 shopping.add,这八行没有那一格。第二句过不去。

十二行还没有,你就把半句改成牛奶 2。后来这一圈若仍贴「牛奶 5」,图说走进 shopping.add,轨迹里没有。第二句过不去。保存不是改半句的那一步。改半句要等贴上的那一行,并且这一行的数得和上一圈不同。

十二行已经贴上「牛奶 2」,你却拿八行来问。半句写着走进 shopping.add,八行没有,贴的是「牛奶 5」。第二句过不去。八行过的时候,半句还是牛奶 5。半句换成这一行的数之后,要问写下这一行的那一圈。

你看见走进了 shopping.add,把目标改成「少于 2」,或改成收口那句。第 1 行仍是「少于 3」。第三句过不去。收口可以写成「牛奶 1 盒」。整齐是第 11 行。盒数在第 3 行贴上的「牛奶 2」。半句若抄收口的 1,这一圈贴上的是 2。第二句不过。

一个常见误会

误会是:cartons.txt 一保存,半句就改成你打下的那个数;或者贴上的数和上一圈相同,因为文件动过,半句也要重写;或者十二行更长,就把整份抄进 diagram.txt;或者问模型「现在是不是 2 盒」。

保存写的是文件。这一圈的盒数是认名字已经贴上的那一行。那一行还没写下,半句留着。贴上的数和上一圈相同,半句也留着。只有不同,才按那一行重写,再拿这一圈问那三句。八行上的通过盖不住这十二行。

把十二行整份抄进图,句子是从轨迹抄的,图就不再指着文件。这一篇目标不动。放回、认名字、停留着,右边的文件名也不换。变的只有半句里的盒数,而且要等贴上的那一行和上一圈不同。

模型看不见 diagram.txt。你问它是几盒,它交出来的仍是下一段。第八篇写过:下一段不是观察。它也看不见你刚保存的文件,除非这一圈的门已经把数贴上。盒数是那一行里的数。

留下三句就够这一篇用:半句里的盒数,抄这一圈认名字贴上的那一行,不抄你写进 cartons.txt、这一圈还没贴上的那个数;那一行还没写下,半句留着;贴上的数和上一圈不同,才按那一行重写半句,再拿这一圈问那三句。下一篇再拆:认名字那一行贴着牛奶和鸡蛋两个数,半句里的盒数抄这一行的牛奶,不抄同一行的鸡蛋;鸡蛋变了、牛奶和上一圈相同,半句留着;只有牛奶那个数不同,才按那一行的牛奶重写半句,再拿这一圈问那三句。

English

Part 35 starts where part 34 stopped. The last part stopped on one line: when the counts change, rewrite the half-sentence from this run. This part is about which line that count is copied from.

The goal is the same, and so are the doors. At the end of the last part, the three questions had passed on an eight-line trace. The first line of loop.txt was still “write it only below 3,” and the goal on the picture said the same. The half-sentence said milk at 5 does not walk into shopping.add on that run. That walk matched. This part does not change the first line. It adds no new door. The count inside the half-sentence is copied from the line this walk’s recognize-the-name step pasted.

[system] Confirm the carton counts for milk and eggs.
If either is below 2, write it on the shopping list.
For a count, call fridge.count. To write the list, call shopping.add.
Do not invent a count. Cap the loop at 8 steps.
Stop after the same door fails 3 times with the same arguments.
Placing an order is not on this list.
[user] Are the milk and eggs in the fridge enough?
Put whatever is short on the list.
[model]

An earlier Chinese piece, outside this series, wrote the loop from part 14 as assemble, decide, run, write back, and check whether to stop: how an agent actually runs. That piece is not part 1. This part still starts from the fridge. The block above is the original task. What gets pasted onto the page is the first line of loop.txt. What pastes the counts is doors/fridge.count. What has to be pulled apart is the number you typed into cartons.txt, and the line this walk has already pasted.

While that line is not written, the half-sentence stays

Tonight cartons.txt changes from milk 5 and eggs 4 to milk 2 and eggs 4. The first line, the list, and the stops stay put. A note at the end of the file can say “change it to milk 2,” and the count line itself can already say 2. diagram.txt stays for now. It still says milk at 5 does not walk into shopping.add.

There is no new trace.txt yet. Recognize-the-name has not run, so there is no pasted line. The 2 you typed is in the file. It is not on this walk’s trace. The half-sentence does not copy that 2. It keeps milk at 5, the count the previous walk pasted.

Part 31 already said that wording the cell did not read leaves the cell on the old sentence. Until the door pastes, you do not yet know whether it read the count line or the note at the end. While that line is not written, the half-sentence stays.

Where it shows up: only a different pasted count is rewritten from that line, then you ask these twelve lines

This time the count line is milk 2 and eggs 4. fridge.count still reads cartons.txt. run walks once. This walk’s trace.txt is these twelve lines:

1   assemble the page     read the first line of loop.txt, "write it only below 3." The list is still fridge.count, shopping.add. The note is not on the page
2   put the model back    put-back 1
3   recognize the name    ran doors/fridge.count. Pasted "milk 2" and "eggs 4"
4   put the model back again?    took otherwise
5   assemble the page     the first line is still "write it only below 3." The list did not change
6   put the model back    put-back 2
7   recognize the name    handed over shopping.add, argument milk. Pasted "written: milk."
8   put the model back again?    took otherwise
9   assemble the page     the first line is still "write it only below 3." The list did not change
10  put the model back    put-back 3
11  close                 "Tonight 2 cartons of milk are on the list, and 4 cartons of eggs are enough." It matches history
12  stop                  hand over the bubble

Line 3 of the previous walk pasted “milk 5.” Line 3 of this walk pasted “milk 2” and “eggs 4.” The pasted count differs from the previous walk. Now the half-sentence changes. You copy it from line 3. You do not copy it from the draft you saved into cartons.txt. The two drafts match on this walk. The line you copy is still the pasted one.

the assemble cell in diagram.txt
old: goal: write it only below 3. Milk at 5 is not below 3, so this run does not walk into shopping.add
new: goal: write it only below 3. Milk at 2 is below 3, so this run walks into shopping.add
the right side is still loop.txt. The list is still fridge.count, shopping.add

“Write it only below 3” stays, because assemble still recorded that sentence. Two is below 3, so this run walks into shopping.add. Eggs are 4, so they are not written. The twelve lines are not added to the picture. The door stays the recognize-the-name cell. This run entered it, so the half-sentence says so. Put-backs going from 2 to 3 is one more door. On the bill from part 22, one more door is one more put-back. That extra step does not change which line the count is copied from.

The three questions are the three from part 29. Does each line have a cell on the picture? Given the sentence on the picture and this run’s counts, did the trace enter every cell the picture says this run would walk? Is the sentence in the cell the sentence that line recorded?

You ask them of these twelve lines. Lines 1, 5, and 9 are assemble. Lines 2, 6, and 10 put the model back. Lines 3 and 7 recognize a name. Lines 4 and 8 take otherwise. Line 11 closes. Line 12 stops. Each of those cells is on the picture. No extra line appears.

The picture now says “write it only below 3,” and milk at 2 walks into shopping.add. These twelve lines enter that cell. Eggs are 4, and the trace has no write for eggs. This question passes.

Assemble points at loop.txt, and line 1 recorded “write it only below 3.” Recognizing the name ran doors/fridge.count and pasted “milk 2” and “eggs 4,” then ran doors/shopping.add. This question passes too. The 2 in the half-sentence comes from line 3. The third question compares the sentence that was read. Whether the half-sentence is right is the second question.

All three pass. The picture has caught up with this run. Caught up means these twelve lines. The eight lines stay, so you can see that the pasted milk went from 5 to 2.

The same rule shows which number was copied too early, and which trace was asked too early.

Leave the count line at milk 5, and add only “change it to 2” at the end of the file. run walks again. Line 3 still pastes “milk 5” and “eggs 4,” and shopping.add does not show up later. The pasted count is the same as the previous walk. The half-sentence stays on milk at 5, and on not walking in. This walk is still eight lines, and the three questions still pass. The 2 at the end was never pasted, so it does not enter the half-sentence. Set the half-sentence from that note to milk at 2 walking into shopping.add, and these eight lines do not enter that cell. The second question fails.

Change the half-sentence to milk at 2 before the twelve lines exist. If the later walk still pastes “milk 5,” the picture says this run walks into shopping.add, and the trace does not. The second question fails. A save is not the step that changes the half-sentence. The half-sentence waits for the pasted line, and that line’s count has to differ from the previous walk.

The twelve lines have already pasted “milk 2,” and you ask the eight lines instead. The half-sentence says this run walks into shopping.add. The eight lines do not, and they pasted “milk 5.” The second question fails. When the eight lines passed, the half-sentence still said milk at 5. After the half-sentence is set from this line, you ask the walk that wrote the line down.

See that the walk entered shopping.add, and change the goal to “below 2,” or to the closing sentence. Line 1 is still “below 3.” The third question fails. The close can say “1 carton of milk.” Tidy is line 11. The count is “milk 2” on line 3. Copy 1 from the close, and this walk pasted 2. The second question fails.

The usual mix-up

The usual mix-up is to treat a save of cartons.txt as the moment to set the half-sentence to the number you typed; or to treat an unchanged pasted count as a reason to rewrite the half-sentence because the file moved; or to treat a longer trace as a reason to copy all twelve lines into diagram.txt; or to ask the model whether the count is now 2.

A save writes the file. This walk’s count is the line recognize-the-name has already pasted. While that line is not written, the half-sentence stays. When the pasted count matches the previous walk, the half-sentence stays too. Only when it differs do you rewrite the half-sentence from that line, and then ask this walk the three questions. The pass on the eight lines does not cover these twelve.

Copy all twelve lines onto the picture, and the sentences came from the trace. The picture no longer points at a file. This part leaves the goal where it is. The cells for putting the model back, recognizing a name, and stopping stay, and the file names on their right stay. The only change is the count in the half-sentence, and it waits until the pasted line differs from the previous walk.

The model does not see diagram.txt. Ask how many cartons there are, and what it hands back is still a next span. Part 8 already said a next span is not an observation. The model does not see the file you just saved either, unless this walk’s door has already pasted the count. The count is the number on that line.

What this part hands off is short. The count in the half-sentence is copied from the line this walk’s recognize-the-name step pasted, not from the number you typed into cartons.txt before this walk has pasted it. While that line is not written, the half-sentence stays. Only when the pasted count differs from the previous walk do you rewrite the half-sentence from that line, and then ask this walk the three questions. The next part splits the two numbers on that pasted line: the half-sentence copies the milk on that line, not the eggs on the same line. When the eggs change and the milk matches the previous walk, the half-sentence stays. Only when that milk count differs do you rewrite the half-sentence from the milk on that line, and then ask this walk the three questions.