Inside an agent handler,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/withastro/flue/llms.txt
Use this file to discover all available pages before exploring further.
init() creates a harness — a configured handle for model defaults, tools, sandbox, and sessions. From the harness you open sessions. From sessions you send prompts, run tasks, and execute shell commands.
Terminology
init(AgentInit) — create a harness
AgentInit:
| Option | Type | Description |
|---|---|---|
model | string | false | Required. Default model for all calls in this harness. Format: 'provider/model-id'. Pass false to require every call to supply its own model via a role or call-site override. |
name | string | Harness name. Defaults to "default". Use a different name when one run needs multiple isolated harness scopes. |
cwd | string | Working directory for context discovery (AGENTS.md, .agents/skills/), tool defaults, and shell calls. Defaults to the sandbox’s own cwd. |
sandbox | false | SandboxFactory | BashFactory | Sandbox to use. Omit or pass false for the default in-memory virtual sandbox. See Sandboxes. |
role | string | Harness-wide default role. Overridden by session-level or per-call roles. |
thinkingLevel | 'off' | 'low' | 'medium' | 'high' | Default reasoning effort. Precedence: call > role > harness. Defaults to 'medium' when nothing is set. |
tools | ToolDef[] | Harness-wide custom tools. Available to every session call. |
compaction | false | CompactionConfig | Context window compaction. Omit for model-aware defaults. Pass false to disable automatic threshold compaction. |
Multiple harnesses in one run
Pass a uniquename when one agent run needs multiple isolated harness scopes — for example, a setup phase and a project phase that share the same sandbox but discover different AGENTS.md contexts:
harness.session(name?, options?) — open a session
id (the URL segment) to continue a conversation. Open multiple named sessions within one harness for parallel conversation branches.
Explicit session management
harness.sessions gives you lower-level control:
session.prompt(text, options?) — send a message
prompt() sends a user message and returns when the model completes its response, including any tool calls.
prompt() options
| Option | Type | Description |
|---|---|---|
result | valibot schema | Parse and validate the model’s response as structured JSON. Returns { data }. |
role | string | Override the role for this call only. |
model | string | Override the model for this call only. |
thinkingLevel | ThinkingLevel | Override reasoning effort for this call. |
tools | ToolDef[] | Additional tools scoped to this call only. |
images | PromptImage[] | Inline images attached to the user message. Requires a vision-capable model. |
signal | AbortSignal | Cancel this call. |
session.task(text, options?) — run a focused child agent
task() opens a detached child session with its own message history. Tasks share the same sandbox and filesystem, but discover their own AGENTS.md and .agents/skills/ from their working directory.
The LLM can also call the
task tool autonomously during prompt() and skill() calls. You don’t need to call session.task() explicitly — the model decides when to delegate parallel research or exploration work on its own.When to use task() vs a new session.prompt()
Use task() when you want a focused, one-shot result with its own clean context. Use session.prompt() when you want to continue the same conversation and have the model build on prior turns.
session.shell() vs harness.shell()
Both run shell commands in the sandbox. The key difference is whether the command appears in the conversation history.
Use
session.shell() when the command output should be visible to the model in subsequent turns. Use harness.shell() for setup work (cloning repos, installing deps) that the model doesn’t need to reason about.{ stdout, stderr, exitCode }.
Shell options:
| Option | Type | Description |
|---|---|---|
cwd | string | Working directory for this command. |
env | Record<string, string> | Extra environment variables. |
signal | AbortSignal | Cancel this command. |
session.fs / harness.fs — out-of-band file operations
FlueFs lets you read and write files in the sandbox without recording anything in the conversation. Use it for staging files, capturing artifacts, and managing scratch space that the model shouldn’t see.
fs.
FlueFs methods:
| Method | Description |
|---|---|
readFile(path) | Read a UTF-8 file. |
readFileBuffer(path) | Read a file as raw bytes. |
writeFile(path, content) | Write content to a file, creating it if needed. |
stat(path) | Get file metadata (size, mtime, type flags). |
readdir(path) | List directory entries (names only). |
exists(path) | Check if a path exists. Never throws. |
mkdir(path, options?) | Create a directory. Pass { recursive: true } for mkdir -p semantics. |
rm(path, options?) | Remove a file or directory. Pass { recursive: true, force: true } for rm -rf semantics. |