org.llm4s.agent.harness

Members list

Type members

Classlikes

@Experimental
final case class BackendRefused(operation: String, target: String, reason: String, kind: Kind, path: Option[VPath]) extends LLMError, NonRecoverableError

A backend's refusal of one operation, for the model to see: a missing file, an old that is not unique, a quota, binary content. Decided when the tool runs, never in an update function (rule 2).

A backend's refusal of one operation, for the model to see: a missing file, an old that is not unique, a quota, binary content. Decided when the tool runs, never in an update function (rule 2).

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final class CompositeBackend extends FileBackend

Several backends as one tree: each route mounts a backend at a path, and a path goes to the backend of the longest mount it is within, segment by segment, or to default. The routed backend sees the path relative to its mount (/memories/notes.md is /notes.md to the backend mounted at /memories), so a backend means the same at any mount.

Several backends as one tree: each route mounts a backend at a path, and a path goes to the backend of the longest mount it is within, segment by segment, or to default. The routed backend sees the path relative to its mount (/memories/notes.md is /notes.md to the backend mounted at /memories), so a backend means the same at any mount.

Mutations, their locks and their replay are the routed backend's. ls adds each mount beneath the directory as a directory; find and search (so glob and grep) span every backend beneath under, and a path of one backend that a deeper mount shadows is never listed.

Attributes

Companion
object
Supertypes
trait FileBackend
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final case class ConversationSummary

The thread's summary, as SummarizationMiddleware.key stores it: text summarises the stored history up to and including the message throughMessageId (a StoredMessage id).

The thread's summary, as SummarizationMiddleware.key stores it: text summarises the stored history up to and including the message throughMessageId (a StoredMessage id).

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final case class DocumentIssue(path: VPath, kind: Kind, line: Option[Int], detail: String)

One file a read of documents through a backend left out or changed: path, what happened (kind), the 1-based line it concerns when there is one, and detail in the reader's own words - never the file's content.

One file a read of documents through a backend left out or changed: path, what happened (kind), the 1-based line it concerns when there is one, and detail in the reader's own words - never the file's content.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object DocumentIssue

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final case class DocumentsReported(middleware: String, issues: Vector[DocumentIssue], omitted: Int)

The issues of one run's read by the middleware middleware: at most 32, in the order found, and the number omitted beyond them. Durable, so it carries no content.

The issues of one run's read by the middleware middleware: at most 32, in the order found, and the number omitted beyond them. Durable, so it carries no content.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class ExecResult

What a command did; each stream cut at the backend's maxOutputBytes, truncated when one was.

What a command did; each stream cut at the backend's maxOutputBytes, truncated when one was.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ExecResult

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ExecResult.type
@Experimental
object ExecuteTool

The execute tool (design §4.33): runs a command in a SandboxBackend, and knows nothing else about where. Through the backend, every command runs under C4's Unverifiable guard: a completed command replays its stored result, one that may have run is refused rather than run again, and a Block cannot undo what a command did (rule 5).

The execute tool (design §4.33): runs a command in a SandboxBackend, and knows nothing else about where. Through the backend, every command runs under C4's Unverifiable guard: a completed command replays its stored result, one that may have run is refused rather than run again, and a Block cannot undo what a command did (rule 5).

  • '''Arguments.''' command; workdir, a path such as /src (default /); timeout_seconds (default defaultTimeout, at most maxTimeout).
  • '''Permissions.''' A call touches ToolResource(Operation.Execute, <command>), so a PermissionMiddleware rule matches on the command; the hints are destructive and openWorld.
  • '''Order.''' A call holds backend.locks(workdir) (a workspace sandbox: its whole workspace), so a batch's commands and the edits of the files they may touch apply in call order.
  • '''Bounds.''' Each stream is at most the backend's maxOutputBytes, the command at most SandboxBackend.MaxCommandBytes, the run at most the timeout; the tool itself is stopped maxTimeout plus a minute in, for a sandbox that never answers.

