pub struct Action {
pub id: String,
pub name: String,
pub args: Value,
pub identity: String,
pub format: ActionFormat,
}Expand description
One unit of “something the model asked the runtime to do”.
Replaces the bare (id, name, args) triple as the kernel currency; the
triple stays internal to the tool-call backend’s executor. identity is
the counting fingerprint assigned at parse time (tool = name + canonical
args, code = canonical code) so limit middlewares count by semantic unit.
Fields§
§id: StringPairing id (tool_call_id / cell id).
name: StringTool name, or the action kind label for non-tool backends.
args: ValueAction arguments. Tool calls carry the provider envelope’s argument
text byte-for-byte as a JSON string (Value::String) — it may be
truncated non-JSON, and the history protocol must echo it exactly
(sanitized downstream). Structured backends use an object, e.g.
{"code": …} for cells. Use Action::raw_args to read the text.
identity: StringCounting fingerprint computed at parse time by the backend.
format: ActionFormatBackend format label.
Implementations§
Source§impl Action
impl Action
Sourcepub fn from_tool_call(
id: impl Into<String>,
name: impl Into<String>,
args: impl Into<String>,
) -> Self
pub fn from_tool_call( id: impl Into<String>, name: impl Into<String>, args: impl Into<String>, ) -> Self
Build a tool-call action from the provider envelope. The argument text is
kept byte-for-byte (Value::String); identity is the counting
fingerprint (Action::tool_call_identity).
Sourcepub fn tool_call_identity(name: &str, args: &str) -> String
pub fn tool_call_identity(name: &str, args: &str) -> String
Counting fingerprint for a tool call: name + canonical (key-sorted) args. The single source of the identity format — limit middlewares count by this same unit.
Sourcepub fn from_code_cell(
id: impl Into<String>,
intent: impl Into<String>,
code: impl Into<String>,
) -> Self
pub fn from_code_cell( id: impl Into<String>, intent: impl Into<String>, code: impl Into<String>, ) -> Self
Build a CodeAct cell action (intent + code). The code is the counting
fingerprint verbatim (design D5: 代码=canonical code — a cell has no
arguments to canonicalize, the source text is the semantic unit).
args carries the engine’s own block shape {"intent", "code"} — one
vocabulary with the codexec host protocol.