Skip to main content

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.

FlueSession is the conversation thread within a harness. It holds message history and exposes the core methods for driving agent interactions: prompt(), skill(), task(), shell(), and compact(). Obtain a session via harness.session().

Properties

name
string
The session name. Defaults to "default".
fs
FlueFs
Out-of-band filesystem access — same interface as harness.fs. Operations do not appear in the conversation transcript. See FlueHarness for the full FlueFs method table.

prompt(text, options?)

Send a user message and get a response. The LLM takes one or more turns (calling tools, thinking, producing text) before returning.
// Plain text response
const response = await session.prompt('Summarize the codebase in 3 bullet points.');
console.log(response.text);

// Typed structured result
import * as v from 'valibot';
const { data } = await session.prompt('What is 2 + 2?', {
  result: v.object({ answer: v.number() }),
});
console.log(data.answer); // 4
text
string
required
The user message to send.
options.result
Valibot schema
Schema for structured output. When provided, the response includes a typed data field and the return type becomes PromptResultResponse<T>.
options.role
string
Call-scoped role override. Overrides session and harness roles.
options.model
string
Call-scoped model override ('provider/model-id'). Overrides role and harness model.
options.thinkingLevel
'off' | 'low' | 'medium' | 'high'
Reasoning effort for this call. Overrides role and harness thinkingLevel.
options.tools
ToolDef[]
Additional call-scoped tools. Names must not conflict with built-in or harness tools.
options.images
PromptImage[]
Images to attach to the user message. Requires a vision-capable model. Each image is { type: 'image', data: base64string, mimeType: string }.
options.signal
AbortSignal
Cancel this call. Rejects with AbortError.
Returns CallHandle<PromptResponse> or CallHandle<PromptResultResponse<T>> when result is provided.

skill(name, options?)

Invoke a reusable skill defined as a Markdown file in .agents/skills/. The model reads the skill file from disk at call time — editable mid-session without re-initializing.
// Reference by frontmatter name
const { data } = await session.skill('triage', {
  args: { issueNumber: 42 },
  result: v.object({
    severity: v.picklist(['low', 'medium', 'high', 'critical']),
    reproducible: v.boolean(),
  }),
});

// Reference by relative path
await session.skill('triage/reproduce.md', { args: { issueNumber: 42 } });
name
string
required
Skill name (from frontmatter name:) or relative path under .agents/skills/.
options.args
Record<string, unknown>
Arguments passed into the skill template.
options.result
Valibot schema
Schema for structured output.
options.role
string
Call-scoped role override.
options.model
string
Call-scoped model override.
options.thinkingLevel
'off' | 'low' | 'medium' | 'high'
Reasoning effort for this call.
options.signal
AbortSignal
Cancel this call.
Returns CallHandle<PromptResponse> or CallHandle<PromptResultResponse<T>>.

task(text, options?)

Launch a detached child agent in a separate session for focused, one-shot work. Shares the same sandbox and filesystem as the parent, but gets its own message history. The LLM can also call the task tool autonomously during prompt() and skill() calls.
const research = await session.task(
  'Research the auth flow and summarize the key files.',
  { cwd: '/workspace/project', role: 'researcher' }
);

const plan = await session.prompt(
  `Use this research to draft the implementation plan:\n\n${research.text}`
);
text
string
required
The task prompt for the child agent.
options.cwd
string
Working directory for the child session. Defaults to the parent session’s cwd.
options.result
Valibot schema
Schema for structured output.
options.role
string
Role for the child agent.
options.model
string
Model for the child agent.
options.signal
AbortSignal
Cancel this task.
Returns CallHandle<PromptResponse> or CallHandle<PromptResultResponse<T>>.

shell(command, options?)

Run a shell command. Unlike harness.shell(), this call is recorded in the conversation transcript, making the output visible to the model in subsequent turns.
const { stdout, exitCode } = await session.shell('git log --oneline -5');
command
string
required
Shell command to execute.
options.cwd
string
Working directory.
options.env
Record<string, string>
Additional environment variables.
options.signal
AbortSignal
Cancel this call.
Returns CallHandle<ShellResult>{ stdout, stderr, exitCode }.
Use harness.shell() for setup work the model shouldn’t see (e.g. cloning a repo before starting a session). Use session.shell() when the output should be visible to the model in the conversation.

compact()

Trigger context compaction on demand. Summarizes older messages to free context window space — the same operation that runs automatically when the session approaches the token limit.
await session.compact();
  • Resolves as a no-op if there is nothing to compact.
  • Throws if another operation (prompt, skill, task, shell) is in-flight on this session.
  • Emits compaction_start (with reason: "manual") followed by compaction events.

delete()

Delete this session’s stored conversation state.
await session.delete();

Response types

PromptResponse

Returned by prompt(), skill(), and task() without a result schema.
text
string
The model’s final text output.
usage
PromptUsage
Aggregated token and cost usage for the entire call (all turns, retries, and any compaction triggered during the call).
model
PromptModel
The model selected for the call’s primary turn ({ id: string }).

PromptResultResponse<T>

Returned when a result schema is provided.
data
T
The schema-validated structured output. Replaces the deprecated result field.
usage
PromptUsage
Token and cost usage.
model
PromptModel
Selected model for the call.

PromptUsage

input
number
Input tokens consumed.
output
number
Output tokens produced.
cacheRead
number
Tokens read from prompt cache.
cacheWrite
number
Tokens written to prompt cache.
totalTokens
number
Sum of all token counts.
cost.total
number
Total cost in the provider’s pricing unit (USD for Anthropic, OpenAI, etc.). Computed as (rate_per_million / 1_000_000) * tokens.

Build docs developers (and LLMs) love