Autonomous Agent Compute & Execution
Deploy multi-turn reasoning loops, autonomous coding workflows, web intelligence agents, and tool-augmented workflows powered by Claude Opus 4.6, DeepSeek R1, and Google Gemini.
The Agent Compute Engine (server/agent-compute/ on port 8795) orchestrates dynamic tool calling, skill execution, persistent workspace file storage, real-time Server-Sent Events (SSE) streaming, and Human-in-the-Loop controls.
API Environment
- Base URL:
https://apis.fotohub.app/compute/v1 - Region:
eu-central-1(Frankfurt, AWS) - Billing: 100% USD prepaid wallet. NO PLN, NO credits. Minimum $0.50 balance to provision agents.
- Auth:
Authorization: Bearer fh_live_YOUR_API_KEY
Agent Lifecycle State Machine
The FOTOhub autonomous agent execution follows a rigorous state machine, ensuring deterministic progress, strict budget constraints, and secure boundaries for sandbox executions.
stateDiagram-v2
[*] --> created: POST /compute/v1/tasks/create
created --> planning: Initialize Engine & Context
planning --> executing_step: Select Tool / Action
executing_step --> tool_running: Dispatch to Sandbox / Web
tool_running --> evaluating_result: Tool Completed
evaluating_result --> executing_step: Next Step Needed
executing_step --> awaiting_approval: Requires Human Clarification
awaiting_approval --> executing_step: POST /compute/v1/tasks/{id}/respond
evaluating_result --> completed: Goal Satisfied
executing_step --> failed: Unrecoverable Error
awaiting_approval --> cancelled: User Cancels
completed --> [*]
failed --> [*]
cancelled --> [*]Architecture Deep Dive: Agent-Compute Orchestrator
The FOTOhub Agent-Compute Orchestrator is designed for high-throughput, low-latency agentic loops. It runs on our proprietary event-driven infrastructure, ensuring that every tool invocation, context window update, and streaming output is processed efficiently.
The Tool Calling Loop
At the heart of the orchestrator is the Tool Calling Loop. When an agent receives an objective, the orchestrator:
- Context Initialization: Loads the prompt, system instructions, and available tools into the model's context window.
- Action Generation: The model predicts the next best action (e.g., call a tool or yield the final answer).
- Sandbox Dispatch: If a tool requires execution (like Python code), the orchestrator securely dispatches it to the Firecracker microVM endpoint (
https://apis.fotohub.app/sandbox/exec-python). - Result Ingestion: The output from the tool (stdout, stderr, or structured JSON) is appended to the context window.
- Re-evaluation: The loop restarts until the model dictates the goal is met or the
max_stepslimit is hit.
Firecracker MicroVM Execution
All arbitrary code execution generated by agents happens within ephemeral Firecracker microVMs. These sandboxes are completely isolated from the FOTOhub control plane.
- Fast Boot Times: MicroVMs boot in under 150ms.
- Resource Constraints: Each VM is hard-capped on RAM and CPU based on your selected tier.
- Network Isolation: By default, sandboxes have restricted egress unless explicitly granted web access.
Available Agent Models & Pricing
FOTOhub provides access to industry-leading models, each optimized for different agentic tasks.
USD Billing Only
All services on FOTOhub are billed strictly in USD against your prepaid wallet. There are no credits or alternative currencies accepted (NO PLN). You must maintain a minimum of $0.50 to provision compute resources.
Language Models
| Model | Provider | Context Window | Best For | Price (Input / 1M) | Price (Output / 1M) |
|---|---|---|---|---|---|
| Claude 3 Opus (4.6) | Anthropic | 200K tokens | Complex reasoning, large refactors, autonomous software engineering | $15.00 | $75.00 |
| Claude 3.5 Sonnet | Anthropic | 200K tokens | Fast coding, tool use, web automation | $3.00 | $15.00 |
| DeepSeek R1 | DeepSeek | 128K tokens | Advanced mathematical reasoning, logic puzzles, optimization algorithms | $1.00 | $3.00 |
| Gemini 2.0 Flash | 1M tokens | High-volume document analysis, multimodal processing | $0.35 | $1.05 | |
| GPT-4o | OpenAI | 128K tokens | General purpose, versatile text/vision tasks, reliable tool calling | $5.00 | $15.00 |
Dedicated Compute Instances
Agents can provision dedicated GPU/CPU resources on-demand or spot for background workloads. Prices are listed per hour.
| Instance Family | Specs | Spot Price ($/hr) | On-Demand Price ($/hr) |
|---|---|---|---|
| G5.xlarge | A10G (24GB VRAM) | $0.38 | $1.01 |
| G4dn.xlarge | T4 (16GB VRAM) | $0.20 | $0.53 |
| T3, C5, M5, R5 | CPU optimized | Varies | Varies |
Storage & Egress
- FOTOhub S3 (
s1.fotohub.app): $0.0245 / GB-month. Intra-cluster egress is FREE. - EBS gp3: $0.08 / GB-month.
- EBS io2: $0.125 / GB-month (Supports up to 64K IOPS).
Tool Categories Available to Agents
Agents are heavily augmented with a suite of native tools. You can specify which tools are available during task creation using the skills array.
1. File Operations
Agents can read, write, patch, and delete files within their persistent workspace.
read_file: Load contents up to 10MB.write_to_file: Overwrite or create new files.replace_file_content: Precise regex or line-range replacements.list_dir: Traverse directory structures.
2. Code Execution (Sandbox)
Agents can execute code in a secure Firecracker sandbox via https://apis.fotohub.app/sandbox/exec-python.
execute_python: Run Python scripts with pre-installed data science packages.execute_bash: Run shell commands, install apt packages ephemerally.execute_nodejs: Run JavaScript/TypeScript tasks.
3. Web Search & Intelligence
search_web: Perform Google-like searches to find real-time information.read_url: Scrape and extract markdown content from public URLs.read_browser_page: Headless browser access for scraping SPA/React applications.
4. FOTOhub Native API Integrations
provision_instance: Spin up a G4dn or G5 instance directly from an agent.upload_to_s3: Store generated artifacts in FOTOhub S3.query_database: Connect to managed FOTOhub PostgreSQL or Redis instances.
5. HTTP Requests
fetch_api: Construct raw HTTP GET/POST/PUT requests to interact with third-party webhooks and REST APIs.
Persistent Workspaces
Every FOTOhub user gets an isolated, persistent filesystem available to their agents.
- Path:
/data/workspaces/{user_id}/ - Persistence: Files survive across individual agent runs. If Agent A generates a dataset on Monday, Agent B can process it on Tuesday.
- Limitations: Workspace storage is billed at the EBS gp3 rate ($0.08/GB-month).
You can pass relative or absolute paths within /workspace/ to the agent, and they automatically map to your user's physical directory on the FOTOhub EBS volume.
Launching an Autonomous Task
Submit a multi-step objective with tool constraints, budget ceilings, and LLM selection:
from fotohub import FotoHub
import os
client = FotoHub(
api_key=os.environ["FOTOHUB_API_KEY"],
base_url="https://apis.fotohub.app/compute/v1"
)
task = client.post("/tasks/create", {
"prompt": """
1. Scrape the top 5 trending open-source AI repositories on GitHub today.
2. Extract their stars, authors, primary languages, and architecture summaries.
3. Generate a comparative Markdown report with an executive taxonomy.
4. Save the file to /workspace/reports/ai_trends_weekly.md.
""",
"model": "claude-opus-4.6",
"skills": ["web_research", "document_generation", "code_interpreter"],
"max_steps": 25,
"budget_limit_usd": 2.50
})
task_id = task["task_id"]
print(f"Task created: {task_id}")import { FotoHub } from "fotohub";
const client = new FotoHub({
apiKey: process.env.FOTOHUB_API_KEY!,
baseURL: "https://apis.fotohub.app/compute/v1"
});
async function dispatchAgent() {
const res = await client.post("/tasks/create", {
prompt: "Investigate customer error trace in /workspace/error.log, identify bug, and run unit tests to confirm fix.",
model: "claude-opus-4.6",
max_steps: 20,
budget_limit_usd: 1.50,
});
console.log("Agent running with Task ID:", res.data.task_id);
}
dispatchAgent();package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
apiKey := os.Getenv("FOTOHUB_API_KEY")
url := "https://apis.fotohub.app/compute/v1/tasks/create"
payload := map[string]interface{}{
"prompt": "Write a concurrent web scraper in Go and save it to /workspace/scraper.go",
"model": "claude-opus-4.6",
"max_steps": 15,
"budget_limit_usd": 1.00,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Task Launched, status:", resp.Status)
}curl -X POST https://apis.fotohub.app/compute/v1/tasks/create -H "Authorization: Bearer $FOTOHUB_API_KEY" -H "Content-Type: application/json" -d '{
"prompt": "Build a responsive React landing page for a coffee brand and save to /workspace/coffee-landing",
"model": "claude-opus-4.6",
"max_steps": 20,
"budget_limit_usd": 2.00
}'Budget Controls & Safeguards
To prevent runaway costs or infinite reasoning loops, FOTOhub enforces two strict limitations on all agent executions:
budget_limit_usd: The absolute maximum dollar amount the agent is allowed to spend. If the cumulative token cost across all API calls in the loop exceeds this value, the orchestrator immediately halts the agent with abudget_exceedederror.max_steps: The maximum number of tool invocation cycles. This prevents infinite loops where an agent fails to solve a problem and keeps trying the same tool repeatedly.
Strict Enforcement
Billing is done on a prepaid basis. If your overall account wallet drops below $0.00 during an execution, the agent is hard-killed regardless of your budget_limit_usd setting.
Real-Time SSE Token & Thought Streaming
Connect to GET /compute/v1/tasks/{task_id}/stream to receive real-time updates as the agent reasons, invokes tools, and generates artifacts.
FOTOhub utilizes Server-Sent Events (SSE) to push high-frequency updates, allowing you to render typing animations (via agent_delta events) and display agent thought processes seamlessly in your UI.
sequenceDiagram
autonumber
participant Client as Frontend / SDK
participant Engine as Agent Compute Server
participant Sandbox as MicroVM Sandbox
Client->>Engine: GET /compute/v1/tasks/{id}/stream
Engine-->>Client: event: task_status (planning)
Engine-->>Client: event: commentary ("Analyzing required packages...")
Engine-->>Client: event: tool_call (sandbox_python)
Engine->>Sandbox: Execute code
Sandbox-->>Engine: Execution OK (duration: 142ms)
Engine-->>Client: event: tool_result (output captured)
Engine-->>Client: event: agent_delta ("Based on the data...")
Engine-->>Client: event: done (Task finished successfully)SSE Event Stream Reference
| Event Name | Description | Payload Data Structure |
|---|---|---|
task_status | Status transition update | {"status": "planning" | "executing_step" | "completed"} |
commentary | Agent internal reasoning step | {"thought": "Evaluating regression coefficients..."} |
tool_call | Agent dispatched a tool | {"tool": "sandbox_python", "args": {"code": "..."}} |
tool_result | Tool output returned | {"tool": "sandbox_python", "success": true, "output": {...}} |
agent_delta | Streaming token fragment | {"content": "Here is the summary table:\n"} |
done | Task completed | {"task_id": "tsk_...", "total_steps": 12, "cost_usd": 0.42} |
error | Failure event | {"code": "budget_exceeded", "message": "Max budget reached"} |
Consuming SSE in TypeScript
const eventSource = new EventSource(
`https://apis.fotohub.app/compute/v1/tasks/${taskId}/stream?token=${FOTOHUB_API_KEY}`
);
eventSource.addEventListener("agent_delta", (e) => {
const data = JSON.parse(e.data);
process.stdout.write(data.content); // Stream tokens to console
});
eventSource.addEventListener("tool_call", (e) => {
const data = JSON.parse(e.data);
console.log(`[Agent called tool: ${data.tool}]`);
});
eventSource.addEventListener("done", (e) => {
const data = JSON.parse(e.data);
console.log(`
Task completed! Total Cost: $${data.cost_usd}`);
eventSource.close();
});Human-in-the-Loop Controls
For sensitive operations (deploying to production, deleting files, committing financial transactions), the agent can pause and await explicit user authorization.
1. Pausing a Task
Force an agent to suspend its current loop:
curl -X POST https://apis.fotohub.app/compute/v1/tasks/tsk_99a812df/pause -H "Authorization: Bearer $FOTOHUB_API_KEY"2. Responding to Agent Clarifications
When an agent reaches state awaiting_approval (because it encountered ambiguity or hit a secure boundary), submit your decision to unblock it:
curl -X POST https://apis.fotohub.app/compute/v1/tasks/tsk_99a812df/respond -H "Authorization: Bearer $FOTOHUB_API_KEY" -H "Content-Type: application/json" -d '{
"approved": true,
"user_feedback": "Proceed with deploying the migration to the staging database."
}'3. Cancelling a Task
Kill an agent execution completely:
curl -X POST https://apis.fotohub.app/compute/v1/tasks/tsk_99a812df/cancel -H "Authorization: Bearer $FOTOHUB_API_KEY"Webhook Notifications
If you do not want to keep an SSE connection open, you can register a webhook to be called upon agent task completion or failure.
Provide the webhook_url in the task creation payload:
{
"prompt": "Analyze log files...",
"model": "gpt-4o",
"webhook_url": "https://api.yourcompany.com/webhooks/fotohub-agent"
}The payload sent to your server will look like this:
{
"event": "task.completed",
"task_id": "tsk_1093jf2",
"status": "completed",
"duration_seconds": 145,
"cost_usd": 0.89,
"result": {
"summary": "Log analysis complete. Found 3 critical errors in auth module.",
"files_created": ["/workspace/analysis.md"]
}
}Complete Agent Task Examples
Example 1: Web Intelligence Pipeline
An agent is instructed to research competitors, compile pricing data, and generate a competitive analysis matrix.
- Model:
gemini-2.0-flash - Tools Used:
search_web,read_url,write_to_file - Result: Generates a 3,000-word markdown report autonomously in ~60 seconds for under $0.20.
Example 2: Multi-Step Data Science
An agent acts as a Junior Data Scientist.
- Prompt: "Download the Titanic dataset from Kaggle, clean the missing age values using median imputation, train a Random Forest model, and plot the feature importance matrix as a PNG."
- Tools Used:
execute_python,fetch_api - Result: Code runs in the Firecracker sandbox. The agent iterates if a Pandas error occurs, eventually saving
feature_importance.pngto your/workspace/volume.
Example 3: Full-Stack Code Generation
- Prompt: "Create a Next.js frontend with Tailwind CSS and a Node.js Express backend. They should communicate over WebSockets. Save the structure in
/workspace/chat-app/." - Tools Used:
execute_bash(to runnpx create-next-app),write_to_file(to write backend files). - Result: A complete, working monorepo scaffolded directly into the persistent workspace.
Example 4: Autonomous Content Pipeline
- Prompt: "Read the latest RSS feed from HackerNews. Pick the top 3 stories. Write a tweet thread for each. Post them to Twitter using my API keys stored in
/workspace/.env." - Tools Used:
fetch_api,read_file - Result: The agent parses the environment variables, formats the tweets, and executes the HTTP requests to the Twitter API.
Integration with Agent Engine (DAG Workflows)
Autonomous agents deployed via Compute can be orchestrated into complex directed acyclic graphs (DAGs) using the Agent Engine:
- Multi-Agent Swarm Consensus: Aggregate decisions from multiple autonomous agents via
/v1/swarm/consensus. - Vector Memory RAG: Store and retrieve long-term state across sessions via
/v1/memory/*. - Canary Deployments: Roll out agent logic changes safely with traffic routing via
/v1/workflows/{id}/canary. - Dead-Letter Queue (DLQ): Automatically capture failures and replay them via
/v1/incidents. - Zero-Secret OAuth Hub: Seamlessly connect agents with 14 external SaaS services (Slack, Google Workspace, Meta, Shopify, Notion, etc.).
For complete specifications, see the Agent Workflows API Reference.

