AnyBot/docs/restructure/notes/b02b-agent-2.md

19 lines
3.6 KiB
Markdown
Raw Normal View History

# b02b agent.rs 801-1600
- refresh_own:自己電腦 place 中途隨 cloudbox available 換 Sealed↔Box(bot_dir)+告知文字。
- bad_action:browser/computer 空 args{}→「參數沒送到」指導(直接放最外層+範例;browser 給單動作工具清單;395次/日案例);非 JSON→转義指導;action 不合法→列 enum。
- SAME_FAILURES_STOP=3(同工具同文字連續失敗3→本輪不再跑);same_failures(read_terminal/write_terminal/browser_wait 除外);same_answers(同 args 同結果連續計數;⚠️前導行不算差異;ask/HANDOFF 除外)。
- keep_grant(本輪「永遠允許」一次)。
- check_in:每 25 步最新 Tool 結果尾加問(只 model 見,聊天原樣);有完成條件→報 sent/want+停線;stalled(連續 STALLS_STOP=2 個 check-in 無新 sent→系統停輪文字)。
- noted:moved 搬台前綴。chosen_by_person=default≠roles.own;not_here(連不到禁自換台文字);roles_now:remote::person_host 變(打字/答 hand-off 那台=現在人的電腦);names_a_computer。
- screen_target:指名→有螢幕?否則 own 無 Docker 文案(mac: OrbStack/Docker Desktop)/SSH 只能檔案;default 有螢幕→用;chosen_by_person 無螢幕→拒(別換台);未指名順序 Box(real)→Local(real)→Device→Box→Local;找不到=錯。estimate_tokens:ascii*2/7+其他(3.5字/token 保守)。
- history_tokens:system+逐則(text+calls args(folded→cap FOLDED_ARGS_TOKENS=200)+pictures(kept_images 內才計)+4);image_tokens=b64.len/800 clamp(800,3200)。
- compaction_cut:len≤KEEP+1 無;倒找 User 非 steer 非 only_in_turn 且前段非全 summary;only_in_turn=「【AnyBot:」開頭 User(窗內不見→摘要切口靠它)。
- flatten:每則 clip 2000;summary 標「【先前的摘要】」;assistant 附 [使用工具 n:describe]。
- FOLD_MIN_CHARS=600;FOLD_BATCH_PERCENT=15(~19k/128k 滾動收起批次,破 cache 一次非每步);folded_text=頭200字+read_result id=outputs::keep(完整結果可讀回);fold_results(前段長結果收起,清圖)。
- SUMMARY_SYSTEM 五段(要的/決定的/做過的/未成/注意;條列;無寫「(無)」;指令路徑網址數字照原);SUMMARY_MIN_CHARS=200 太短二次;SUMMARY_PERSON_WORDS=12/CHARS=400(原話照原文附尾);TURN_BOT thread_local(背景指令列名);SUMMARY_PIECE_CHARS=40000 分段逐段併摘要(一段超模型可讀→失敗留長);SUMMARY_RESULT_CHARS=600;local_summary(無模型自寫:更早摘要4000+最新40步+狀態+最後回答1500);with_what_must_stay(原話+tools::running_for 背景指令 #id)。
- maybe_compact:tools_tokens(~12k 全工具)計入;滾動收起(≥15%→fold_results+StreamEvent::Folded);used*100<ctx*percent 停;先收起再算;cut 無→turn_cut 值得(WITHIN_TURN_MIN=10 步)→compact_within_turn;summarize(step_model 快模型)→summary Message(splice ..cut,StreamEvent::Compacted(cut,summary,boundary=history[cut].at));oplog step "compaction"。
- first_waits map(每 bot 本轮首字預算)/first_wait_secs=max(provider FIRST_RESPONSE_TIMEOUT)+MARGIN 30(窗 watchdog 只抓掛死)。
- wait_after_send:browser_wait after_send clamp≤900s(刻1/4小時),無 send 過=不用等;中停=None。
- RoomWay{Pictures,Results,Summary}+Room(tried,last,pictures_as_text);PICTURE_AS_TEXT_TOKENS=20000(pictures_read_as_text:overflow_prompt 減我們估/圖數>20k=這 gateway 讀圖當字→此後全無圖);ROOM_KEEP_RESULTS=2;make_room 順序未試過:drop_pictures(每圖換一句話)/fold_all_but_newest/Summary(maybe_compact(0) 或 within_turn);still_too_long(列試過+system/tools/history tokens+建議關能力換模型)。
- REFUSED_ALREADY 文案(同輪已拒:停,等他下則,問他想怎麼做)。