Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 63 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ console_error_panic_hook = "0.1"
# llm-web so a clean clone always resolves the same API. No default
# features: the agent crate turns on `threads` natively and agent-wasm
# turns on `web`.
lean = { git = "https://github.com/idle-intelligence/llm-web", rev = "1fce23d866c23fb6f3635abb51db52c50ff87808", default-features = false }
lean-chat = { git = "https://github.com/idle-intelligence/llm-web", rev = "1fce23d866c23fb6f3635abb51db52c50ff87808" }
lean = { git = "https://github.com/idle-intelligence/llm-web", rev = "6daf322d8759f570b7bd01363bbe0c7ab6cc21b3", default-features = false }
lean-chat = { git = "https://github.com/idle-intelligence/llm-web", rev = "6daf322d8759f570b7bd01363bbe0c7ab6cc21b3" }

[profile.release]
lto = true
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ cargo run -p agent --example agent_cli --release -- \
--utterance "pause the kitchen"
```

The eval set, as a markdown table on stdout (`AGENT_EVAL_MAX_CTX` sets the context size in tokens, default 4096; `AGENT_EVAL_DATE` the date in the table's title):
The eval set, as a markdown table on stdout. `--fixture-set` picks the Sonos set (default) or the small two-step tool-chaining set (`crates/agent/fixtures/two-step`); `--thinking template|off` and `--think-cap N` control Qwen3's thinking block; `--only s01,m02` runs some cases:

```sh
LEAN_GGUF_QWEN25_3B=models/Qwen2.5-3B-Instruct-GGUF/qwen2.5-3b-instruct-q4_0.gguf \
LEAN_TOKENIZER_DIR_QWEN25_3B=models/Qwen2.5-3B-Instruct \
cargo run -p agent --example agent_eval --release
cargo run -p agent --example agent_eval --release -- \
--model models/Qwen3-1.7B-GGUF/Qwen3-1.7B-Q8_0.gguf \
--tokenizer-dir models/Qwen3-1.7B \
--model-label Qwen3-1.7B-Q8_0 --max-new-tokens 1024
```

Both pick the backend by capability: the GPU when a wgpu adapter is available, otherwise the CPU forward pass on every core. Each step reuses the KV cache of the previous one for the prompt prefix they share, so the system prompt and the tools are prefilled once per turn.
Expand Down
26 changes: 25 additions & 1 deletion crates/agent-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::cell::RefCell;

use wasm_bindgen::prelude::*;

use agent::agent::{AbortFlag, Agent, PendingToolCall, StepOutcome};
use agent::agent::{AbortFlag, Agent, PendingToolCall, StepOutcome, Thinking};
use agent::lean_generator::LeanGenerator;
use anyhow::Result;
use lean::{Backend, GgufSource, LoadOptions, TokenizerSource};
Expand Down Expand Up @@ -122,6 +122,30 @@ impl AgentJs {
Ok(())
}

/// With `off` true, asks a Qwen3-style model not to think (the prompt
/// ends with the empty thinking block); false renders as the model's
/// template does by default.
#[wasm_bindgen(js_name = setThinkingOff)]
pub fn set_thinking_off(&self, off: bool) -> Result<(), JsError> {
let mut agent = self.take()?;
agent.set_thinking(if off {
Thinking::Off
} else {
Thinking::TemplateDefault
});
self.put(agent);
Ok(())
}

/// Caps a thinking block at `cap` tokens, 0 for no cap.
#[wasm_bindgen(js_name = setThinkCap)]
pub fn set_think_cap(&self, cap: u32) -> Result<(), JsError> {
let mut agent = self.take()?;
agent.set_think_cap((cap > 0).then_some(cap as usize));
self.put(agent);
Ok(())
}

/// A handle whose `abort()` stops the running step (it resolves to an
/// `aborted` outcome). Take it before calling `start`; it stays valid
/// for every later turn.
Expand Down
Loading
Loading