The result is the exit code, stdout and stderr, and a note when output was cut. A refusal (by the sandbox's policy, or of a replay) is a tool error; a failure whose outcome is unknown fails the task, so recover decides it from C4's records.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
trait FileBackend

Where an agent's files live: thread state (StateFileBackend), a host directory (HostFileBackend), a LongTermStore (StoreFileBackend), several at once (CompositeBackend), or one chosen per run (FileBackend.resolved).

Where an agent's files live: thread state (StateFileBackend), a host directory (HostFileBackend), a LongTermStore (StoreFileBackend), several at once (CompositeBackend), or one chosen per run (FileBackend.resolved).

A backend owns the four obligations of every mutation, so the tools that call it need not know them:

  • '''Order.''' locks(path) are the LockKeys a mutation of path holds; a tool declares them with AgentToolSpec.withLocks, so mutations of one path in one batch apply in call order. Reads take no lock.
  • '''Replay.''' A mutation outside thread state runs through C4's replay guard of its target's class, under ctx.effectKey(operation, path). A state mutation is the StateUpdate it returns, which the runtime commits with the call; it needs no guard.
  • '''Bounds.''' Every result is bounded by limit and the backend's own limits, and every store by a limit the backend checks itself.
  • '''Tenant.''' A backend shared across threads is scoped by the run's tenant, or built per tenant by a resolver.

A refusal the model should see is a BackendRefused; any other Left is a failure the task must not hide (BackendRefused.toolOutcome).

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object FileBackend

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final class FileContext

What a backend operation knows: the run, the thread state it may read, and - for a tool call - the call, whose key names each external effect it performs. Built from a ToolContext by a tool, or from a RunContext and ThreadState by a hook.

What a backend operation knows: the run, the thread state it may read, and - for a tool call - the call, whose key names each external effect it performs. Built from a ToolContext by a tool, or from a RunContext and ThreadState by a hook.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object FileContext

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final case class FileDeleted(wasDirectory: Boolean)

What a delete removed: a file, or an empty directory.

What a delete removed: a file, or an empty directory.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class FileEdited(replacements: Int)

How many occurrences an edit replaced.

How many occurrences an edit replaced.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class FileEntry(content: String, modified: Instant)

One file of a StateFileBackend: UTF-8 text, and when it was last written.

One file of a StateFileBackend: UTF-8 text, and when it was last written.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object FileEntry

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
FileEntry.type
@Experimental
final case class FileInfo(path: VPath, isDirectory: Boolean, size: Long, modified: Option[Instant])

One entry of a directory. size is in UTF-8 bytes, 0 for a directory.

One entry of a directory. size is in UTF-8 bytes, 0 for a directory.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class FileLines(lines: Vector[String], offset: Int, totalLines: Int)

Lines offset to offset + lines.size - 1 (0-based) of a file of totalLines lines.

Lines offset to offset + lines.size - 1 (0-based) of a file of totalLines lines.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class FileToolLimits

The bounds of FileTools' results (design §4.32, rule 12).

The bounds of FileTools' results (design §4.32, rule 12).

Every limit in characters counts UTF-16 units, as String.length does, so it bounds the text's size as stored and sent; a character outside the Basic Multilingual Plane (an emoji) counts 2. A cut never splits one.

Value parameters

maxLineChars

the most characters of one line read_file and grep show; a longer line is cut and marked

maxResultChars

the most characters of any one result a tool returns, an error's included, as the model sees it; at least 256. An outcome the loop or a middleware gives instead of running the tool (invalid arguments, a denial, a timeout) is theirs, bounded by the arguments the tools bound

maxResults

the most entries ls, glob and grep return; a longer listing says it stopped

readLimit

the lines read_file returns when the model gives no limit, and the most it returns

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
object FileTools

The filesystem tools over a FileBackend (design §4.32): ls, read_file, write_file, edit_file, delete, glob and grep, as AgentTools.

The filesystem tools over a FileBackend (design §4.32): ls, read_file, write_file, edit_file, delete, glob and grep, as AgentTools.

val files = StateFileBackend()
Agent.builder("coder", client).withTools(ToolSet.of(FileTools(files)*).fold(e => throw ..., identity))

The backend does the work and owns its obligations - locks, replay, bounds and tenant (§4.25); the tools translate arguments into backend calls and results into bounded text:

  • '''Paths''' are absolute (/src/a.scala): ., .. and empty segments are refused, never normalised.
  • '''Resources''' (C2): Read of the path for ls and read_file; Write for write_file and edit_file; Delete for delete; and for glob and grep the envelope of every path they may read (<path>/<pattern>, <path>/&#42;&#42;), which a permission rule decides as a whole.
  • '''Locks''': each mutation holds backend.locks(path), so two mutations of one file in one model message apply in order, the second against the first's result. Reads take no lock, so a read in the same message as a write is not ordered with it: over thread state it sees the file as it was before the message (the batch's snapshot); over an external backend (a store, a workspace) it may see either version.
  • '''Bounds''': read_file returns at most readLimit lines, each cut at maxLineChars; ls, glob and grep at most maxResults entries, and say when they stopped; every result is at most maxResultChars.

Do not register these beside llm4s-agent-tools' host file tools: read_file and write_file are both suites' names, and a ToolSet refuses a duplicate.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
FileTools.type
@Experimental
enum FileUpdate

An update to a StateFileBackend's files; both are total (rule 2).

An update to a StateFileBackend's files; both are total (rule 2).

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class FileWritten(created: Boolean, bytes: Long)

What a write did: whether it created the file, and the content's size in UTF-8 bytes.

What a write did: whether it created the file, and the content's size in UTF-8 bytes.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class GeneralPurposeConfig

The general-purpose subagent of a SubagentConfig (design 4.48): a TypedAgent.text("general-purpose", ...) that takes a task description and reports its answer as text, through the shared task tool. Its own harness is the minimal profile (the file tools over its own StateFileBackend) with systemPrompt.

The general-purpose subagent of a SubagentConfig (design 4.48): a TypedAgent.text("general-purpose", ...) that takes a task description and reports its answer as text, through the shared task tool. Its own harness is the minimal profile (the file tools over its own StateFileBackend) with systemPrompt.

Its grant is written here, not implied: GeneralPurposeConfig.DefaultInheritance grants every tool of the parent except the file tools and execute (its own harness has file tools over its own backend) and no delegation. For this subagent a ToolGrant.AllExcept withholds the names it lists that the parent has, and ignores the rest - withholding an absent tool is harmless - so the default holds for a parent with or without a sandbox. Any other grant is checked as for every subagent. Agent.delegation shows the grant as computed.

Value parameters

description

what the parent model reads about it, in the task tool and the prompt; must not be blank

inheritance

what it takes from the parent

model

the client and options it calls; None for the parent's

systemPrompt

its harness's prompt

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final case class GrepMatch(path: VPath, line: Int, text: String)

A line of a file that matched, numbered from 1.

A line of a file that matched, numbered from 1.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object HarnessEvents

The events the harness middleware send, each an org.llm4s.agent.graph.EventType to match a StreamEvent with, as org.llm4s.agent.events.AgentEvents are.

The events the harness middleware send, each an org.llm4s.agent.graph.EventType to match a StreamEvent with, as org.llm4s.agent.events.AgentEvents are.

Durable (stored, replayed, no content): TodosUpdated, DocumentsReported. Live (current subscribers only): TodosProgress.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final case class HarnessProfile

A harness for an agent (design §4.37): file tools over a backend, optionally execute over a sandbox, and the middleware that plan, manage context, load skills and instructions and check permissions - assembled in a fixed order by AgentBuilder.withHarness. Start from HarnessProfile.deepAgents, or from HarnessProfile() (the file tools alone), and change it with the with* setters; org.llm4s.config.HarnessConfigLoader loads the preset's settings from llm4s.agent.harness.

A harness for an agent (design §4.37): file tools over a backend, optionally execute over a sandbox, and the middleware that plan, manage context, load skills and instructions and check permissions - assembled in a fixed order by AgentBuilder.withHarness. Start from HarnessProfile.deepAgents, or from HarnessProfile() (the file tools alone), and change it with the with* setters; org.llm4s.config.HarnessConfigLoader loads the preset's settings from llm4s.agent.harness.

build() installs, outermost first and before the builder's own middleware: a PermissionMiddleware over permissions (none when they are empty, since a PermissionMiddleware denies every call no rule matches), then summarisation, offload, skills, instructions and todos, each when set. When the agent has subagents - the profile's subagents, then the builder's own - their delegation middleware runs inside the permissions and outside the rest, so a permission rule decides each task call: with rules, task needs an Invoke rule. The selected file tools run over backend, or over a CompositeBackend that also mounts OffloadBackend at /large_tool_results when offload is set; skills and instructions read through the same backend. execute is added only when sandbox is set. Each tool of the profile that declares no timeout is bounded by toolTimeout. The system prompt follows systemPrompt. After each turn, as it is admitted, the root agent prunes the thread to retention (RunConfig.withRetention), which bounds the full-snapshot checkpoints it keeps.

build() refuses an invalid setting (a limit a component refuses, a blank PromptMode.Replace), a tool name the selection does not know, execute selected without a sandbox, and withSystemPrompt beside a harness: set the prompt through systemPrompt.

Value parameters

backend

where the file tools, skills and instructions read and write

instructions

instruction memory (AGENTS.md); None for none

offload

offload of large tool results; None for none

permissions

permission rules, first match wins; empty for no permission checks

retention

what a thread keeps of its checkpoints and events, applied as each turn is admitted

sandbox

where execute runs commands; None adds no execute tool

skills

Agent Skills; None for none

subagents

the subagents offered through the task tools, and their bounds; SubagentConfig.none for none

summarization

summarisation of older messages; None for none

systemPrompt

the system prompt

todos

the plan (write_todos); None for none

toolTimeout

the bound on each run of a profile tool that declares none

tools

which of the file tools and execute the agent gets

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final class HostFileBackend extends FileBackend, AutoCloseable

Files in a directory of the host, opt-in: the agent sees root as / (design §4.40).

Files in a directory of the host, opt-in: the agent sees root as / (design §4.40).

'''One writer per root.''' HostFileBackend.open takes an exclusive OS lock on the root, held until close: a second open of the same root, or of one containing it or inside it, from this JVM or another process, is refused with HostRootInUse. The lock excludes other backends that share the lock directory, not an editor or a build writing the directory; a replay still sees such a change, by its digests.

'''One path, one file.''' A path the model sees is the only way to reach its file: symbolic links, files with other hard links, other file systems mounted inside the root, names ending in a dot or a space and the backend's own temporary names are refused and never listed. open refuses a root whose file system makes 8.3 short names, and one it cannot check (no hard-link counts, as on NTFS, or a root it cannot probe) unless allowUncheckedIdentity.

'''Not a security boundary.''' It is a convenience for a trusted directory. Never give it a root an untrusted process can write, a sandboxed command included: such a process can swap a directory for a link between the backend's check and its open. Untrusted commands belong in the workspace sandbox (F2).

  • '''Replay.''' Its target is Verifiable (C4): each mutation runs through ReplayGuard.verifiable under ctx.effectKey("file.write" | "file.edit" | "file.delete", path), and its effect is a compare-and-set under the backend's own effect lock, so a run that lost its claim cannot overwrite its successor's change.
  • '''Atomic.''' A write or edit moves a flushed temporary file over its target, keeping the target's POSIX permissions, owner, group, ACL and DOS flags, or is refused where it cannot keep them.
  • '''Order.''' Every mutation locks files/host/<root>: a batch's mutations through one backend apply one at a time, in call order.
  • '''Bounds.''' A file over maxFileBytes cannot be read, written or edited, and search skips it. ls, find and search read at most maxScanEntries directory entries, never a stream past it, and report a cut scan as truncated: a directory over the bound lists as empty, and a walk stops at the first directory it cannot read whole, so a cut result is a prefix of the full one.
  • '''Tenant.''' Not scoped: one root is one tenant's. Build one per tenant with FileBackend.resolved.
  • '''Snapshot.''' Reads see the file as it is now, not as the batch's thread state.

Attributes

Companion
object
Supertypes
trait AutoCloseable
trait FileBackend
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final case class HostRootInUse(root: Path, conflict: Conflict, detail: String) extends LLMError, NonRecoverableError

A root HostFileBackend.open refused because another backend holds it, or one overlapping it, in this JVM or another process: one root has one writer (design §4.40).

A root HostFileBackend.open refused because another backend holds it, or one overlapping it, in this JVM or another process: one root has one writer (design §4.40).

Attributes

Companion
object
Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object HostRootInUse

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final class InMemoryLongTermStore extends LongTermStore

The in-memory LongTermStore, for tests and single-process applications: one lock for the store. search is a case-insensitive substring match over keys and string values.

The in-memory LongTermStore, for tests and single-process applications: one lock for the store. search is a case-insensitive substring match over keys and string values.

Attributes

Companion
object
Supertypes
trait AppliedKeys
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final class InstructionMemoryMiddleware(val paths: Vector[VPath], val backend: FileBackend, val maxFileTokens: Int, val maxTotalTokens: Int, val maxCachedRuns: Int, val id: MiddlewareId) extends AgentMiddleware

Instruction memory for an agent (design §4.36): the AGENTS.md files at paths, read through backend in order - for example the user's, then the project's - and shown to the model as one cacheable prompt section, each file under a heading naming its path. A later file refines an earlier one.

Instruction memory for an agent (design §4.36): the AGENTS.md files at paths, read through backend in order - for example the user's, then the project's - and shown to the model as one cacheable prompt section, each file under a heading naming its path. A later file refines an earlier one.

  • When. The files are read on a run's first model call, from that step's snapshot, and kept for the run (a bounded cache, maxCachedRuns runs). A run recovered or resumed reads again: a state backend's files come back with the checkpoint, while a store's or a host's may have changed in between.
  • Editing. The agent edits a file with edit_file, over the same backend, when the backend accepts the write and the permission rules allow Write on its path; the change shows from the next run. Make a scope read-only with a deny rule, or by mounting it on a backend that refuses writes.
  • Bounds. Each file is read at most maxFileTokens estimated tokens, and the section - guide, headings and markers included - is at most maxTotalTokens. A file over either is shown cut and marked; the files after the section is full are left out. Each is named, by path, in a durable HarnessEvents.DocumentsReported.
  • Problems. A missing file is skipped, and so is one that is only whitespace (one cut at its limit is shown, cut). A file the backend refuses is skipped and reported. A backend error that is not a refusal fails the step, which recover runs again.

Instruction memory is a few whole files the agent always sees; semantic memory (llm4s-agent-memory) is facts recalled per query. The middleware writes nothing: its writes are the backend's keys, so a state backend's files are registered with the graph even with no file tool.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
@Experimental

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final case class Instructions

One instruction file as a run shows it: its path, its text (at most the middleware's limits), and whether the text was cut at one.

One instruction file as a run shows it: its path, its text (at most the middleware's limits), and whether the text was cut at one.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object Instructions

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final case class InstructionsConfig

The settings of a harness's InstructionMemoryMiddleware, which reads through the profile's backend; see its parameters.

The settings of a harness's InstructionMemoryMiddleware, which reads through the profile's backend; see its parameters.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final case class Listing[A](items: Vector[A], truncated: Boolean)

A list cut at a limit: truncated when there was more, or a scan bound stopped the walk.

A list cut at a limit: truncated when there was more, or a scan bound stopped the walk.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Listing

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Listing.type
@Experimental
trait LongTermStore extends AppliedKeys

Items kept across threads and runs, by (Namespace, key): /memories/ files (StoreFileBackend) and semantic memory (F7). Its target is Transactional (C4).

Items kept across threads and runs, by (Namespace, key): /memories/ files (StoreFileBackend) and semantic memory (F7). Its target is Transactional (C4).

The one mutation primitive is modify, a read-modify-write in the store's own transaction, serialisable within its namespace: the outcome already recorded for the effect's key, or the change decided against a StoreView and applied, bounds checked and (key, outcome) recorded with it. An edit therefore never loses a concurrent write, a check that spans keys cannot be raced, and a replay whose first attempt landed returns the first outcome before it re-reads anything. put and delete wrap it in ReplayGuard.transactional; a backend over the store uses modify the same way with its own keys.

ujson.Value is mutable, so a store copies every value it is given and every value it hands out. An implementation keeps its applied keys only until C4's guard forgets them, and never by age.

Attributes

Companion
object
Supertypes
trait AppliedKeys
class Object
trait Matchable
class Any
Known subtypes
object LongTermStore

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final case class Namespace(tenant: Option[TenantId], path: Vector[String])

Where a LongTermStore item lives: always with its tenant (None is the single-tenant namespace, its own), then a path. No operation reaches across namespaces (rule 8).

Where a LongTermStore item lives: always with its tenant (None is the single-tenant namespace, its own), then a path. No operation reaches across namespaces (rule 8).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object OffloadBackend extends FileBackend

The read-only view of the thread's offloaded results (ToolOutputOffload.key): one file /<key> per result. Mount it at ToolOutputOffload.Mount in a CompositeBackend, the path the model is shown. ls, read, glob and grep see the stored text; write, edit and delete are refused, so a file tool reports them as tool errors. Reading an evicted result says it was evicted. An agent without a ToolOutputOffload has no results.

The read-only view of the thread's offloaded results (ToolOutputOffload.key): one file /<key> per result. Mount it at ToolOutputOffload.Mount in a CompositeBackend, the path the model is shown. ls, read, glob and grep see the stored text; write, edit and delete are refused, so a file tool reports them as tool errors. Reading an evicted result says it was evicted. An agent without a ToolOutputOffload has no results.

Attributes

Supertypes
trait FileBackend
class Object
trait Matchable
class Any
Self type
@Experimental
final case class OffloadConfig

The settings of a harness's ToolOutputOffload; see its parameters.

The settings of a harness's ToolOutputOffload; see its parameters.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object OffloadConfig

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental

An update to ToolOutputOffload.key; both are total (rule 2).

An update to ToolOutputOffload.key; both are total (rule 2).

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class OffloadedResult

One offloaded result: key is its path segment (the call's IdempotencyKey), content its stored text.

One offloaded result: key is its path segment (the call's IdempotencyKey), content its stored text.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final case class Offloads

The thread's offloaded results, oldest first, and the keys of the latest ToolOutputOffload.MaxEvicted evicted or dropped ones, oldest first.

The thread's offloaded results, oldest first, and the keys of the latest ToolOutputOffload.MaxEvicted evicted or dropped ones, oldest first.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object Offloads

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Offloads.type
@Experimental
enum PromptMode

Where a HarnessProfile's system prompt comes from.

Where a HarnessProfile's system prompt comes from.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final class SandboxBackend

Where commands run. Its target is Unverifiable (C4): every execute runs through ReplayGuard.unverifiable under ctx.effectKey("sandbox.execute", command, workdir), never as idempotent, so a completed command replays its stored ExecResult and one whose run may have begun without recording its outcome is refused (GraphError.EffectReplayRefused, a tool error), never run again. Each stream is cut, on a character boundary, so that its JSON encoding - what the guard records - is at most maxOutputBytes, before the outcome is recorded; so a recorded ExecResult always fits C4's record, whatever the output's characters (rule 12). A command's effects stay when a Block retracts its turn (rule 5).

Where commands run. Its target is Unverifiable (C4): every execute runs through ReplayGuard.unverifiable under ctx.effectKey("sandbox.execute", command, workdir), never as idempotent, so a completed command replays its stored ExecResult and one whose run may have begun without recording its outcome is refused (GraphError.EffectReplayRefused, a tool error), never run again. Each stream is cut, on a character boundary, so that its JSON encoding - what the guard records - is at most maxOutputBytes, before the outcome is recorded; so a recorded ExecResult always fits C4's record, whatever the output's characters (rule 12). A command's effects stay when a Block retracts its turn (rule 5).

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental

What runs commands for a SandboxBackend (F2's workspace sandbox): it only runs. The backend wraps every run in C4's guard, so a runner cannot run a command twice on replay by mistake.

What runs commands for a SandboxBackend (F2's workspace sandbox): it only runs. The backend wraps every run in C4's guard, so a runner cannot run a command twice on replay by mistake.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
@Experimental
final case class Skill

One Agent Skill: the frontmatter of its SKILL.md, at path. The model reads the file itself, and the skill's other files, with read_file; SkillsMiddleware lists the name and description.

One Agent Skill: the frontmatter of its SKILL.md, at path. The model reads the file itself, and the skill's other files, with read_file; SkillsMiddleware lists the name and description.

Value parameters

allowedTools

the tools the skill expects (allowed-tools), parsed but not enforced

description

what the skill does and when to use it

license

the skill's licence, if it names one

metadata

the skill's metadata map, in file order

name

the skill's name: at most 64 characters of a-z, 0-9 and -, equal to its folder's name

path

the skill's SKILL.md

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object Skill

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Skill.type
@Experimental
final case class SkillFormatError(path: VPath, line: Int, problem: String) extends LLMError, NonRecoverableError

A SKILL.md whose frontmatter is not in the restricted format, or breaks the standard's rules: the file, the 1-based line, and the problem in the parser's own words, which never quote the file.

A SKILL.md whose frontmatter is not in the restricted format, or breaks the standard's rules: the file, the 1-based line, and the problem in the parser's own words, which never quote the file.

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class SkillsConfig

The settings of a harness's SkillsMiddleware, which reads through the profile's backend; see its parameters.

The settings of a harness's SkillsMiddleware, which reads through the profile's backend; see its parameters.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object SkillsConfig

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final class SkillsMiddleware(val sources: Vector[VPath], val backend: FileBackend, val maxSkills: Int, val maxDescriptionChars: Int, val maxSectionTokens: Int, val maxScanned: Int, val maxCachedRuns: Int, val id: MiddlewareId) extends AgentMiddleware

Agent Skills for an agent (design §4.35): finds the skills under sources through backend - each folder <source>/<name>/ holding a SKILL.md - and lists each one's name and description in one cacheable prompt section. The model loads a skill when a task matches it, reading its SKILL.md and other files with read_file, so give the agent file tools over the same backend (or the composite it is mounted in): the paths the section shows are the backend's.

Agent Skills for an agent (design §4.35): finds the skills under sources through backend - each folder <source>/<name>/ holding a SKILL.md - and lists each one's name and description in one cacheable prompt section. The model loads a skill when a task matches it, reading its SKILL.md and other files with read_file, so give the agent file tools over the same backend (or the composite it is mounted in): the paths the section shows are the backend's.

  • When. The skills are read on a run's first model call, from that step's snapshot, and kept for the run (a bounded cache, maxCachedRuns runs). A skill added or edited during a run shows from the next run. A run recovered or resumed reads again: a state backend's skills come back with the checkpoint, while a store's or a host's may have changed in between, and the recovered run sees them as they are then.
  • Order. Sources in order, then folders in path order; a later source's skill replaces an earlier one of the same name, so list the user's skills before the project's.
  • Bounds. At most maxSkills skills are listed, each description cut at maxDescriptionChars code points, the section at most maxSectionTokens estimated tokens; at most maxScanned folders are examined across all sources, and of each SKILL.md only its frontmatter (at most Skill.MaxFrontmatterChars characters).
  • Problems. A missing source, and a folder without SKILL.md, are skipped. A skill that is malformed, not listed, shadowed or unreadable is skipped and named, by path, in a durable HarnessEvents.DocumentsReported committed with the run's first model step; it never fails the run. A backend error that is not a refusal fails the step, which recover runs again.

allowed-tools is parsed onto Skill.allowedTools and not enforced. The middleware writes nothing: its writes are the backend's keys, so a state backend's files are registered with the graph even with no file tool.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
@Experimental

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final class StateFileBackend extends FileBackend

The default FileBackend: files in thread state, under one key of its own (files, id keyId). They are committed with the call that wrote them, so they are part of every checkpoint, of history and of fork, and a mutation needs no replay guard: its effect is the update the runtime commits.

The default FileBackend: files in thread state, under one key of its own (files, id keyId). They are committed with the call that wrote them, so they are part of every checkpoint, of history and of fork, and a mutation needs no replay guard: its effect is the update the runtime commits.

Directories are implicit: a path is a directory when an entry lies beneath it. Every mutation holds the lock files/state/<keyId>, so the mutations of one batch apply in call order, each against the state the previous one committed. That makes the bounds exact: the total bytes of paths and contents, as JSON strings (what a checkpoint stores, escapes included), is at most maxBytes, and the number of files at most maxFiles, checked when the tool runs (rules 1, 2, 12).

Each checkpoint copies the whole map (rule 6), so pair the backend with a RetentionPolicy.

The lock is what keeps two edits of one file in a batch from losing one, and the bounds exact: the calls of a batch otherwise share one snapshot. Adding tools over this backend to an existing agent adds the files key and the loop's tool-queue: a thread at rest continues with no files, and one in flight is refused until it is finished (§4.29). The last file's delete removes the key's entry, so taking the tools out again refuses only a thread that still holds files.

Attributes

Companion
object
Supertypes
trait FileBackend
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final class StaticFileBackend extends FileBackend

Files the application ships, fixed when the backend is built and read-only: skills and AGENTS.md for an agent whose files are otherwise thread state (design §4.38). On a StateFileBackend only a tool call writes a file, so mount this in a CompositeBackend - at /app, say - and point SkillsConfig.withSources and InstructionsConfig.withPaths there; every thread reads the same files, and no tool can change them.

Files the application ships, fixed when the backend is built and read-only: skills and AGENTS.md for an agent whose files are otherwise thread state (design §4.38). On a StateFileBackend only a tool call writes a file, so mount this in a CompositeBackend - at /app, say - and point SkillsConfig.withSources and InstructionsConfig.withPaths there; every thread reads the same files, and no tool can change them.

Paths are the backend's own, as for every backend in a composite: a file the agent reads at /app/skills/a/SKILL.md through a mount at /app is given here as /skills/a/SKILL.md. ls, read, glob and grep see the files; write, edit and delete are refused, so a file tool reports a tool error. It writes no state key, so it adds nothing to a checkpoint.

Attributes

Companion
object
Supertypes
trait FileBackend
class Object
trait Matchable
class Any
@Experimental

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
enum StoreChange[+A]

What LongTermStore.modify does to the current item, and the outcome it records.

What LongTermStore.modify does to the current item, and the outcome it records.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class StoreEntry(key: String, item: StoreItem)

An item with its key, as a listing returns it.

An item with its key, as a listing returns it.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final class StoreFileBackend extends FileBackend

A LongTermStore namespace as files, for /memories/: what the agent writes there outlives the thread. Each run uses Namespace(<the run's tenant>, path), so no run can reach another tenant's files, whatever the application configures (rule 8).

A LongTermStore namespace as files, for /memories/: what the agent writes there outlives the thread. Each run uses Namespace(<the run's tenant>, path), so no run can reach another tenant's files, whatever the application configures (rule 8).

A file is an item keyed by its path, with value {"content": ...}; directories are implicit, as in StateFileBackend. Mutations lock files/store/<path>/<file> and run through ReplayGuard.transactional under ctx.effectKey("file.write" | "file.edit" | "file.delete", file), each as one store.modify, so an edit decides "old was not found", and a write the tree's shape, inside the store's transaction, and a replay whose first attempt landed returns the first outcome. The store's bounds hold, and an over-limit write is a tool error. Listings read at most the store's maxItems entries.

Attributes

Companion
object
Supertypes
trait FileBackend
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
final case class StoreItem(value: Value, updated: Instant)

A stored value, and when it was last written.

A stored value, and when it was last written.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class StoreLimits

A store's bounds (rule 12): one item's UTF-8 bytes (its key plus its encoded value), and one namespace's item count and total bytes. maxItemBytes is at most ReplayGuard.DefaultMaxOutcomeBytes, so an outcome built from an item always fits a replay record.

A store's bounds (rule 12): one item's UTF-8 bytes (its key plus its encoded value), and one namespace's item count and total bytes. maxItemBytes is at most ReplayGuard.DefaultMaxOutcomeBytes, so an outcome built from an item always fits a replay record.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object StoreLimits

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
trait StoreView

What a LongTermStore.modify change sees, inside its transaction: the item being modified, and the rest of its namespace, so a check that spans keys (a file's ancestors and descendants) is atomic with the write. Values are copies: changing one changes nothing stored.

What a LongTermStore.modify change sees, inside its transaction: the item being modified, and the rest of its namespace, so a check that spans keys (a file's ancestors and descendants) is atomic with the write. Values are copies: changing one changes nothing stored.

Attributes

Supertypes
class Object
trait Matchable
class Any
@Experimental
final case class SubagentConfig

The subagents a HarnessProfile gives its agent (design 4.48), offered through the task tools, and the bounds on their tasks. SubagentConfig.none, the minimal profile's, gives none: delegation is never granted silently. HarnessProfile.deepAgents has SubagentConfig.deepAgents, the general-purpose subagent alone.

The subagents a HarnessProfile gives its agent (design 4.48), offered through the task tools, and the bounds on their tasks. SubagentConfig.none, the minimal profile's, gives none: delegation is never granted silently. HarnessProfile.deepAgents has SubagentConfig.deepAgents, the general-purpose subagent alone.

AgentBuilder.build() binds these before any the builder adds with withSubagents, and delegation bounds them all; withDelegation beside a harness is refused, so the bounds have one source.

Value parameters

delegation

the bounds on the agent's delegated tasks

generalPurpose

the general-purpose subagent, general-purpose; None disables it

specialists

the profile's own subagents, after the general-purpose one, in order

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final case class SummarizationConfig

The settings of a harness's SummarizationMiddleware; see its parameters. compressor None is SummaryCompressor.digest over core's cl100k_base counter, which makes no model call; give a SummaryCompressor.model(client) for a summary the model writes.

The settings of a harness's SummarizationMiddleware; see its parameters. compressor None is SummaryCompressor.digest over core's cl100k_base counter, which makes no model call; give a SummaryCompressor.model(client) for a summary the model writes.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
@Experimental
final class SummarizationMiddleware(val trigger: SummaryTrigger, val keepRecent: Int, compressor: SummaryCompressor, val maxSummaryTokens: Int, tokenCounter: Message => Int, val id: MiddlewareId) extends AgentMiddleware

When a model request grows past trigger, replaces its older messages with a summary, kept in the thread and extended as the thread grows (design §4.34). The stored history is never edited.

When a model request grows past trigger, replaces its older messages with a summary, kept in the thread and extended as the thread grows (design §4.34). The stored history is never edited.

  • The trigger is measured on the outgoing request as it would be sent with the stored summary applied, system prompt included: its estimated tokens (tokenCounter) or its message count.
  • When it fires, every message after the summary but the last keepRecent goes to compressor with the summary so far; the cut moves earlier so a tool call is never separated from its results. The new summary goes straight into this request, and is written to SummarizationMiddleware.key with the stored id of the last message it covers, committed with the model step.
  • Later requests send the summary in place of the messages it covers - one UserMessage straight after the system prompt - and the messages after it unchanged.
  • The bound: a summary is at most maxSummaryTokens estimated tokens at four characters a token, cut after the compressor returns and again when a stored one is sent.

An output Block restores the key, so a blocked turn's summary is never kept. A model compressor's calls go through ModelContext.accounted, so they are counted in the thread's usage. Use this or ContextWindowMiddleware, which prunes with no model call, not both.

It must run outside a ToolOutputOffload - registered before it - so it matches the request with the stored history before offload cuts any tool result; build() refuses the other order (placement).

Value parameters

compressor

writes the summary

keepRecent

how many of the latest messages are always sent as they are; at least 1

maxSummaryTokens

the bound on the summary, in estimated tokens at four characters a token; at least SummaryCompressor.MinSummaryTokens (32)

tokenCounter

the estimate a SummaryTrigger.Tokens trigger is measured with

trigger

when to summarise

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
@Experimental

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental

Writes the summary a SummarizationMiddleware keeps (design §4.34).

Writes the summary a SummarizationMiddleware keeps (design §4.34).

compress returns a summary of previous - the summary so far, if any - followed by messages, the messages after it, never those it already covers: a summary is extended, not recomputed. It should stay within maxTokens estimated tokens at four characters a token; the middleware cuts what it returns to that bound either way.

A compressor that calls a model must call it through context.accounted(client), so the call is counted in the thread's usage, also when the model step later fails. Its result is pure state: when the model step runs again (recover), it is called again.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
@Experimental

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental

When a SummarizationMiddleware summarises, measured on the outgoing request.

When a SummarizationMiddleware summarises, measured on the outgoing request.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class Todo

One item of an agent's plan. id is assigned by the write_todos tool and stays with the item while the model keeps it in the list; it is never given to another item of the same thread.

One item of an agent's plan. id is assigned by the write_todos tool and stays with the item while the model keeps it in the list; it is never given to another item of the same thread.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object Todo

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Todo.type
@Experimental
final case class TodoConfig

The settings of a harness's TodoMiddleware; see its parameters.

The settings of a harness's TodoMiddleware; see its parameters.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object TodoConfig

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TodoConfig.type
@Experimental
final case class TodoList

A thread's plan, as TodoMiddleware.key stores it: the todos in order, and nextId, the number the next new todo's id takes, so no id is reused within the thread.

A thread's plan, as TodoMiddleware.key stores it: the todos in order, and nextId, the number the next new todo's id takes, so no id is reused within the thread.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object TodoList

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TodoList.type
@Experimental
final case class TodoMark(id: String, status: TodoStatus)

A todo's id and status, without its content.

A todo's id and status, without its content.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final class TodoMiddleware(val maxTodos: Int, val maxTodoChars: Int, val id: MiddlewareId) extends AgentMiddleware

A plan for the agent: a write_todos tool that replaces the thread's todo list, and a prompt section that shows the list to the model on every model step (design §4.30).

A plan for the agent: a write_todos tool that replaces the thread's todo list, and a prompt section that shows the list to the model on every model step (design §4.30).

  • The tool takes the whole list - content, status (pending, in_progress, done) and, to keep an item, its id - and stores it in TodoMiddleware.key. An item without an id keeps the id of an unclaimed todo with the same content, or takes a fresh one; an id is never reused within a thread. A list of more than maxTodos items, an item whose content is empty or over maxTodoChars code points, an id given twice, or an id the list does not have, is refused as a tool error the model sees. The tool locks todos, so two calls in one model message run in turn, the second seeing the first's list.
  • The sections: todos-guide, cacheable, on how to use the tool; and todos, the current plan, while it is not empty. Both are bounded by the limits whatever the stored list holds: at most maxTodos todos are shown, each cut to maxTodoChars code points.
  • Events: each change emits a durable HarnessEvents.TodosUpdated (ids and statuses) and a live HarnessEvents.TodosProgress (the whole list).

The plan guides the model only: it never routes, filters tools, or changes a permission. write_todos is a tool like any other, so a PermissionMiddleware decides it by its default resource, invoke write_todos. An output Block restores the list to its value before the turn.

The key, and the lock schedule the tool's lock needs, are registered only by an agent family with a TodoMiddleware: adding one to an existing agent changes its graph's structure.

Value parameters

maxTodoChars

the most code points one todo's content may hold; at least 1

maxTodos

the most todos one list may hold; at least 1

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
@Experimental

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
enum TodoStatus

Where a Todo stands. On the wire, and in the write_todos schema: pending, in_progress, done.

Where a Todo stands. On the wire, and in the write_todos schema: pending, in_progress, done.

Attributes

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object TodoStatus

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
TodoStatus.type
@Experimental
final case class TodosProgress(todos: Vector[Todo])

The plan after a change, content included; live only.

The plan after a change, content included; live only.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final case class TodosUpdated(todos: Vector[TodoMark])

The plan after a change, as ids and statuses in order; durable, so it carries no content.

The plan after a change, as ids and statuses in order; durable, so it carries no content.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
final class ToolOutputOffload(val thresholdTokens: Int, val maxResultBytes: Long, val maxTotalBytes: Long, val id: MiddlewareId) extends AgentMiddleware

Keeps a large tool result out of the conversation (design §4.34). A Success whose text is over thresholdTokens estimated tokens (four characters a token) is stored in ToolOutputOffload.key, cut to maxResultBytes, and the model is shown instead a header naming the path /large_tool_results/<idempotencyKey> and the first lines of the text. OffloadBackend, mounted at ToolOutputOffload.Mount in a CompositeBackend, serves the stored results to file tools, read-only.

Keeps a large tool result out of the conversation (design §4.34). A Success whose text is over thresholdTokens estimated tokens (four characters a token) is stored in ToolOutputOffload.key, cut to maxResultBytes, and the model is shown instead a header naming the path /large_tool_results/<idempotencyKey> and the first lines of the text. OffloadBackend, mounted at ToolOutputOffload.Mount in a CompositeBackend, serves the stored results to file tools, read-only.

  • Identity. The path is the call's IdempotencyKey, the runtime's identity of the call: a provider that reuses a tool call id cannot make an older result's path name a newer call's content, and a rerun of the same call (recover) replaces its own entry.
  • The bound. The stored results are at most maxTotalBytes, as a checkpoint stores them: each update evicts the oldest until they fit, when it is applied, so the bound holds under a parallel batch and whether or not a SummarizationMiddleware runs. Reading an evicted path is a tool error that says so.
  • Content parts. Only text is offloaded. Every non-text part of a result is passed on as it is, after the preview.
  • Cleanup. With a SummarizationMiddleware, results whose path appears in a tool result the summary covers are dropped at the next model step. The bound does not depend on it. The summariser runs outside this middleware - build() refuses the other order (SummarizationMiddleware.placement).

An output Block restores the key, so a blocked turn's results are never kept.

Value parameters

maxResultBytes

the most bytes of one stored result; at least 1 and at most maxTotalBytes

maxTotalBytes

the most bytes all stored results take together

thresholdTokens

a result over this many estimated tokens is offloaded; at least 1000

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
@Experimental

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental

Which of a HarnessProfile's tools - the file tools and execute - the agent gets.

Which of a HarnessProfile's tools - the file tools and execute - the agent gets.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
@Experimental
object VPath

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
VPath.type

Types

opaque type VPath

A path in a FileBackend's own space: absolute, /-separated, with non-empty segments, none of them . or .., and no NUL, backslash or control character. Nothing is normalised away: /a/../b is refused, not rewritten, so a path names what it says. One trailing / is dropped, so /src/ is /src. At most 1024 UTF-8 bytes in all, and 255 per segment.

A path in a FileBackend's own space: absolute, /-separated, with non-empty segments, none of them . or .., and no NUL, backslash or control character. Nothing is normalised away: /a/../b is refused, not rewritten, so a path names what it says. One trailing / is dropped, so /src/ is /src. At most 1024 UTF-8 bytes in all, and 255 per segment.

It encodes as a JSON string, and its reader refuses an invalid one.

Attributes