test: Agent-Lauf gegen Ollama auf srv04 mit qwen3:0.6b

Ignorierter Test ollama_lauf_schreibt_datei_und_beendet bestanden:
Modell schreibt out.txt und ruft done auf (1 Schritt, 496/219 Tokens, 20 s
inkl. Modell-Ladezeit).

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-06 19:31:50 +01:00
parent a02f57b469
commit e69f3be35b
2 changed files with 31 additions and 1 deletions

View File

@ -767,6 +767,36 @@ mod tests {
sb.remove().unwrap();
}
/// Echter Modelllauf gegen Ollama und Podman. Braucht laufenden Ollama-Dienst
/// mit dem Modell und ein Image: `CB_OLLAMA_URL=http://host:11434 CB_OLLAMA_MODEL=qwen3:0.6b
/// CB_TEST_IMAGE=cb-python:latest cargo test ollama_lauf -- --ignored`.
#[test]
#[ignore]
fn ollama_lauf_schreibt_datei_und_beendet() {
use crate::sandbox::{container_name, Limits};
let url = std::env::var("CB_OLLAMA_URL").expect("CB_OLLAMA_URL setzen");
let model = std::env::var("CB_OLLAMA_MODEL").expect("CB_OLLAMA_MODEL setzen");
let image = std::env::var("CB_TEST_IMAGE").expect("CB_TEST_IMAGE setzen");
let name = container_name(&format!("ollama-{}", std::process::id()));
let sb = Sandbox::start("podman", &name, &image, &Limits::default(), None).expect("Start");
let ws = SandboxWorkspace { sandbox: &sb };
let client = OllamaClient::new(&url, &model).unwrap();
let lim = AgentLimits { max_steps: 10, timeout: Duration::from_secs(600) };
let prompt = "Erstelle die Datei out.txt mit dem Inhalt hallo (ohne Zeilenumbruch). \
Rufe danach das Werkzeug done auf.";
let out = run_agent(&client, &ws, prompt, &lim);
eprintln!("Lauf: {:?} Schritte={} Tokens={}/{} Dauer={}ms", out.class, out.steps,
out.prompt_tokens, out.completion_tokens, out.duration_ms);
for m in &out.transcript {
eprintln!("[{}] {} {:?}", m.role, m.content.chars().take(200).collect::<String>(), m.tool_calls);
}
let content = ws.read_file("/work/out.txt").unwrap_or_default();
sb.remove().unwrap();
assert_eq!(out.class, ErrorClass::Ok, "Lauf endete mit {:?}", out.class);
assert_eq!(content.trim(), "hallo", "out.txt: {content:?}");
}
#[test]
fn sh_quote_maskiert_apostrophe() {
assert_eq!(sh_quote("a'b"), "'a'\\''b'");