> ## Documentation Index
> Fetch the complete documentation index at: https://hub.hcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> H Platform has three products: the Agents API (managed computer-use agents, base URL https://agp.eu.hcompany.ai/api/v2 or https://agp.hcompany.ai/api/v2 for the US), the Models API (OpenAI-compatible Holo vision-language models at https://api.hcompany.ai/v1), and HoloTab (a free no-code Chrome extension that runs Holo in the user's browser, with recordable routines and schedules). The `holo` CLI (`pip install "hai-agents[cli]"`) runs Agents API agents from a terminal, drives the user's own desktop with `-a h/holo-desktop`, and serves coding agents through `holo mcp`.
> Authenticate with a bearer API key from the HAI_API_KEY environment variable. SDKs: `pip install hai-agents` (Python, `from hai_agents import Client`) and `npm install hai-agents` (TypeScript, `import { HaiAgentsClient } from "hai-agents"`). CLI: `holo`.
> Agents do work in a browser or on a desktop; describe the task as an imperative instruction. To run a task quickly, prefer the pre-built agent `h/web-surfer-flash`. Read results from the session's `latest_answer` after it reaches a terminal status.
> Sessions are the unit of work; wait for a terminal status (completed, failed, timed_out, interrupted) before reading the answer. Use webhooks or the `changes` long-poll endpoint to follow progress.

# Custom tools

> Let the agent call functions in your code.

## With the SDKs

Pass your functions via `tools`. They add to the core tools the [environment](https://hub.hcompany.ai/agents-api/environments/overview.md) supplies, like click and type. Python derives the schema from the signature and docstring. TypeScript declares it with `tool()`. The SDK runs the whole loop.

```python Python theme={"system"}
from hai_agents import Client

def get_order_status(order_id: str) -> str:
    """Look up the status of an order in our system."""
    return db.orders.get(order_id).status

client = Client()
result = client.run_session(
    agent="h/web-surfer-flash",
    messages="Has order 4242 shipped?",
    tools=[get_order_status],
)
print(result.answer)
```

```typescript TypeScript theme={"system"}
import { HaiAgentsClient, tool } from "hai-agents";

const getOrderStatus = tool({
  name: "get_order_status",
  description: "Look up the status of an order in our system.",
  inputSchema: {
    type: "object",
    properties: { order_id: { type: "string" } },
    required: ["order_id"],
  },
  fn: async ({ order_id }) => db.orders.get(order_id).status,
});

const client = new HaiAgentsClient();
const result = await client.runSession({
  agent: "h/web-surfer-flash",
  messages: "Has order 4242 shipped?",
  tools: [getOrderStatus],
});
console.log(result.answer);
```

* Functions may be sync or async. Exceptions reach the agent as tool errors and don't crash the session.
* Tools run only while your program [waits on the session](https://hub.hcompany.ai/agents-api/observe-and-steer.md#stream-events-as-they-arrive).
* Execution is at-least-once: if posting a result fails and the wait retries, the tool may run again. Make side-effecting tools idempotent.

## Over the raw API

### 1. Declare the tools at session create

Declare the tools when [creating the session](https://hub.hcompany.ai/agents-api/sessions/create.md), inline on the agent or via the `agent.tools` override for a registered agent:

```bash cURL theme={"system"}
SESSION_ID=$(curl -s -X POST https://agp.eu.hcompany.ai/api/v2/sessions \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": {
      "name": "support-agent",
      "description": "Answers order questions.",
      "environments": [{"id": "browser", "kind": "web"}],
      "tools": [{
        "name": "get_order_status",
        "description": "Look up the status of an order in our system.",
        "input_schema": {"type": "object", "properties": {"order_id": {"type": "string"}}, "required": ["order_id"]}
      }]
    },
    "messages": "Has order 4242 shipped?"
  }' | jq -r .id)
```

### 2. Detect the pending call

Long-poll [`changes`](https://hub.hcompany.ai/agents-api/sessions/changes) for an `ActiveStateChangeEvent` whose `data.state` is `"awaiting_tool_results"`. Its `data.pending_tool_calls` lists each pending call as a `{ tool_name, args, id }` object:

```json Pending tool call event theme={"system"}
{
  "type": "ActiveStateChangeEvent",
  "data": {
    "state": "awaiting_tool_results",
    "pending_tool_calls": [
      { "tool_name": "get_order_status", "args": { "order_id": "4242" }, "id": "call_1" }
    ]
  },
  "timestamp": "2026-06-01T15:14:05Z"
}
```

The same list is on the session itself: `pending_tool_calls` on [status](https://hub.hcompany.ai/agents-api/sessions/status.md#response) and [changes](https://hub.hcompany.ai/agents-api/sessions/changes.md#response) holds the calls from the agent's latest report, so you don't need to scan events for it. A call you just answered can stay listed until the agent reports again.

### 3. Post the result

Execute the call and [post the result](https://hub.hcompany.ai/agents-api/sessions/tool-results.md), echoing the pending call back as `tool_req`:

```bash theme={"system"}
curl -X POST "https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/tool_results" \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind": "tool_result", "tool_req": {"tool_name": "get_order_status", "args": {"order_id": "4242"}, "id": "call_1"}, "result": "shipped"}'
```

Send several at once with `{"type": "batch", "results": [...]}`. Report a failure as an `error_event` instead of a `tool_result`. It carries `error`, `origin` (both required), and the echoed `tool_req`:

```json Tool error report theme={"system"}
{ "kind": "error_event", "error": "Order not found", "origin": "custom_tools", "tool_req": { "tool_name": "get_order_status", "args": { "order_id": "4242" }, "id": "call_1" } }
```

The agent resumes once every pending call has a result. Calls still unresolved when the turn ends (for example on `max_time_s`) fail with a model-visible error.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.