---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://segmentstream.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# The company agent, in a folder of your repository.

@segmentstream/agent · agent/

The extension behind the company agent in agent/. It gives the agent the workspace's ontology as tools, acting as the member who is talking to it, and puts it in your team's channels through the workspace's connections: unknown senders pair with a member first, voice messages become text, and groups are answered only when the agent is addressed.

[Start a pilot](https://segmentstream.com/enterprise#pilot) · [Request access](https://segmentstream.com/developers/agent-sdk#waitlist)

Get started

agent/

```
 $ cd agent && npm install
```

At a glance

- One agent per workspace, in agent/, deployed with the rest
- Acts as the member who writes, with their roles
- Channels through the workspace’s connections; no tokens in code
- Open source under Apache-2.0

## What it does

01

### One folder

agent/ is a package of its own, like ontology/. You write the instructions; tools come from the ontology and the channel from a connection.

agent/

```
 agent/ ├── package.json            # @segmentstream/agent and its runtime, pinned ├── segmentstream.json      # channels and models; the platform reads it too └── agent/     ├── agent.ts            # model, reasoning and limits     ├── instructions.md     # who the company is, how the agent behaves     └── extensions/         └── segmentstream.ts  # mounts the SegmentStream extension
```

02

### Mount the extension

The extension gives the agent the app's ontology as tools, acting as the member of each turn, and puts it behind the workspace's channels.

agent/

```
 // agent/agent/extensions/segmentstream.ts import { segmentstream } from "@segmentstream/agent/extension";  import config from "../../segmentstream.json";  export default segmentstream(config);  // agent/segmentstream.json {   "channels": {     "telegram": { "connection": "telegram", "policy": "smart" }   } }
```

03

### A model per role

Choose the model once per session from the member's roles. Every major model is available, with no API key to configure. The default tools stay off: the ontology is the tool surface, and \`sandbox\` adds bash and file tools in an isolated sandbox without network.

agent/agent/agent.ts

```
 import { defineAgent, segmentstream } from "@segmentstream/agent";  export default defineAgent({   defaultTools: false,   model: segmentstream.model({     default: DEFAULT_MODEL,              // a gateway model id     byRole: { accountant: FINANCE_MODEL },   }),   reasoning: "medium",   limits: { sessionUsage: ({ window }) => (window.costUsd ?? 0) >= 2 }, });
```

04

### Pairing with a member

An unknown sender gets a link to the app's /agent/connect page. The member signs in and approves once, and from then on the agent acts as them. Members see and revoke their pairings in the app.

app/src/app/api/agent/connect/route.ts

```
 // app/src/app/api/agent/connect/route.ts import { segmentstream } from "@/segmentstream";  export const { POST } = segmentstream.agent.connectHandler();
```

05

### Run and deploy

Run it locally in the terminal, then deploy with the workspace. The platform registers the channels' webhooks after each production deploy; previews never answer real chats. A preview runs the agent on the preview app's own chat and data, with no channels, tasks or connections, and \`segmentstream agent eval --preview\` runs your evals against it.

terminal

```
 $ cd agent && npm install $ npm run dev $ segmentstream deploy $ segmentstream deploy --preview $ segmentstream agent eval --preview feat-recall --as tester@example.com --role sales
```

Inside SegmentStream

## What the Agent SDK deploys.

The company agent from agent/: the channels it is live on, the models it uses and the deployment it runs.

segmentstream.com

![The console's agent page: live on Telegram, WhatsApp and Slack, its chat model with one more by role and the model for previews, the deployment it runs and its Agent SDK version, tabs for groups, instructions, personas, skills and its browser, each channel with whether it works, and at a glance the models for chat, group decisions and voice and the limit per member](https://segmentstream.com/screens/dark/console-agent.webp)

The company agent as its agent/ folder declares it: the channels it is live on and whether each works, the models it uses and the deployment it runs.

## The rest of the surface

[Ontology SDK](https://segmentstream.com/developers/ontology-sdk)

[@segmentstream/ontology](https://segmentstream.com/developers/ontology-sdk)

[Entities, actions and roles; REST, OpenAPI and MCP from one model](https://segmentstream.com/developers/ontology-sdk)

·

[App SDK](https://segmentstream.com/developers/app-sdk)

[@segmentstream/app](https://segmentstream.com/developers/app-sdk)

[Email-code sign-in, roles, records and warehouse data for Next.js](https://segmentstream.com/developers/app-sdk)

·

[Pipeline SDK](https://segmentstream.com/developers/pipeline-sdk)

[segmentstream-pipeline (Python)](https://segmentstream.com/developers/pipeline-sdk)

[Connections, ingestion, models, checks and schedules in Python](https://segmentstream.com/developers/pipeline-sdk)

·

[CLI](https://segmentstream.com/developers/cli)

[segmentstream](https://segmentstream.com/developers/cli)

[Workspaces, deploys, members, jobs and data from the terminal](https://segmentstream.com/developers/cli)

·

[MCP and API](https://segmentstream.com/developers/mcp)

[/mcp and /api/ontology on every app](https://segmentstream.com/developers/mcp)

[REST, OpenAPI and MCP on every app, per caller](https://segmentstream.com/developers/mcp)

[Developer overview →](https://segmentstream.com/developers)

## Build your company’s own software. Let agents run it.

$ segmentstream workspace create acme --region eu --subdomain acme

▸ Created workspace acme · database, warehouse and a private git repository

$ segmentstream workspace WORKSPACE-ID clone acme && cd acme

▸ your coding agent builds what your team asked for and runs the checks

$ git add -A && git commit -m "First version"

$ segmentstream deploy

▸ app, company agent, API and MCP tools live for your invited members

[Start a pilot](https://segmentstream.com/enterprise#pilot)

Our engineers build the first version on your data in two weeks, at a fixed price.

Or build it yourself with your coding agent:

`curl -fsSL https://segmentstream.com/install.sh | sh`

Work email

We’ll email you product updates, tips and onboarding help. Unsubscribe anytime.
