Skip to main content

Llm

Struct Llm 

Source
pub struct Llm {
    pub proc: Option<Arc<DaggerSessionProc>>,
    pub selection: Selection,
    pub graphql_client: DynGraphQLClient,
}

Fields§

§proc: Option<Arc<DaggerSessionProc>>§selection: Selection§graphql_client: DynGraphQLClient

Implementations§

Source§

impl Llm

Source

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

Source

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).

Source

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.
Source

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.

Source

pub async fn id(&self) -> Result<Id, DaggerError>

A unique identifier for this LLM.

Source

pub async fn last_reply(&self) -> Result<String, DaggerError>

The text of the model’s most recent reply.

Source

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
Source

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
Source

pub async fn messages(&self) -> Result<Vec<LlmMessage>, DaggerError>

The full message history, as structured messages.

Source

pub async fn model(&self) -> Result<String, DaggerError>

The model the conversation is running against, after resolving any configured default.

Source

pub async fn portable_id(&self) -> Result<Id, DaggerError>

A portable, self-contained ID for the conversation that node() can resolve in any session. Unlike id, which may return an engine-local runtime handle valid only within the current session, this returns the recipe form suitable for persisting and later restoring the conversation. The recipe is flattened: bindings superseded during the session (workspace overlays recorded by each mutating tool call, and re-bound toolsets) are dropped, while the current workspace binding — including any pending, un-exported edits — is preserved.

Source

pub async fn provider(&self) -> Result<String, DaggerError>

The provider serving the model, e.g. “anthropic”, “openai”, “google”, or “local”.

Source

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.

Source

pub async fn replay(&self) -> Result<Llm, DaggerError>

Re-emit telemetry spans for the full message history, so a loaded conversation displays in the TUI.

Source

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.

Source

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
Source

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
Source

pub async fn sync(&self) -> Result<Llm, DaggerError>

Force evaluation of the conversation’s pending operations (prompts, steps, loops) in the engine.

Source

pub fn token_usage(&self) -> LlmTokenUsage

The cumulative token usage, summed across every API call in the conversation.

Source

pub async fn tools(&self) -> Result<String, DaggerError>

Render documentation for the tools currently exposed to the model.

Source

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).

Source

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 server
  • service - The MCP service to run and communicate with over stdio
Source

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
Source

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
Source

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 send
Source

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
Source

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”.
Source

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 content
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

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 content
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

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.
Source

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
Source

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 to
  • content - The content returned by the tool
  • errored - Whether the tool call resulted in an error
Source

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
Source

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
Source

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.
Source

pub fn without_default_system_prompt(&self) -> Llm

Disable the default system prompt

Source

pub fn without_message_history(&self) -> Llm

Clear the message history, keeping only the system prompts.

Source

pub fn without_system_prompts(&self) -> Llm

Clear the user-added system prompts, keeping only the default system prompt.

Source

pub fn workspace(&self) -> Workspace

Return the workspace the LLM is bound to.

Trait Implementations§

Source§

impl Clone for Llm

Source§

fn clone(&self) -> Llm

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl IntoID<Id> for Llm

Source§

fn into_id( self, ) -> Pin<Box<dyn Future<Output = Result<Id, DaggerError>> + Send>>

Source§

impl Loadable for Llm

Source§

fn graphql_type() -> &'static str

The GraphQL type name (e.g. "Container").
Source§

fn from_query( proc: Option<Arc<DaggerSessionProc>>, selection: Selection, graphql_client: DynGraphQLClient, ) -> Self

Construct this type from a query selection.
Source§

impl Node for Llm

Source§

fn id(&self) -> impl Future<Output = Result<Id, DaggerError>> + Send

Source§

impl Syncer for Llm

Source§

fn id(&self) -> impl Future<Output = Result<Id, DaggerError>> + Send

Source§

fn sync(&self) -> impl Future<Output = Result<Id, DaggerError>> + Send

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more