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
12 changes: 6 additions & 6 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 @@ -7,9 +7,9 @@ edition = "2024"
license = "BSL-1.0"

[workspace.dependencies]
# The Plugin SDK at contract 0.7, pinned to a commit. A Host loads this
# The Plugin SDK at contract 0.8, pinned to a commit. A Host loads this
# Plugin only when its Harness speaks the same contract version.
runvil-plugin-sdk = { version = "0.7.0", git = "https://github.com/cppalliance/runvil-plugin-api", rev = "450afa2d3b0d70c3f2a4a9f89f5938da5ef0fb78" }
runvil-plugin-sdk = { version = "0.8.0", git = "https://github.com/cppalliance/runvil-plugin-api", rev = "f2d42cc41b0f28f81ac73193f21c2eacfafc11d9" }
# The HTTP client, over rustls with one crypto backend, aws-lc-rs. reqwest
# 0.13 has no feature that picks `ring`, and CI checks that `ring` stays
# out of the workspace's normal dependency graph. Root certificates come
Expand Down
32 changes: 32 additions & 0 deletions plan/2026-12-02-1-tool-call-model-and-origin.plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
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: plugins-pin-0-8
content: "runvil-plugin-std, runvil-plugin-bashkit, runvil-plugin-web: testable commits for plan copies, Pin SDK 0.8, and std README update"
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 2: `runvil-harness` and the three Plugin repositories

- **The three Plugin repositories (in parallel with `runvil-harness` after Wave 1 merges):**
- `runvil-plugin-std`: `Pin SDK 0.8` in `Cargo.toml`, `Cargo.lock`, and `README.md`.
- `runvil-plugin-bashkit` and `runvil-plugin-web`: plan record commit + `Pin SDK 0.8` in `Cargo.toml` and `Cargo.lock`.
- Verify each with a fresh verifier subagent, push, open PRs, wait for green CI, and merge Wave 2.
Loading