LLM
class LLM extends AbstractObject implements IdAble, Node, Syncer
A conversation with a large language model (LLM): queue prompts, expose tools, and step the model until it completes its turn.
Properties
| $lastQuery | from AbstractObject |
Methods
No description
estimated number of tokens currently occupying the context window; unlike tokenUsage this is not cumulative over the session
The model's total context window in tokens, or null if unknown (e.g. a local or uncatalogued model).
Fork the conversation, so that otherwise-identical follow-ups evaluate independently instead of deduplicating to a single cached result.
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.
The text of the model's most recent reply.
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.
The full message history, as structured messages.
The model the conversation is running against, after resolving any configured default.
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.
The provider serving the model, e.g. "anthropic", "openai", "google", or "local".
The reasoning effort in use, e.g. "low", "medium", or "high". Empty or "none" when reasoning is disabled.
Re-emit telemetry spans for the full message history, so a loaded conversation displays in the TUI.
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.
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.
Force evaluation of the conversation's pending operations (prompts, steps, loops) in the engine.
The cumulative token usage, summed across every API call in the conversation.
Render documentation for the tools currently exposed to the model.
The message history rendered as a plain-text transcript, suitable for feeding back to an LLM (e.g. for summarization).
Change the model for the rest of the conversation. The message history is preserved; the new model takes effect on the next step.
Queue a user prompt, to be sent to the model on the next step or loop.
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.
Append an assistant response to the message history without calling the model, e.g. to reconstruct a conversation from another source.
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.
Add a system prompt, instructing the model across the whole conversation.
Append the result of a tool call to the message history.
Bind the LLM to a workspace, exposing its modules as tools exactly as the Dagger CLI would serve them for that workspace.
Disable the default system prompt
Clear the message history, keeping only the system prompts.
Clear the user-added system prompts, keeping only the default system prompt.
Details
in
AbstractObject at line 13
__construct(AbstractClient $client, QueryBuilderChain $queryBuilderChain)
No description
in
AbstractObject at line 19
protected null|array|string|int|float|bool
queryLeaf(QueryBuilder $leafQueryBuilder, string $leafKey)
No description
at line 19
int
contextTokens()
estimated number of tokens currently occupying the context window; unlike tokenUsage this is not cumulative over the session
at line 28
int
contextWindow()
The model's total context window in tokens, or null if unknown (e.g. a local or uncatalogued model).
at line 37
LLM
fork(string $label)
Fork the conversation, so that otherwise-identical follow-ups evaluate independently instead of deduplicating to a single cached result.
at line 47
bool
hasPending()
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.
at line 56
Id
id()
A unique identifier for this LLM.
at line 65
string
lastReply()
The text of the model's most recent reply.
at line 74
LLM
loop(int|null $maxSteps = null, int|null $maxTokens = null)
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.
at line 89
array
messages()
The full message history, as structured messages.
at line 98
string
model()
The model the conversation is running against, after resolving any configured default.
at line 107
Id
portableID()
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.
at line 116
string
provider()
The provider serving the model, e.g. "anthropic", "openai", "google", or "local".
at line 125
string
reasoningEffort()
The reasoning effort in use, e.g. "low", "medium", or "high". Empty or "none" when reasoning is disabled.
at line 134
LLM
replay()
Re-emit telemetry spans for the full message history, so a loaded conversation displays in the TUI.
at line 144
array
skills()
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.
at line 153
LLM
step(int|null $maxTokens = null)
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.
at line 165
Syncer
sync()
Force evaluation of the conversation's pending operations (prompts, steps, loops) in the engine.
at line 175
LLMTokenUsage
tokenUsage()
The cumulative token usage, summed across every API call in the conversation.
at line 184
string
tools()
Render documentation for the tools currently exposed to the model.
at line 193
string
transcript()
The message history rendered as a plain-text transcript, suitable for feeding back to an LLM (e.g. for summarization).
at line 213
LLM
withModel(string $model, string|null $provider = null)
Change the model for the rest of the conversation. The message history is preserved; the new model takes effect on the next step.
at line 226
LLM
withPrompt(string $prompt)
Queue a user prompt, to be sent to the model on the next step or loop.
at line 236
LLM
withPromptFile(File $file)
Queue a file's contents as a user prompt, like withPrompt.
at line 246
LLM
withReasoningEffort(string $effort)
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.
at line 256
LLM
withResponse(array $content, int|null $inputTokens = 0, int|null $outputTokens = 0, int|null $cachedTokenReads = 0, int|null $cachedTokenWrites = 0, int|null $totalTokens = 0)
Append an assistant response to the message history without calling the model, e.g. to reconstruct a conversation from another source.
at line 287
LLM
withSkills(Directory $directory)
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.
at line 297
LLM
withSystemPrompt(string $prompt)
Add a system prompt, instructing the model across the whole conversation.
at line 307
LLM
withToolResult(string $callId, string $content, bool $errored)
Append the result of a tool call to the message history.
at line 319
LLM
withTools(Node $object, array|null $except = [])
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.
at line 332
LLM
withWorkspace(Workspace $workspace)
Bind the LLM to a workspace, exposing its modules as tools exactly as the Dagger CLI would serve them for that workspace.
at line 342
LLM
withoutDefaultSystemPrompt()
Disable the default system prompt
at line 351
LLM
withoutMessageHistory()
Clear the message history, keeping only the system prompts.
at line 360
LLM
withoutSystemPrompts()
Clear the user-added system prompts, keeping only the default system prompt.
at line 369
Workspace
workspace()
Return the workspace the LLM is bound to.