Run inference.sh apps as agent tools.
Basic Usage
1from inferencesh import app_tool23image_gen = (4 app_tool("generate_image", "infsh/flux@latest")5 .describe("Generate images from text prompts")6 .build()7)How It Works
When the agent calls an app tool:
- A task is created for the referenced app
- Tool arguments become task input
- Task output becomes tool result
- Agent continues with the result
Builder Methods
| Method | Description |
|---|---|
appTool(name, ref) | Create app tool with app reference |
.describe(text) | Set description for LLM |
.display(name) | Human-readable name |
.setup({...}) | Pre-configured setup values (hidden from agent) |
.input({...}) | Default input values (agent can override) |
.function(name) | Specify which function to call (for multi-function apps) |
.sessionEnabled() | Enable session support (agent controls sessions) |
.requireApproval() | Require user approval |
.build() | Build the tool |
App Reference Formats
code
1# Latest version2namespace/app-name@latest34# Specific version5namespace/app-name@abc123Examples
Image Generation
1image_gen = (2 app_tool("generate_image", "infsh/flux@latest")3 .describe("Generate an image from a text prompt")4 .build()5)67agent = client.agent({8 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },9 "tools": [image_gen]10})1112response = agent.send_message("Generate a picture of a sunset")13# Agent calls generate_image, waits for result, then respondsText-to-Speech & Code Execution
1tts = (2 app_tool("speak", "infsh/tts@latest")3 .describe("Convert text to speech audio")4 .build()5)67code_runner = (8 app_tool("run_code", "infsh/code-interpreter@latest")9 .describe("Execute Python code and return the result")10 .build()11)With Approval
1expensive_model = (2 app_tool("analyze", "expensive/model@latest")3 .describe("Deep analysis using expensive model")4 .require_approval() # User must approve before running5 .build()6)Setup & Default Inputs
Configure app tools with pre-set values that persist across calls.
1# Setup: One-time configuration (API keys, model selection)2# Input: Default values the agent can override34transcribe = (5 app_tool("transcribe", "infsh/whisper@latest")6 .describe("Transcribe audio to text")7 .setup({8 "model": "large-v3", # Always use this model9 "language": "auto" # Auto-detect language10 })11 .input({12 "timestamps": True, # Default: include timestamps13 "format": "srt" # Default output format14 })15 .build()16)How values are merged:
- Setup values are passed on every call — the agent never sees them
- Input values are defaults — the agent's arguments override them
Multiple App Tools
1agent = client.agent({2 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },3 "tools": [4 app_tool("generate_image", "infsh/flux@latest")5 .describe("Generate images").build(),6 app_tool("transcribe", "infsh/whisper@latest")7 .describe("Transcribe audio").build(),8 app_tool("run_code", "infsh/code-interpreter@latest")9 .describe("Run Python code").build(),10 ]11})Function Selection
For multi-function apps, specify which function to expose as a tool using .function().
1# Same app, different functions as separate tools2generate = (3 app_tool("generate_image", "infsh/sdxl@latest")4 .describe("Generate an image from a text prompt")5 .function("generate")6 .build()7)89upscale = (10 app_tool("upscale_image", "infsh/sdxl@latest")11 .describe("Upscale an existing image to higher resolution")12 .function("upscale")13 .build()14)1516agent = client.agent({17 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },18 "tools": [generate, upscale]19})If not specified, the app's default function is used.
Session Support
Enable session support for stateful interactions where the agent controls session creation and continuation.
1browser = (2 app_tool("browser", "infsh/browser-use@latest")3 .describe("Control a web browser to navigate and interact with pages")4 .session_enabled() # Agent can manage sessions5 .build()6)How Sessions Work
When session support is enabled:
- Tool schema includes a
sessionparameter - Agent passes
session: "new"to start a new session - Tool output includes
session_id(e.g.,sess_abc123) - Agent passes
session: "sess_abc123"in subsequent calls to continue
Example Agent Behavior
code
1User: "Go to example.com and click the login button"23Agent: [calls browser({action: "navigate", url: "https://example.com", session: "new"})]4> Output: {result: "Page loaded", session_id: "sess_abc123"}56Agent: [calls memory_set(key: "browser_session", value: "sess_abc123")]7> Stored session ID for later use89Agent: [calls browser({action: "click", selector: "#login", session: "sess_abc123"})]10> Output: {result: "Clicked login button", session_id: "sess_abc123"}The agent uses its memory tools to track session IDs across turns.