Python API¶
The Python API centers on init, PyFlueAgent, and PyFlueSession.
init¶
from pyflue import init
agent = await init(
model="openai:gpt-5.5",
harness="deepagents",
sandbox="virtual",
skills_dir=".agents/skills",
allow_write=False,
allow_shell=False,
allowed_commands=("pytest", "git"),
)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
str | None |
config value | Model identifier passed to the backend. |
harness |
str | None |
deepagents |
Harness backend name. |
sandbox |
str | None |
virtual |
Sandbox name. |
skills_dir |
str | Path | None |
.agents/skills |
Skill directory. |
config_path |
str | Path | None |
pyflue.toml |
Config file path. |
env |
dict[str, str] | None |
{} |
Runtime environment metadata. |
allow_write |
bool |
False |
Enable sandbox writes. |
allow_shell |
bool |
False |
Enable sandbox shell execution. |
allowed_commands |
tuple[str, ...] \| list[str] \| None |
config value | Optional command grant list. |
allow_compound_commands |
bool \| None |
config value | Allow shell operators and redirects. |
PyFlueAgent.session¶
If no session id is supplied, PyFlue uses default.
PyFlueSession.prompt¶
With typed output:
Use a role:
Override the model for a single call:
PyFlueSession.skill¶
PyFlueSession.stream¶
The stream emits normalized events:
PyFlueSession.subagent¶
subagent creates a child PyFlue session with isolated history and the same
sandbox.
PyFlueSession.task¶
task is the Flue-style child-agent primitive. It shares the parent sandbox
and uses an isolated child history.
Python Backend¶
When a Python backend is configured, use run_python:
Filesystem Helpers¶
Writes require allow_write=True.
Shell Helper¶
Shell execution requires allow_shell=True.
Grant secrets only for the command that needs them: