ask

package
v0.1.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ask is Lagrange's convention for questions an agent puts to a person: multiple-choice questions, like Claude Code's plan-mode questions (each has a few options to pick one or several of, and the person can write their own answer in clients that allow it), and approvals (a yes/no on what the message says).

Both travel in the message metadata, next to a plain text rendering, so a client that knows neither still shows something to answer:

  • MetaKey holds the questions; the answer is a text message, one line per question (see Format).
  • ApprovalKey (true) marks an approval; the answer is the decision "approve" or "reject" (POST /api/tasks/{id}/answer), which completes or rejects the task.

Clients with buttons (the web inbox, Telegram) render both as buttons.

Index

Constants

View Source
const (
	// MetaKey is the message metadata key that carries the questions.
	MetaKey = "https://threeagents.dev/ext/questions"
	// LegacyMetaKey is the key Halo used before the questions moved to Lagrange; Parse
	// still reads it.
	LegacyMetaKey = "https://threeagents.dev/ext/halo/questions"
	// ApprovalKey marks a message that asks to approve or reject (metadata true).
	ApprovalKey = "https://threeagents.dev/ext/approval"
)
View Source
const (
	MaxQuestions = 4
	MinOptions   = 2
	MaxOptions   = 5
)

Limits keep a form small enough to answer at a glance.

Variables

This section is empty.

Functions

func ApprovalField

func ApprovalField(schema *jsonschema.Schema) (string, bool)

ApprovalField returns the boolean field of a structured input form that a plain approve or reject can answer: the form has exactly one boolean field, and every other field is optional (an approval with an optional note).

func Format

func Format(qs []Question, as []Answer) string

Format renders the answers for the lead, one line per question.

func IsApproval

func IsApproval(meta map[string]any) bool

IsApproval reports whether metadata marks an approval.

func Text

func Text(qs []Question) string

Text renders the questions as plain text, for clients without the form.

func Validate

func Validate(qs []Question) error

Validate checks a form against the limits.

Types

type Answer

type Answer struct {
	Picked []int
	Other  string
}

Answer is the human's answer to one question: the options picked (by index), and their own words, which may stand alone or add to the picks.

type Option

type Option struct {
	Label       string `json:"label" jsonschema:"1-5 words; put the recommended option first and end its label with (Recommended)"`
	Description string `json:"description,omitempty" jsonschema:"one sentence: what picking it means, its trade-off"`
}

Option is one answer to pick.

type Question

type Question struct {
	Header      string   `json:"header" jsonschema:"a 1-2 word tag for the question, like Auth or Scope"`
	Question    string   `json:"question" jsonschema:"the whole question, ending with a question mark"`
	Options     []Option `json:"options" jsonschema:"2-5 distinct choices; the human can always write their own instead"`
	MultiSelect bool     `json:"multi_select,omitempty" jsonschema:"true when several options can apply together"`
}

Question is one question of a form.

func Parse

func Parse(meta map[string]any) []Question

Parse reads the questions from message metadata, or nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL