pub struct Llm {
pub proc: Option<Arc<DaggerSessionProc>>,
pub selection: Selection,
pub graphql_client: DynGraphQLClient,
}Fields§
§proc: Option<Arc<DaggerSessionProc>>§selection: Selection§graphql_client: DynGraphQLClientImplementations§
Source§impl Llm
impl Llm
Sourcepub async fn id(&self) -> Result<Id, DaggerError>
pub async fn id(&self) -> Result<Id, DaggerError>
A unique identifier for this LLM.
Sourcepub fn compose(&self, expertise: Vec<Id>) -> Llm
pub fn compose(&self, expertise: Vec<Id>) -> Llm
Run expertise in list order, passing this conversation through each function. Retain existing contributions.
§Arguments
expertise- The expertise to run. Each reference retains its source workspace.
Sourcepub fn recompose(&self, expertise: Vec<Id>) -> Llm
pub fn recompose(&self, expertise: Vec<Id>) -> Llm
Run expertise in list order, replacing their modules’ contributions and preserving compatible tool state. Clear each selected module’s contributions once before execution. Retain unowned contributions and contributions from other modules. Keep this LLM’s workspace. A change to a tool binding’s version resets its state. Removed bindings, changed identities, and incompatible state are errors.
§Arguments
expertise- The expertise to run. Each reference retains its source workspace.
Sourcepub async fn model(&self) -> Result<String, DaggerError>
pub async fn model(&self) -> Result<String, DaggerError>
The model the conversation is running against, after resolving any configured default.
Sourcepub async fn provider(&self) -> Result<String, DaggerError>
pub async fn provider(&self) -> Result<String, DaggerError>
The provider serving the model, e.g. “anthropic”, “openai”, “google”, or “local”.
Sourcepub async fn context_window(&self) -> Result<isize, DaggerError>
pub async fn context_window(&self) -> Result<isize, DaggerError>
The model’s total context window in tokens, or null if unknown (e.g. a local or uncatalogued model).
Sourcepub async fn messages(&self) -> Result<Vec<LlmMessage>, DaggerError>
pub async fn messages(&self) -> Result<Vec<LlmMessage>, DaggerError>
The full message history, as structured messages.
Sourcepub async fn transcript(&self) -> Result<String, DaggerError>
pub async fn transcript(&self) -> Result<String, DaggerError>
The message history rendered as a plain-text transcript, suitable for feeding back to an LLM (e.g. for summarization).
Sourcepub fn without_message_history(&self) -> Llm
pub fn without_message_history(&self) -> Llm
Clear the message history, keeping only the system prompts.
Sourcepub fn without_system_prompts(&self) -> Llm
pub fn without_system_prompts(&self) -> Llm
Clear the user-added system prompts, keeping only the default system prompt.
Sourcepub async fn last_reply(&self) -> Result<String, DaggerError>
pub async fn last_reply(&self) -> Result<String, DaggerError>
The text of the model’s most recent reply.
Sourcepub fn with_workspace(&self, workspace: impl IntoID<Id>) -> Llm
pub fn with_workspace(&self, workspace: impl IntoID<Id>) -> Llm
Bind the LLM to a workspace, exposing its modules as tools exactly as the Dagger CLI would serve them for that workspace.
§Arguments
workspace- The workspace to work in.
Sourcepub fn artifacts(&self) -> Artifacts
pub fn artifacts(&self) -> Artifacts
Discover every artifact this conversation can address, as one selection, without evaluating their values. Tool objects bound with withTools contribute their modules’ artifacts, rooted at their current values: evaluating one reads the live state of the bound tools, not a fresh construction. If a module’s main object is bound, only its tree is included; otherwise each bound object of that module contributes its own tree. Addresses start with the module name. These artifacts have no workspace of their own: they evaluate in the LLM’s bound workspace, if any, whoever evaluates them. The workspace part is the artifacts of the workspace bound with withWorkspace, as returned by Workspace.artifacts; an LLM with no bound workspace has none. A workspace module with the same name as a module with bound tool objects is omitted: the bound tools shadow it. Unless they are only a plain construction of the module, which has no state of its own: then the workspace module’s artifacts are kept instead. Tool arguments that take an address resolve it here: a DAG address to one object, or, for Artifacts and Artifact arguments, a selection filtered like filterUri.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn artifacts_opts<'a>(&self, opts: LlmArtifactsOpts<'a>) -> Artifacts
pub fn artifacts_opts<'a>(&self, opts: LlmArtifactsOpts<'a>) -> Artifacts
Discover every artifact this conversation can address, as one selection, without evaluating their values. Tool objects bound with withTools contribute their modules’ artifacts, rooted at their current values: evaluating one reads the live state of the bound tools, not a fresh construction. If a module’s main object is bound, only its tree is included; otherwise each bound object of that module contributes its own tree. Addresses start with the module name. These artifacts have no workspace of their own: they evaluate in the LLM’s bound workspace, if any, whoever evaluates them. The workspace part is the artifacts of the workspace bound with withWorkspace, as returned by Workspace.artifacts; an LLM with no bound workspace has none. A workspace module with the same name as a module with bound tool objects is omitted: the bound tools shadow it. Unless they are only a plain construction of the module, which has no state of its own: then the workspace module’s artifacts are kept instead. Tool arguments that take an address resolve it here: a DAG address to one object, or, for Artifacts and Artifact arguments, a selection filtered like filterUri.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_model(&self, model: impl Into<String>) -> Llm
pub fn with_model(&self, model: impl Into<String>) -> Llm
Change the model for the rest of the conversation. The message history is preserved; the new model takes effect on the next step.
§Arguments
model- The model to use, e.g. “claude-sonnet-4-5” or “gpt-5.4”.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_model_opts<'a>(
&self,
model: impl Into<String>,
opts: LlmWithModelOpts<'a>,
) -> Llm
pub fn with_model_opts<'a>( &self, model: impl Into<String>, opts: LlmWithModelOpts<'a>, ) -> Llm
Change the model for the rest of the conversation. The message history is preserved; the new model takes effect on the next step.
§Arguments
model- The model to use, e.g. “claude-sonnet-4-5” or “gpt-5.4”.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_small_model(&self) -> Llm
pub fn with_small_model(&self) -> Llm
Switch to the configured small model for the current provider, or that provider’s recommended default. The message history is preserved; unknown providers without a small-model configuration keep their current model.
Sourcepub async fn reasoning_effort(&self) -> Result<String, DaggerError>
pub async fn reasoning_effort(&self) -> Result<String, DaggerError>
The reasoning effort in use, e.g. “low”, “medium”, or “high”. Empty or “none” when reasoning is disabled.
Sourcepub fn with_reasoning_effort(&self, effort: impl Into<String>) -> Llm
pub fn with_reasoning_effort(&self, effort: impl Into<String>) -> Llm
Change the reasoning effort for the rest of the conversation, overriding any configured default. The message history is preserved; the new effort takes effect on the next step.
§Arguments
effort- The reasoning effort, e.g. “low”, “medium”, or “high”; “none” disables reasoning. Supported levels are model-specific — some models also accept e.g. “minimal”, “xhigh”, or “max”.
Sourcepub fn with_prompt(&self, prompt: impl Into<String>) -> Llm
pub fn with_prompt(&self, prompt: impl Into<String>) -> Llm
Queue a user prompt, to be sent to the model on the next step or loop.
§Arguments
prompt- The prompt to sendopt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_prompt_opts(
&self,
prompt: impl Into<String>,
opts: LlmWithPromptOpts,
) -> Llm
pub fn with_prompt_opts( &self, prompt: impl Into<String>, opts: LlmWithPromptOpts, ) -> Llm
Queue a user prompt, to be sent to the model on the next step or loop.
§Arguments
prompt- The prompt to sendopt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_content(&self, content: Vec<LlmContentBlockInput>) -> Llm
pub fn with_content(&self, content: Vec<LlmContentBlockInput>) -> Llm
Queue one user message containing ordered text and media blocks.
§Arguments
content- The ordered message content.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_content_opts(
&self,
content: Vec<LlmContentBlockInput>,
opts: LlmWithContentOpts,
) -> Llm
pub fn with_content_opts( &self, content: Vec<LlmContentBlockInput>, opts: LlmWithContentOpts, ) -> Llm
Queue one user message containing ordered text and media blocks.
§Arguments
content- The ordered message content.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_content_file(&self, file: impl IntoID<Id>) -> Llm
pub fn with_content_file(&self, file: impl IntoID<Id>) -> Llm
Queue an image, audio, or PDF file as one user message. Media bytes are stored in the conversation.
§Arguments
file- The media file.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_content_file_opts<'a>(
&self,
file: impl IntoID<Id>,
opts: LlmWithContentFileOpts<'a>,
) -> Llm
pub fn with_content_file_opts<'a>( &self, file: impl IntoID<Id>, opts: LlmWithContentFileOpts<'a>, ) -> Llm
Queue an image, audio, or PDF file as one user message. Media bytes are stored in the conversation.
§Arguments
file- The media file.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_prompt_file(&self, file: impl IntoID<Id>) -> Llm
pub fn with_prompt_file(&self, file: impl IntoID<Id>) -> Llm
Queue a file’s contents as a user prompt, like withPrompt.
§Arguments
file- The file to read the prompt from
Sourcepub fn with_system_prompt(&self, prompt: impl Into<String>) -> Llm
pub fn with_system_prompt(&self, prompt: impl Into<String>) -> Llm
Add a system prompt, instructing the model across the whole conversation.
§Arguments
prompt- The system prompt to send
Sourcepub fn with_response(&self, content: Vec<LlmContentBlockInput>) -> Llm
pub fn with_response(&self, content: Vec<LlmContentBlockInput>) -> Llm
Append an assistant response to the message history without calling the model, e.g. to reconstruct a conversation from another source.
§Arguments
content- The response contentopt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_response_opts(
&self,
content: Vec<LlmContentBlockInput>,
opts: LlmWithResponseOpts,
) -> Llm
pub fn with_response_opts( &self, content: Vec<LlmContentBlockInput>, opts: LlmWithResponseOpts, ) -> Llm
Append an assistant response to the message history without calling the model, e.g. to reconstruct a conversation from another source.
§Arguments
content- The response contentopt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_tool_result(
&self,
call_id: impl Into<String>,
content: impl Into<String>,
errored: bool,
) -> Llm
pub fn with_tool_result( &self, call_id: impl Into<String>, content: impl Into<String>, errored: bool, ) -> Llm
Append the result of a tool call to the message history.
§Arguments
call_id- The ID of the tool call this result responds tocontent- Text returned by the tool, placed before blockserrored- Whether the tool call resulted in an erroropt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_tool_result_opts(
&self,
call_id: impl Into<String>,
content: impl Into<String>,
errored: bool,
opts: LlmWithToolResultOpts,
) -> Llm
pub fn with_tool_result_opts( &self, call_id: impl Into<String>, content: impl Into<String>, errored: bool, opts: LlmWithToolResultOpts, ) -> Llm
Append the result of a tool call to the message history.
§Arguments
call_id- The ID of the tool call this result responds tocontent- Text returned by the tool, placed before blockserrored- Whether the tool call resulted in an erroropt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_tools(&self, object: impl IntoID<Id>) -> Llm
pub fn with_tools(&self, object: impl IntoID<Id>) -> Llm
Expose an object’s methods as tools. Every eligible method of the bound object becomes a tool; a tool that returns this object’s own type replaces it as the new state. Repeatable to bind several objects.
§Arguments
object- The object whose methods become tools.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_tools_opts<'a>(
&self,
object: impl IntoID<Id>,
opts: LlmWithToolsOpts<'a>,
) -> Llm
pub fn with_tools_opts<'a>( &self, object: impl IntoID<Id>, opts: LlmWithToolsOpts<'a>, ) -> Llm
Expose an object’s methods as tools. Every eligible method of the bound object becomes a tool; a tool that returns this object’s own type replaces it as the new state. Repeatable to bind several objects.
§Arguments
object- The object whose methods become tools.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_default_system_prompt(&self) -> Llm
pub fn without_default_system_prompt(&self) -> Llm
Disable the default system prompt
Sourcepub fn with_mcp_server(
&self,
name: impl Into<String>,
service: impl IntoID<Id>,
) -> Llm
pub fn with_mcp_server( &self, name: impl Into<String>, service: impl IntoID<Id>, ) -> Llm
Add an external MCP server to the LLM
§Arguments
name- The name of the MCP serverservice- The MCP service to run and communicate with over stdio
Sourcepub fn with_skills(&self, directory: impl IntoID<Id>) -> Llm
pub fn with_skills(&self, directory: impl IntoID<Id>) -> Llm
Install skills from a directory, adding them to the skills the model discovers with ListSkills and reads with ReadSkill. Each skill is a directory containing a SKILL.md with name and description frontmatter, discovered anywhere in the tree. Installed skills take precedence over skills discovered in the workspace, but cannot shadow the engine’s built-in skills.
§Arguments
directory- A directory containing skills, each a subdirectory holding a SKILL.md.
Sourcepub async fn skills(&self) -> Result<Vec<LlmSkill>, DaggerError>
pub async fn skills(&self) -> Result<Vec<LlmSkill>, DaggerError>
The skills visible to the model, exactly as the ListSkills tool serves them: engine-embedded skills, skills installed with withSkills, and skills discovered in the workspace.
Sourcepub async fn sync(&self) -> Result<Llm, DaggerError>
pub async fn sync(&self) -> Result<Llm, DaggerError>
Force evaluation of the conversation’s pending operations (prompts, steps, loops) in the engine.
Sourcepub fn loop(&self) -> Llm
pub fn loop(&self) -> Llm
Send the queued prompt and step the model against the available tools, until it ends its turn: a reply with no tool calls and nothing left queued.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn loop_opts(&self, opts: LlmLoopOpts) -> Llm
pub fn loop_opts(&self, opts: LlmLoopOpts) -> Llm
Send the queued prompt and step the model against the available tools, until it ends its turn: a reply with no tool calls and nothing left queued.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn step(&self) -> Llm
pub fn step(&self) -> Llm
Advance the conversation by a single step: send the queued prompt or tool results to the model, evaluate any tool calls it makes, and queue their results. Use loop to step until the model ends its turn.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn step_opts(&self, opts: LlmStepOpts) -> Llm
pub fn step_opts(&self, opts: LlmStepOpts) -> Llm
Advance the conversation by a single step: send the queued prompt or tool results to the model, evaluate any tool calls it makes, and queue their results. Use loop to step until the model ends its turn.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn spawn(&self) -> Result<Agent, DaggerError>
pub async fn spawn(&self) -> Result<Agent, DaggerError>
Spawn the conversation as an agent: a startable, addressable evaluation loop seeded with this conversation’s state, tools, and workspace. Every spawn mints a unique agent instance — two spawns of an identical conversation are two distinct agents, like two calls to a process spawn. The result is pinned to the instance (via the agent lookup field), so re-loading its ID re-addresses the same agent from any request in the session. The loop is not started: the agent spends nothing until it is prompted or resumed, and any input pending on the conversation is stepped then. With a handle, spawn restores an instance instead of minting one: this conversation becomes the committed history of the agent that handle names, so prompting it continues where it left off — rebuild a conversation’s ID from a trace, load it, and spawn it under the handle it belonged to. Fails if that instance already has a runtime entry in this session: a restore must happen before anything else addresses the instance, since by then it may have stepped.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn spawn_opts<'a>(
&self,
opts: LlmSpawnOpts<'a>,
) -> Result<Agent, DaggerError>
pub async fn spawn_opts<'a>( &self, opts: LlmSpawnOpts<'a>, ) -> Result<Agent, DaggerError>
Spawn the conversation as an agent: a startable, addressable evaluation loop seeded with this conversation’s state, tools, and workspace. Every spawn mints a unique agent instance — two spawns of an identical conversation are two distinct agents, like two calls to a process spawn. The result is pinned to the instance (via the agent lookup field), so re-loading its ID re-addresses the same agent from any request in the session. The loop is not started: the agent spends nothing until it is prompted or resumed, and any input pending on the conversation is stepped then. With a handle, spawn restores an instance instead of minting one: this conversation becomes the committed history of the agent that handle names, so prompting it continues where it left off — rebuild a conversation’s ID from a trace, load it, and spawn it under the handle it belonged to. Fails if that instance already has a runtime entry in this session: a restore must happen before anything else addresses the instance, since by then it may have stepped.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn agent(&self, handle: impl Into<String>, name: impl Into<String>) -> Agent
pub fn agent(&self, handle: impl Into<String>, name: impl Into<String>) -> Agent
Reconstruct a spawned agent from its runtime handle. This is the lookup spawn pins its result’s identity through: the returned handle’s ID is an honest, replayable chain denoting the one instance the spawn minted. It never creates an instance itself.
§Arguments
handle- The opaque runtime handle minted by the spawn that created the agent.name- The agent’s display name, as recorded by the spawn.
Sourcepub async fn has_pending(&self) -> Result<bool, DaggerError>
pub async fn has_pending(&self) -> Result<bool, DaggerError>
Report whether anything is queued to send to the model: an unsent prompt or unevaluated tool results. When true, another step will do work; when false, the turn is complete.
Sourcepub fn fork(&self, label: impl Into<String>) -> Llm
pub fn fork(&self, label: impl Into<String>) -> Llm
Fork the conversation, so that otherwise-identical follow-ups evaluate independently instead of deduplicating to a single cached result.
§Arguments
label- A label distinguishing this fork from its siblings, e.g. “attempt-2” when retrying a flaky evaluation.
Sourcepub async fn tools(&self) -> Result<String, DaggerError>
pub async fn tools(&self) -> Result<String, DaggerError>
Render documentation for the tools currently exposed to the model.
Sourcepub fn token_usage(&self) -> LlmTokenUsage
pub fn token_usage(&self) -> LlmTokenUsage
The cumulative token usage, summed across every API call in the conversation.
Sourcepub async fn context_tokens(&self) -> Result<isize, DaggerError>
pub async fn context_tokens(&self) -> Result<isize, DaggerError>
estimated number of tokens currently occupying the context window; unlike tokenUsage this is not cumulative over the session
Trait Implementations§
Source§impl Loadable for Llm
impl Loadable for Llm
Source§fn graphql_type() -> &'static str
fn graphql_type() -> &'static str
"Container").Source§fn from_query(
proc: Option<Arc<DaggerSessionProc>>,
selection: Selection,
graphql_client: DynGraphQLClient,
) -> Self
fn from_query( proc: Option<Arc<DaggerSessionProc>>, selection: Selection, graphql_client: DynGraphQLClient, ) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Llm
impl !UnwindSafe for Llm
impl Freeze for Llm
impl Send for Llm
impl Sync for Llm
impl Unpin for Llm
impl UnsafeUnpin for Llm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more