org.llm4s.agent.harness

Members list

Type members

Classlikes

@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. Live (current subscribers only): TodosProgress.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
@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 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