class

Smith::Agent

Inherits Reference < Object

Constants

CONTINUE_TEXT = "Your previous response was cut off at the output token limit. Continue exactly where you left off. Do not repeat what you already wrote and do not start over."
MAX_CONTINUATIONS = 3

A model that keeps running into its output limit would otherwise cost without bound.

MAX_STOP_CONTINUATIONS = 3

A stop hook that never goes green — make test on a red suite — would otherwise keep the loop alive until MAX_TURNS.

MAX_TURNS = 500
RETRY_SMALLER = "Your tool call was cut off at the output token limit and was discarded. Retry with a smaller payload — for large files, write them in multiple smaller edits."

Constructors

new(provider : LLM::Provider, registry : Tools::Registry = Tools::Registry.default, model : String = Config::DEFAULT_MODEL, system_prompt : String = "You are Smith, an autonomous coding agent written in Crystal.", messages : Array(LLM::Message) | Nil = nil, context_settings : Config::ContextSettings = Config::ContextSettings.new, context_ratio : Float64 = 1.0, transcript_log : TranscriptLog | Nil = nil, stream : Bool = true, hooks : Hooks::Runner = Hooks::Runner.new, thinking_effort : String | Nil = nil, thinking_budget : Int32 | Nil = nil, cost_limit_usd : Float64 | Nil = nil, rates : Pricing::Rates | Nil = nil)
Source

Instance methods

breakdown

Where the context window goes, counted the way compaction counts it. smith context renders this; compaction reads overhead_tokens off it. One computation rather than two is what keeps the breakdown and the compaction decision from disagreeing.

Source
clear!

/clear: the conversation starts over. The calibration ratio goes back to neutral with it — it was measured against a history that no longer exists. The transcript log keeps its copy: it is append-only on purpose.

Source
compactions

What compaction has done to this session so far. smith context reports it; a session read back from disk has no such history to report.

Source
context_ratio

Reported prompt tokens over estimated ones. Persisted with the session so the first turn after a resume is not blind about a 100k history.

Source
context_ratio=(context_ratio : Float64)

Reported prompt tokens over estimated ones. Persisted with the session so the first turn after a resume is not blind about a 100k history.

Source
context_settings
Source
cumulative_usage
Source
hooks
Source
last_compaction
Source
listeners
Source
messages
Source
model
Source
on_event
Source
provider
Source
registry
Source
send(user_text : String, attachments : Array(LLM::ContentBlock) = Array(LLM::ContentBlock).new) : Nil
Source
stop!

Ends the run after the tool results of the current turn are recorded, without sending them back to the provider. A tool reaches this through whatever callback the CLI wired — plan mode uses it so an unapproved plan never slides into execution.

Source
stream?
Source
system_prompt

Writable because the mode switch rebuilds it mid-session (/plan, /normal).

Source
system_prompt=(system_prompt : String)

Writable because the mode switch rebuilds it mid-session (/plan, /normal).

Source