Documentation
¶
Overview ¶
Package logos provides a reusable stateless agent loop.
Run() executes one agent loop iteration: prompt → LLM → tool calls → response. The caller provides conversation history, a system prompt, tools, and an optional sandbox env. No persistence — the caller receives StepMessages and handles storage.
Plane: shared
Index ¶
- Constants
- func BuildSystemPrompt(data PromptData) (string, error)
- func ContainsToolCallHallucination(text string) bool
- type AllowedPath
- type BlockRunner
- type Callbacks
- type CommandDoc
- type CommandResult
- type Config
- type PromptData
- type RunBlockRequest
- type RunBlockResponse
- type RunResult
- type StepMessage
- type StepRole
Constants ¶
const DefaultMaxSteps = 30
DefaultMaxSteps is the fallback max steps when Config.MaxSteps is 0.
const DefaultMaxTokens = 16384
DefaultMaxTokens is the fallback max output tokens when Config.MaxTokens is 0.
const MaxHallucinationRetries = 3
MaxHallucinationRetries is the maximum number of tool call hallucination retries before Run() returns an error.
Variables ¶
This section is empty.
Functions ¶
func BuildSystemPrompt ¶
func BuildSystemPrompt(data PromptData) (string, error)
BuildSystemPrompt renders the default system prompt with runtime context. The result is the base prompt — consumers append their own instructions after this.
func ContainsToolCallHallucination ¶ added in v0.8.0
ContainsToolCallHallucination returns true if text contains tool call patterns produced by models that hallucinate structured formats — XML tags (e.g. <tool_call>) or bracket delimiters (e.g. [TOOL_CALL]...[/TOOL_CALL]). Standalone utility — internal detection is handled by streamFilter during streaming.
Types ¶
type AllowedPath ¶ added in v0.3.0
type AllowedPath = client.AllowedPath
AllowedPath specifies a filesystem path allowed in the sandbox.
type BlockRunner ¶ added in v1.1.0
type BlockRunner interface {
RunBlock(ctx context.Context, req RunBlockRequest) (*RunBlockResponse, error)
}
BlockRunner executes a block of commands in the sandbox. *client.Client satisfies this interface automatically.
func NewClient ¶ added in v0.3.0
func NewClient(addr string) (BlockRunner, error)
NewClient creates a BlockRunner connected to a temenos daemon. addr formats:
- Empty string: resolve from TEMENOS_LISTEN_ADDR → TEMENOS_SOCKET_PATH → default socket
- Starts with "/" or ".": unix socket path
- Starts with "http://": HTTP base URL (TCP)
- Otherwise (e.g. ":8081", "localhost:8081"): TCP
type Callbacks ¶
type Callbacks struct {
// OnDelta is called with each text delta as the LLM streams its response.
OnDelta func(text string)
// OnCommandResult is called after a command executes with the command string,
// raw combined stdout+stderr output (no exit code suffix), and the exit code.
// Fires once per CommandResult from the batch response.
OnCommandResult func(command string, output string, exitCode int)
// OnRetry is called when a tool call hallucination (XML or bracket) is detected
// and an "unprocessed" directive is injected. reason is "tool_call".
OnRetry func(reason string, step int)
}
Callbacks holds optional streaming callbacks for the agent loop. All fields are nil-safe — unset callbacks are simply not called.
type CommandDoc ¶ added in v0.9.0
type CommandDoc struct {
Name string // command name, e.g. "url", "web", "rg"
Summary string // one-line description shown under the heading
Help string // full help text (flags, examples, caveats)
}
CommandDoc describes a command available to the agent. Callers provide these to control which commands appear in the system prompt.
type CommandResult ¶ added in v1.1.0
type CommandResult = client.CommandResult
CommandResult is one command's execution result within a block.
type Config ¶
type Config struct {
Provider fantasy.Provider
Model string
SystemPrompt string
MaxSteps int // 0 means use default (DefaultMaxSteps)
MaxTokens int // 0 means use default (DefaultMaxTokens)
Temenos BlockRunner
SandboxEnv map[string]string // env vars passed to temenos per-request
// AllowedPaths lists filesystem paths accessible during command execution.
// Path validation (non-empty, absolute) is enforced by the temenos daemon.
AllowedPaths []AllowedPath
// Prefix is the command prefix the LLM uses (e.g. "§ ").
// Passed to RunBlock so temenos can parse commands. Defaults to "§ ".
Prefix string
}
Config holds everything needed to run one agent loop iteration.
type PromptData ¶
type PromptData struct {
WorkingDir string
Platform string
Date string
Commands []CommandDoc // caller-provided command documentation
}
PromptData holds the runtime context used to render the default system prompt.
type RunBlockRequest ¶ added in v1.1.0
type RunBlockRequest = client.RunBlockRequest
RunBlockRequest is the request payload for batch block execution.
type RunBlockResponse ¶ added in v1.1.0
type RunBlockResponse = client.RunBlockResponse
RunBlockResponse is the response from batch block execution.
type RunResult ¶
type RunResult struct {
Response string // final text response (accumulated assistant text)
Steps []StepMessage // all messages generated (for persistence by caller)
}
RunResult contains the agent's output after a loop completes.
type StepMessage ¶
type StepMessage struct {
Role StepRole
Content string
Reasoning string // thinking block text (empty if no reasoning)
ReasoningSignature string // provider signature for round-trip
Timestamp time.Time
}
StepMessage represents one message generated during the agent loop.