diff --git a/Cargo.toml b/Cargo.toml index e8fe9cf0d..31688c647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ libraries = [{ git = "https://github.com/cppalliance/dylints", rev = "982b297ede # differs from this workspace's. [workspace.metadata.workshop] git = "https://github.com/cppalliance/runvil-workshop" -rev = "15e879c40c8d96a487c4874e808a9e8957f9d8f6" +rev = "0381a776f37240bf900a035d572774af5054b705" [workspace.lints.rust] unsafe_code = "deny" diff --git a/plan/2026-12-02-1-tool-call-model-and-origin.plan.md b/plan/2026-12-02-1-tool-call-model-and-origin.plan.md new file mode 100644 index 000000000..c4de41fe8 --- /dev/null +++ b/plan/2026-12-02-1-tool-call-model-and-origin.plan.md @@ -0,0 +1,29 @@ +--- +name: Model and Origin on Tool Calls +overview: Pass the call's origin (caller, section, entry) and the requesting round's full ModelInfo to every tool call across the Engine, Harness, and C Plugin contract (version 0.8), and update the documentation and downstream pins across all repositories. +todos: + - id: wave4-runvil-docs-classroom-0-8 + content: "Wave 4: runvil pin of Workshop, runvil-docs tool call model/origin description, runvil-classroom tutorial update to 0.8; push to origin, open PRs, monitor GitHub Actions and CodeRabbit comments, address findings, merge to upstream in order, and push classroom direct" + status: pending +isProject: false +--- + +# Pass the Model and Origin to Tool Calls (Contract 0.8) + +## The idea in plain terms + +Today a render (`RV_PACK_RENDER` and `RenderContext`) learns the section entry (`sys.id`) and the full `ModelInfo` (`server`, `name`, `description`, `context`, `thinking`, and `provider`) of the section's first model round, while a tool call learns less: + +- In the Engine and Harness (`Effect::ToolCall` and `ToolContext`), a tool call receives `ToolCallOrigin` (`section`, `caller`, `entry`, and `model` as a bare model-name string), without the rest of the round's `ModelInfo`. +- Across the C Plugin contract (`RvToolCallArgs` and `runvil_plugin_sdk::ToolCall`), a tool call receives only `tool`, `arguments`, `resources`, the file functions, and `waker`. A contract Plugin cannot tell whether a script or a model called it, which section or entry made the call, or which model requested the call. + +This change gives every tool call both the call's origin and, when a model round requested the call, that round's full model facts: + +- **In the Engine (`runvil-lua` and `runvil-runtime`):** `MessageList::commit` records the round's `ModelInfo` (`binding.render_info()`) instead of only `binding.id().name()`. When a model round requests a tool call (`CallSite::Model` or `CallSite::Batch`), `prepare_catalog_call` attaches `Some(ModelInfo)` to `Effect::ToolCall` and sets `origin.model` to the model's name as before. When Lua calls `tools.call` directly (`CallSite::Script`), `model` is `None`. +- **In the Harness (`runvil-plugin` and `harness-runner`):** `ToolContext<'a>` gains `model: Option<&'a ModelInfo>` and `ToolContext::model(&self) -> Option<&'a ModelInfo>`, populated by `RunPacks::call`. +- **In the C contract (`runvil-plugin-sys` v0.8):** `RvToolCallArgs` gains `caller: RvCaller` (`RV_CALLER_MODEL = 0`, `RV_CALLER_SCRIPT = 1`, placed in the 4-byte `reserved` slot after `size`) and three `RvStr` fields at the end: `section`, `entry` (empty when unset), and `model` (the same JSON object shape as `RvPackRenderArgs.model` when a model round asked for the call, and empty for a script call). Every step of one call gets the same values. +- **In the SDK (`runvil-plugin-sdk` v0.8):** `ToolCall<'a>` gains `caller(&self) -> Caller`, `section(&self) -> &'a str`, `entry(&self) -> Option<&'a str>`, and `model(&self) -> Option<&'a str>`, backed by copies in `CallState` taken on the first step. The fake Host (`testing`) defaults a call to `Caller::Model`, `section: "Test"`, `entry: Some("0.0")`, and `model: None`, and adds builder setters on `testing::Call` so existing Plugin test suites compile unchanged while new tests can exercise every field. + +## Wave 4: `runvil`, `runvil-docs`, and `runvil-classroom` + +- **`runvil`:** Plan record commit + `Pin Workshop at ` in `Cargo.toml`, verified, PR, and merged on green CI.