pub struct ToolCallContext { /* private fields */ }Expand description
Per-session context the host injects into plugin tool arguments under
rpi_plugin_sdk::HOST_CONTEXT_KEY.
A built-in tool gets an ExecutionToolContext from the harness and can
resolve the working directory from it; a plugin tool has no such channel.
Without this, a plugin that needs project (or session) identity has to ask
the model for it — and the model does not know the session id, while any
cwd it guesses is a silent way to split one store into two.
It is filled in two steps because the CLI assembles the tool set before the
session it belongs to exists: ToolCallContext::new carries the cwd, and
ToolCallContext::set_session_id completes it once the session does.
Every adapter for one session shares one instance (Arc inside), so the late
write is visible to all of them — including across an extension reload, which
rebuilds the adapters from the same context.
Unknown fields are absent, not empty strings: a consumer should prefer a
project-scoped fallback when ToolCallContext::session_id is None.
Implementations§
Source§impl ToolCallContext
impl ToolCallContext
Sourcepub fn new(cwd: impl Into<String>) -> Self
pub fn new(cwd: impl Into<String>) -> Self
A context that knows the project directory but not yet the session id.
An empty cwd is treated as unknown.
Sourcepub fn set_session_id(&self, session_id: impl Into<String>)
pub fn set_session_id(&self, session_id: impl Into<String>)
Record the session id once the session exists. Safe to call again (a reload re-derives it); a poisoned lock is ignored rather than panicking inside a tool call.
Sourcepub fn cwd(&self) -> Option<String>
pub fn cwd(&self) -> Option<String>
The project directory the session was launched in, when known.
Sourcepub fn session_id(&self) -> Option<String>
pub fn session_id(&self) -> Option<String>
The session id, when the session has one and the host has recorded it.