Skip to content

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 v3.2, and Gemini.

The Agent Compute Engine 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://comp1.fotohub.app/v1
  • Region: eu-central-1 (Frankfurt, AWS)
  • Billing: USD prepaid wallet first, subscription credits as fallback. A task will not start with $0.00 wallet balance and fewer than 5 credits.
  • 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.

mermaid
stateDiagram-v2
    [*] --> created: POST /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 /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:

  1. Context Initialization: Loads the prompt, system instructions, and available tools into the model's context window.
  2. Action Generation: The model predicts the next best action (e.g., call a tool or yield the final answer).
  3. Sandbox Dispatch: If a tool requires execution (like Python code), the orchestrator securely dispatches it internally to its Firecracker microVM backend (proxy-secret authenticated, not a public endpoint — see Firecracker Sandboxes).
  4. Result Ingestion: The output from the tool (stdout, stderr, or structured JSON) is appended to the context window.
  5. Re-evaluation: The loop restarts until the model dictates the goal is met or the max_steps limit 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.

Wallet First, Credits as Fallback

Agent tasks bill the prepaid USD wallet first and fall back to subscription credits. A task is rejected before it starts if your wallet is at $0.00 and you hold fewer than 5 subscription credits.

Language Models ​

Pricing below matches the live per-model rate table used by the Agent Compute service.

ModelProviderBest ForPrice (Input / 1M)Price (Output / 1M)
Claude Opus 4.6AnthropicComplex reasoning, large refactors, autonomous software engineering$15.00$75.00
Claude Sonnet 4.6AnthropicFast coding, tool use, web automation (fallback model)$3.00$15.00
Claude Haiku 4.5AnthropicLow-latency, high-volume tool steps$1.00$5.00
Gemini 3.1 Pro (preview)GoogleMultimodal reasoning, long-context document analysis$2.00$12.00
Gemini 2.5 FlashGoogleHigh-volume, latency-sensitive tasks$0.30$2.50
Grok 4.20xAIReasoning and non-reasoning agentic steps$2.00$6.00
DeepSeek v3.2DeepSeekMathematical reasoning, optimization$0.50$2.00
Kimi K2Moonshot AILong-horizon planning, thinking mode$0.60$2.40
Qwen3 MaxAlibabaGeneral purpose reasoning$1.00$4.00
GPT-5.1Azure OpenAIGeneral purpose, reliable tool calling$3.00$15.00

The default model is Claude Opus 4.6, with Claude Sonnet 4.6 as the automatic fallback.

Dedicated Compute Instances ​

Agents can provision dedicated GPU/CPU resources on-demand or spot for background workloads. Prices are listed per hour.

Instance FamilySpecsSpot Price ($/hr)On-Demand Price ($/hr)
G5.xlargeA10G (24GB VRAM)$0.38$1.01
G4dn.xlargeT4 (16GB VRAM)$0.20$0.53
T3, C5, M5, R5CPU optimizedVariesVaries

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 — dispatched internally, not via a public URL. See Firecracker Sandboxes for the mechanism.

  • 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 not separately metered or billed today — only model tokens and sandbox wall-clock time show up on your invoice for a task.

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:

python
import os, requests

# Agent Compute is not covered by the fotohub SDK -- plain HTTP.
BASE = "https://comp1.fotohub.app/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['FOTOHUB_API_KEY']}"}

task = requests.post(f"{BASE}/tasks/create", headers=HEADERS, timeout=60, json={
    "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}")
typescript
const BASE = "https://comp1.fotohub.app/v1";
const HEADERS = {
  Authorization: `Bearer ${process.env.FOTOHUB_API_KEY!}`,
  "Content-Type": "application/json",
};

async function dispatchAgent() {
  const res = await fetch(`${BASE}/tasks/create`, {
    method: "POST",
    headers: HEADERS,
    body: JSON.stringify({
      prompt: "Investigate customer error trace in /workspace/error.log, identify bug, and run unit tests to confirm fix.",
      max_steps: 20,
      budget_limit_usd: 1.50,
    }),
  });

  const task = await res.json();
  console.log("Agent running with Task ID:", task.task_id);
}

dispatchAgent();
go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	apiKey := os.Getenv("FOTOHUB_API_KEY")
	url := "https://comp1.fotohub.app/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)
}
bash
curl -X POST https://comp1.fotohub.app/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:

  1. 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 a budget_exceeded error.
  2. 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 /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.

mermaid
sequenceDiagram
    autonumber
    participant Client as Frontend / SDK
    participant Engine as Agent Compute Server
    participant Sandbox as MicroVM Sandbox

    Client->>Engine: GET /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 NameDescriptionPayload Data Structure
task_statusStatus transition update{"status": "planning" | "executing_step" | "completed"}
commentaryAgent internal reasoning step{"thought": "Evaluating regression coefficients..."}
tool_callAgent dispatched a tool{"tool": "sandbox_python", "args": {"code": "..."}}
tool_resultTool output returned{"tool": "sandbox_python", "success": true, "output": {...}}
agent_deltaStreaming token fragment{"content": "Here is the summary table:\n"}
doneTask completed{"task_id": "tsk_...", "total_steps": 12, "cost_usd": 0.42}
errorFailure event{"code": "budget_exceeded", "message": "Max budget reached"}

Consuming SSE in TypeScript ​

typescript
const eventSource = new EventSource(
  `https://comp1.fotohub.app/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:

bash
curl -X POST https://comp1.fotohub.app/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:

bash
curl -X POST https://comp1.fotohub.app/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:

bash
curl -X POST https://comp1.fotohub.app/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:

json
{
  "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:

json
{
  "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.png to 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 run npx 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 /engine/v1/swarm/consensus.
  • Vector Memory RAG: Store and retrieve long-term state across sessions via /engine/v1/memory/*.
  • Canary Deployments: Roll out agent logic changes safely with traffic routing via /engine/v1/workflows/{id}/canary.
  • Dead-Letter Queue (DLQ): Automatically capture failures and replay them via /engine/v1/incidents.
  • Zero-Secret OAuth Hub: Seamlessly connect agents with 13 external SaaS services (Slack, Google, Meta, Shopify, Notion, TikTok, LinkedIn, X/Twitter, Airtable, Stripe, Microsoft, Dropbox, Discord).

For complete specifications, see the Agent Workflows API Reference.