模型送空參數的 browser/computer:這段對話改給一個動作一個工具
jenny-Host 的模型(OpenCode Go · deepseek-v4.1-flash)叫 browser 3719 次有 3452 次參數是 {},
action 只出現過 1 次;computer 130 次全是 {}。同一個模型叫 browser_open、browser_tabs 這些單一動作
的工具卻每次都帶得到參數。技能裡早就寫了改用單一動作工具,但清單裡只有 browser,它還是一直回去叫,
連三次就整輪鎖住,一則留言都沒送出。
現在:對話裡出現過一次空的 browser(或 computer),下一步起清單就把它換成一個動作一個工具
(browser_open、browser_click、browser_tabs {action}…;computer_use_screenshot、computer_use_click…),
每個只帶自己的欄位和 profile/computer;fill 和 batch 不拆。空參數的回覆改說「從下一步起改用單一動作的工具」。
已驗證: cargo test 全綠(930 通過,含 featuremap::、layout_audit::、tool_specs_are_locked);新測試
a_model_that_sent_the_one_tool_empty_gets_the_one_action_tools、
after_an_empty_browser_call_the_next_step_offers_the_one_action_tools(假模型走完整一輪);獨立審查(乾淨脈絡)
提的 P1(mouse_move 少 y、click 少 button/count/modifier_keys、typing 少 ref)已修並加進測試。
未驗證: jenny-Host 實機(她的 Bot 正在跑例行任務,不能重開);動到工具清單和 computer,照協定要實機
測試(--ignored)+人類簽名,沒有發佈。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
aeb38794f8
commit
bf3a19fb08
|
|
@ -38,7 +38,7 @@ Bot 用 AnyBot 自己的瀏覽器上網、登入、點按、打字、送出。
|
||||||
|
|
||||||
## 陷阱
|
## 陷阱
|
||||||
|
|
||||||
- 有些模型經閘道叫 `browser` 時參數送到是空的(`{}`;OpenCode Go · deepseek-v4.1-flash 一天 395 次,思考裡每次都有寫動作):AnyBot 說「參數是空的——不是你沒寫,是沒有送到」,再叫一次還是空的就改用單一動作的工具(`browser_open {url}`、`browser_click {ref|text}`…,AnyBot 照收),紀錄檔記一行「叫 browser 卻沒帶參數;串流裡這個呼叫的原文:…」。參數不是合法 JSON 時說「不是合法的 JSON」(字串裡的換行要寫 \n),不再說成沒給 action。
|
- 有些模型經閘道叫 `browser` 時參數送到是空的(`{}`;OpenCode Go · deepseek-v4.1-flash 一天 395 次,思考裡每次都有寫動作):AnyBot 說「參數是空的——不是你沒寫,是沒有送到」,再叫一次還是空的就改用單一動作的工具(`browser_open {url}`、`browser_click {ref|text}`…,AnyBot 照收),紀錄檔記一行「叫 browser 卻沒帶參數;串流裡這個呼叫的原文:…」。對話裡只要出現過一次空的 `browser`(或 `computer`),下一步起工具清單就不再給這個大工具,改給一個動作一個工具(`browser_open`、`browser_click`、`browser_tabs {action}`…,各自只帶自己的欄位;`fill` 和 `computer` 的 `batch` 不拆),紀錄檔記「模型送過空參數的 browser,這段對話改給單一動作的工具」(看的是模型讀得到的對話:那一步被收起進摘要後,下一輪又先給回大工具,再空一次才換)——那個模型在 jenny-Host 叫 `browser` 3719 次有 3452 次空的,叫單一動作的工具卻每次都帶得到參數。參數不是合法 JSON 時說「不是合法的 JSON」(字串裡的換行要寫 \n),不再說成沒給 action。
|
||||||
|
|
||||||
- 別人傳來的訊息那一輪不能用 AnyBot 瀏覽器、保險庫和 `sent`(帶著使用者的登入)。公開網頁用 `web_fetch`。
|
- 別人傳來的訊息那一輪不能用 AnyBot 瀏覽器、保險庫和 `sent`(帶著使用者的登入)。公開網頁用 `web_fetch`。
|
||||||
- 不同電腦、不同設定檔的登入不共用;沒帶 `profile` 會用到別的。
|
- 不同電腦、不同設定檔的登入不共用;沒帶 `profile` 會用到別的。
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ Bot 用一個 `computer` 工具看一台電腦的螢幕、動滑鼠和鍵盤:
|
||||||
|
|
||||||
- 在這台電腦上:先要「在這台電腦上執行」開著([safety](safety.md));看畫面先問(可一律允許);點擊、打字照落在哪個 App 逐個問;桌面看不出是哪個 App 時問整個螢幕(`computer:control`)。直接操作模式不問。帳號裡的其他電腦,看和操作各自要允許(可一律允許);Bot 自己的電腦不問。
|
- 在這台電腦上:先要「在這台電腦上執行」開著([safety](safety.md));看畫面先問(可一律允許);點擊、打字照落在哪個 App 逐個問;桌面看不出是哪個 App 時問整個螢幕(`computer:control`)。直接操作模式不問。帳號裡的其他電腦,看和操作各自要允許(可一律允許);Bot 自己的電腦不問。
|
||||||
- 目標寫著付款、刪除、傳送、送出、發布這類字的點擊或 Enter,每次都問,一律允許和直接操作模式也一樣。
|
- 目標寫著付款、刪除、傳送、送出、發布這類字的點擊或 Enter,每次都問,一律允許和直接操作模式也一樣。
|
||||||
|
- 有些模型經閘道叫 `computer` 時參數送到是空的(`{}`):對話裡出現過一次,下一步起清單改給一個動作一個工具(`computer_use_screenshot`、`computer_use_click`、`computer_use_typing`…,各自只帶自己的欄位和 `computer`;`batch` 不拆)。
|
||||||
- Bot 不能點、按鍵或打字到 AnyBot 自己的視窗(核准卡、開關),`open_app` 也不能切到 AnyBot。
|
- Bot 不能點、按鍵或打字到 AnyBot 自己的視窗(核准卡、開關),`open_app` 也不能切到 AnyBot。
|
||||||
- 按鍵和沒指定欄位的 `typing` 只送到上次截圖時在最前面的 App;中途換了 App 會「沒有按」:先截圖或 `open_app`。
|
- 按鍵和沒指定欄位的 `typing` 只送到上次截圖時在最前面的 App;中途換了 App 會「沒有按」:先截圖或 `open_app`。
|
||||||
- 結果說「畫面和上一步完全一樣」就是沒點到:換編號或換方法,不要重複同一步。
|
- 結果說「畫面和上一步完全一樣」就是沒點到:換編號或換方法,不要重複同一步。
|
||||||
|
|
|
||||||
182
src/agent.rs
182
src/agent.rs
|
|
@ -836,11 +836,12 @@ fn bad_action(tool: &str, args: &str) -> String {
|
||||||
// gave no action」 it sent the same again, three times, and lost the tool for the turn).
|
// gave no action」 it sent the same again, three times, and lost the tool for the turn).
|
||||||
if v.as_object().is_some_and(|o| o.is_empty()) {
|
if v.as_object().is_some_and(|o| o.is_empty()) {
|
||||||
let direct = if tool == crate::browser::TOOL {
|
let direct = if tool == crate::browser::TOOL {
|
||||||
"\n如果再叫一次還是空的,改用單一動作的工具,參數一樣、不用 action:browser_open {url}、browser_read、browser_elements、browser_click {ref|text}、browser_type {ref|text, value}、browser_press {key}、browser_wait {text|seconds}、browser_scroll {direction}、browser_eval {script}、browser_screenshot。"
|
"browser_open {url}、browser_read、browser_elements、browser_click {ref|text}、browser_type {ref|text, value}、browser_press {key}、browser_wait {text|seconds}、browser_scroll {direction}、browser_eval {script}、browser_screenshot"
|
||||||
} else {
|
} else {
|
||||||
""
|
"computer_use_screenshot、computer_use_click {ref|name|x,y}、computer_use_typing {value}、computer_use_press_key {key}、computer_use_scroll {direction}、computer_use_open_app {app}"
|
||||||
};
|
};
|
||||||
return format!("沒有執行:這一步的 {tool} 送到 AnyBot 時參數是空的({{}})——不是你沒寫,是參數沒有送到。再叫一次,參數直接放在最外層,例如 {example}(action 可以是:{})。{direct}", actions.join("、"));
|
// (From the next step the list has these instead of the one tool: see split_unfilled.)
|
||||||
|
return format!("沒有執行:這一步的 {tool} 送到 AnyBot 時參數是空的({{}})——不是你沒寫,是參數沒有送到。從下一步起改用單一動作的工具,參數一樣、不用 action:{direct}。");
|
||||||
}
|
}
|
||||||
if v.is_null() {
|
if v.is_null() {
|
||||||
let head: String = args.chars().take(120).collect();
|
let head: String = args.chars().take(120).collect();
|
||||||
|
|
@ -853,6 +854,102 @@ fn bad_action(tool: &str, args: &str) -> String {
|
||||||
format!("沒有執行:{tool} 要用 action 指定做什麼,這一步{given}。可以用的有:{}。參數直接放在最外層,例如 {example}。", actions.join("、"))
|
format!("沒有執行:{tool} 要用 action 指定做什麼,這一步{given}。可以用的有:{}。參數直接放在最外層,例如 {example}。", actions.join("、"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A model that sent `browser` / `computer` with nothing in it gets the one-action tools instead
|
||||||
|
/// (`browser_click`, `computer_use_typing`…), each with only its own fields. jenny-Host's model
|
||||||
|
/// (OpenCode Go · deepseek-v4.1-flash) sent `browser` `{}` 3452 times out of 3719 and `computer`
|
||||||
|
/// `{}` every time (130), while `browser_open`, `browser_tabs`… carried their arguments every
|
||||||
|
/// time: told to use those, it still went back to the one tool the list showed. Decided from the
|
||||||
|
/// chat: one empty call there and the list changes from the next step on. Returns whether it did.
|
||||||
|
fn split_unfilled(tools: &mut Vec<serde_json::Value>, history: &[Message]) -> bool {
|
||||||
|
let mut changed = false;
|
||||||
|
for composite in [crate::browser::TOOL, computer::TOOL] {
|
||||||
|
let Some(at) = tools.iter().position(|t| t["name"] == composite) else { continue };
|
||||||
|
let empty = |c: &ToolCall| c.name == composite && tools::args_of(&c.args).as_object().is_some_and(|o| o.is_empty());
|
||||||
|
if !history.iter().any(|m| m.tool_calls.iter().any(empty)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let parts = split_composite(&tools[at]);
|
||||||
|
if parts.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
log::info!("AnyBot:模型送過空參數的 {composite},這段對話改給單一動作的工具({} 個)", parts.len());
|
||||||
|
tools.splice(at..=at, parts);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
changed
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One composite tool as one tool per action: its words about that action, the fields those
|
||||||
|
/// words (or the field's own words) name, and the field that picks the computer / profile.
|
||||||
|
/// Left out: actions that only make sense with the composite's own nesting (`batch`) or its
|
||||||
|
/// vault mapping (`fill`) — the one tool still carries those when it gets its arguments.
|
||||||
|
fn split_composite(spec: &serde_json::Value) -> Vec<serde_json::Value> {
|
||||||
|
let name = spec["name"].as_str().unwrap_or("");
|
||||||
|
let desc = spec["description"].as_str().unwrap_or("");
|
||||||
|
let props = spec["parameters"]["properties"].as_object().cloned().unwrap_or_default();
|
||||||
|
let actions: Vec<&str> = props.get("action").and_then(|a| a["enum"].as_array()).map(|a| a.iter().filter_map(|x| x.as_str()).collect()).unwrap_or_default();
|
||||||
|
let has_word = |hay: &str, w: &str| {
|
||||||
|
hay.match_indices(w).any(|(i, _)| {
|
||||||
|
let ok = |c: Option<char>| !c.is_some_and(|c| c.is_ascii_alphanumeric() || c == '_');
|
||||||
|
ok(hay[..i].chars().next_back()) && ok(hay[i + w.len()..].chars().next())
|
||||||
|
})
|
||||||
|
};
|
||||||
|
// The words about one action: browser's 「- click {…}: …」 line, computer's 「click(…)」 part.
|
||||||
|
let about = |a: &str| -> String {
|
||||||
|
if let Some(l) = desc.lines().find(|l| l.strip_prefix("- ").is_some_and(|r| r.starts_with(&format!("{a} ")) || r.starts_with(&format!("{a}:")))) {
|
||||||
|
return l.trim_start_matches("- ").to_string();
|
||||||
|
}
|
||||||
|
desc.split("; ")
|
||||||
|
.find_map(|s| {
|
||||||
|
s.match_indices(a).find(|(i, _)| (*i == 0 || s[..*i].ends_with(':')) && matches!(s[i + a.len()..].chars().next(), None | Some('(' | '。'))).map(|(i, _)| s[i..].to_string())
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
|
};
|
||||||
|
let mut out = vec![];
|
||||||
|
for a in actions {
|
||||||
|
if matches!(a, "batch" | "fill") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let internal = if name == crate::browser::TOOL { crate::browser::action_tool(a) } else { computer::top_action_tool(a) };
|
||||||
|
let Some(internal) = internal else { continue };
|
||||||
|
let words = about(a);
|
||||||
|
let mut own = serde_json::Map::new();
|
||||||
|
for (k, v) in &props {
|
||||||
|
let mentioned = has_word(&words, k) || v["description"].as_str().is_some_and(|d| has_word(d, a));
|
||||||
|
if matches!(k.as_str(), "profile" | "computer") || (k != "action" && mentioned) {
|
||||||
|
own.insert(k.clone(), v.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fields a screen action runs with that its words don't name (a click's button, count
|
||||||
|
// and keys; where a move goes; the field typing clicks first).
|
||||||
|
let more: &[&str] = match (name, a) {
|
||||||
|
(computer::TOOL, "click") => &["ref", "name", "x", "y", "button", "count", "modifier_keys", "hold_duration_ms"],
|
||||||
|
(computer::TOOL, "mouse_move" | "zoom" | "scroll") => &["ref", "name", "x", "y"],
|
||||||
|
(computer::TOOL, "typing") => &["ref", "name"],
|
||||||
|
_ => &[],
|
||||||
|
};
|
||||||
|
for k in more.iter().chain(if own.contains_key("x") { &["y"][..] } else { &[] }) {
|
||||||
|
if let Some(v) = props.get(*k) {
|
||||||
|
own.insert(k.to_string(), v.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// browser tabs {action: list|switch|new|close}: its own `action`, not the composite's.
|
||||||
|
if let Some(choices) = words.split_once("action: ").map(|(_, r)| r.split([',', '}']).next().unwrap_or("").trim()) {
|
||||||
|
own.insert("action".into(), serde_json::json!({"type": "string", "enum": choices.split('|').collect::<Vec<_>>()}));
|
||||||
|
}
|
||||||
|
let mut what = if words.is_empty() { format!("{name} 的 {a}") } else { words };
|
||||||
|
// The one tool's words for every action ride on the tool a page or screen starts with.
|
||||||
|
if matches!(a, "open" | "screenshot") {
|
||||||
|
let general = if name == crate::browser::TOOL { desc.split("\nactions:").next().unwrap_or("") } else { desc.rsplit("check_permissions。").next().filter(|g| *g != desc).unwrap_or("") };
|
||||||
|
if !general.trim().is_empty() {
|
||||||
|
what = format!("{what}\n{}", general.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.push(serde_json::json!({"name": internal, "description": what, "parameters": {"type": "object", "properties": own}}));
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
/// Failures in a row of one tool, all saying the same, after which it isn't run this turn.
|
/// Failures in a row of one tool, all saying the same, after which it isn't run this turn.
|
||||||
const SAME_FAILURES_STOP: usize = 3;
|
const SAME_FAILURES_STOP: usize = 3;
|
||||||
|
|
||||||
|
|
@ -2391,6 +2488,7 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc<
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
let tried_quick = quick.clone();
|
let tried_quick = quick.clone();
|
||||||
|
split_unfilled(&mut job.req.tools, &history);
|
||||||
let mut attempt = 0;
|
let mut attempt = 0;
|
||||||
let mut out = loop {
|
let mut out = loop {
|
||||||
// A replay step: no model.
|
// A replay step: no model.
|
||||||
|
|
@ -4265,6 +4363,84 @@ echo '<meta charset=utf-8><title>done</title>送出了' > done.html; (setsid pyt
|
||||||
assert_eq!(tools::unwrapped_args(r#"{"action":"read"}"#, props), None);
|
assert_eq!(tools::unwrapped_args(r#"{"action":"read"}"#, props), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_model_that_sent_the_one_tool_empty_gets_the_one_action_tools() {
|
||||||
|
let start = || {
|
||||||
|
let mut t = vec![crate::browser::tool(&serde_json::json!({"type": "string"}))];
|
||||||
|
t.extend(computer::specs_for(&["這台".to_string()], "這台", true));
|
||||||
|
t
|
||||||
|
};
|
||||||
|
let said = |name: &str, args: &str| Message { role: Role::Assistant, tool_calls: vec![ToolCall { id: "c".into(), name: name.into(), args: args.into(), status: ToolStatus::Done }], ..Default::default() };
|
||||||
|
let props = |tools: &[serde_json::Value], n: &str| -> Vec<String> {
|
||||||
|
let t = tools.iter().find(|t| t["name"] == n).unwrap_or_else(|| panic!("no {n}"));
|
||||||
|
t["parameters"]["properties"].as_object().unwrap().keys().cloned().collect()
|
||||||
|
};
|
||||||
|
// Arguments that got through, or no call at all: the list stays as it was.
|
||||||
|
let mut tools = start();
|
||||||
|
assert!(!split_unfilled(&mut tools, &[Message::user("hi"), said("browser", r#"{"action":"read"}"#), said("browser_open", "{}")]));
|
||||||
|
assert_eq!(tools.len(), 2);
|
||||||
|
// One empty `browser`: browser goes, its actions come, each with its own fields; computer stays.
|
||||||
|
assert!(split_unfilled(&mut tools, &[said("browser", "{}")]));
|
||||||
|
let names: Vec<&str> = tools.iter().filter_map(|t| t["name"].as_str()).collect();
|
||||||
|
assert!(!names.contains(&"browser") && names.contains(&"computer") && !names.contains(&"browser_fill_login"), "{names:?}");
|
||||||
|
for n in ["browser_open", "browser_read", "browser_click", "browser_type", "browser_press", "browser_wait", "browser_tabs", "browser_sent_log", "browser_eval"] {
|
||||||
|
assert!(names.contains(&n), "{n} in {names:?}");
|
||||||
|
}
|
||||||
|
assert!(tools.iter().filter(|t| t["name"] != "computer").all(|t| t["parameters"]["required"].is_null()), "nothing required: an empty call still runs and says what it lacks");
|
||||||
|
let click = props(&tools, "browser_click");
|
||||||
|
assert!(["ref", "text", "double", "button", "profile"].iter().all(|k| click.contains(&k.to_string())) && !click.contains(&"action".to_string()) && !click.contains(&"script".to_string()), "{click:?}");
|
||||||
|
assert!(props(&tools, "browser_open").contains(&"url".to_string()));
|
||||||
|
assert!(props(&tools, "browser_press").contains(&"key".to_string()));
|
||||||
|
assert!(props(&tools, "browser_wait").iter().any(|k| k == "after_send"));
|
||||||
|
let tabs = tools.iter().find(|t| t["name"] == "browser_tabs").unwrap();
|
||||||
|
assert_eq!(tabs["parameters"]["properties"]["action"]["enum"], serde_json::json!(["list", "switch", "new", "close"]));
|
||||||
|
assert!(tools.iter().find(|t| t["name"] == "browser_press").unwrap()["description"].as_str().unwrap().starts_with("press {key}"));
|
||||||
|
// Every split tool runs as what the one tool's action would have run as.
|
||||||
|
for t in &tools {
|
||||||
|
let n = t["name"].as_str().unwrap();
|
||||||
|
assert!(n == "computer" || crate::browser::action_tool(n.trim_start_matches("browser_")).is_some() || n == crate::browser::SENT_LOG, "{n}");
|
||||||
|
}
|
||||||
|
// Again: nothing more to change.
|
||||||
|
assert!(!split_unfilled(&mut tools, &[said("browser", "{}")]));
|
||||||
|
// An empty `computer` too: its actions, each with the computer field and its own.
|
||||||
|
assert!(split_unfilled(&mut tools, &[said("computer", "")]));
|
||||||
|
let names: Vec<&str> = tools.iter().filter_map(|t| t["name"].as_str()).collect();
|
||||||
|
assert!(!names.contains(&"computer") && !names.contains(&"computer_use_batch") && names.contains(&"computer_use_screenshot") && names.contains(&"computer_use_check_permissions"), "{names:?}");
|
||||||
|
let typing = props(&tools, "computer_use_typing");
|
||||||
|
assert!(["value", "name", "append", "submit", "computer"].iter().all(|k| typing.contains(&k.to_string())) && !typing.contains(&"path".to_string()), "{typing:?}");
|
||||||
|
assert!(props(&tools, "computer_use_drag").contains(&"path".to_string()));
|
||||||
|
let intent = props(&tools, "computer_use_intent");
|
||||||
|
assert!(intent.contains(&"intent_name".to_string()) && intent.contains(&"intent_arg".to_string()), "{intent:?}");
|
||||||
|
let shot = tools.iter().find(|t| t["name"] == "computer_use_screenshot").unwrap()["description"].as_str().unwrap().to_string();
|
||||||
|
assert!(shot.starts_with("screenshot(") && shot.contains("優先 ref/name"), "the one tool's words for every action: {shot}");
|
||||||
|
let moving = props(&tools, "computer_use_mouse_move");
|
||||||
|
assert!(["x", "y", "ref", "name", "computer"].iter().all(|k| moving.contains(&k.to_string())), "{moving:?}");
|
||||||
|
let click = props(&tools, "computer_use_click");
|
||||||
|
assert!(["ref", "name", "x", "y", "button", "count", "modifier_keys"].iter().all(|k| click.contains(&k.to_string())), "{click:?}");
|
||||||
|
assert!(props(&tools, "computer_use_typing").contains(&"ref".to_string()));
|
||||||
|
let open = tools.iter().find(|t| t["name"] == "browser_open").unwrap()["description"].as_str().unwrap().to_string();
|
||||||
|
assert!(open.starts_with("open {url}") && open.contains("Never act on a page from memory"), "{open}");
|
||||||
|
let t = bad_action(computer::TOOL, "{}");
|
||||||
|
assert!(t.contains("參數是空的") && t.contains("computer_use_click") && t.contains("從下一步起"), "{t}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Through a real turn: the model sends `browser` empty; the next request carries the
|
||||||
|
/// one-action tools and no `browser`, and the one before still had it.
|
||||||
|
#[test]
|
||||||
|
fn after_an_empty_browser_call_the_next_step_offers_the_one_action_tools() {
|
||||||
|
let (_, results, seen) = browser_turn(vec![sse_call("c1", "browser", serde_json::json!({}))], false, None, &[], ApprovalAnswer::Reject);
|
||||||
|
assert!(results[0].contains("參數是空的"), "{results:?}");
|
||||||
|
let names = |raw: &str| -> Vec<String> {
|
||||||
|
let body = raw.split("\r\n\r\n").last().unwrap_or(raw);
|
||||||
|
let v: serde_json::Value = serde_json::from_str(body).unwrap_or_else(|_| serde_json::from_str(&raw[raw.find('{').unwrap()..]).unwrap());
|
||||||
|
v["tools"].as_array().unwrap().iter().map(|t| t["function"]["name"].as_str().unwrap_or("").to_string()).collect()
|
||||||
|
};
|
||||||
|
assert_eq!(seen.len(), 2);
|
||||||
|
let (first, next) = (names(&seen[0]), names(&seen[1]));
|
||||||
|
assert!(first.contains(&"browser".to_string()) && !first.contains(&"browser_click".to_string()), "{first:?}");
|
||||||
|
assert!(!next.contains(&"browser".to_string()) && next.contains(&"browser_click".to_string()) && next.contains(&"browser_open".to_string()), "{next:?}");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_call_without_a_known_action_is_told_what_the_tool_takes() {
|
fn a_call_without_a_known_action_is_told_what_the_tool_takes() {
|
||||||
let t = bad_action(crate::browser::TOOL, r#"{"key":"ctrl+v"}"#);
|
let t = bad_action(crate::browser::TOOL, r#"{"key":"ctrl+v"}"#);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue