Run Cortex, the local Reactive Agents studio, connect agents with withCortex(), and configure its chat, Lab, approvals, voice, provider keys and request guard.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Cortex Studio?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tylerjrbuell-cortex-studio)
---
name: cortex-studio
description: Run Cortex, the local Reactive Agents studio, connect agents with withCortex(), and configure its chat, Lab, approvals, voice, provider keys and request guard.
compatibility: Reactive Agents TypeScript projects using @reactive-agents/*
metadata:
author: reactive-agents
version: "1.0"
tier: "capability"
---
# Cortex Studio
## Agent objective
Get a Cortex server running, stream an agent's events into it, and set it up safely (keys, host allowlist, approvals). Full docs: `/features/cortex/` on the docs site.
## When to load this skill
- The user wants to watch runs live, inspect traces, or chat with an agent in a browser
- Connecting an app or `rax run` to a running Cortex
- Setting up local models (Ollama), Ollama Cloud, or local speech (Speaches) in Cortex
- Exposing Cortex beyond loopback, or hitting `403 Forbidden: Host or Origin not allowed`
## Implementation baseline
```bash
bun add @reactive-agents/cortex
rax cortex # API + UI on http://127.0.0.1:4321, opens the browser
rax run "your task" --provider anthropic --reasoning --tools --cortex
```
```ts
import { ReactiveAgents } from "reactive-agents";
const agent = await ReactiveAgents.create()
.withProvider("anthropic")
.withReasoning()
.withTools({ builtins: true })
.withCortex() // explicit URL, else CORTEX_URL, else http://localhost:4321
.build();
await agent.run("Research AI agent frameworks");
```
The connection is best-effort: if Cortex is down, the agent runs normally and logs one warning.
## Where things are
- **Beacon** (`/`): live agents. **Runs** (`/runs`): history, compare, resume. **Run view** (`/run/<id>`): trace, Why it ended, inspector tabs.
- **Chat** (`/chat`): quick bar and Config popover; `/mcp`, `/btw`, `/goal`, `/plan`, `/go`, `/loop`, `/schedule`, `/agent on`, `/compact`; `@` tags workspace files; the paperclip attaches pictures, audio and text files.
- **Lab** (`/lab`): Builder, Saved agents, Skills, Memory, Tools, Prompts. Export an agent as TypeScript or JSON. Tools has three sub-tabs: Servers (MCP: state, Test, Enable switch, tools, options, write-only credentials), Custom tools (create and edit), Catalog and test.
- **Settings** (`/settings`): provider keys (encrypted on the server, never returned to the browser), voice, storage.
## Chat and Lab details
- **Extra directories**: Lab, Tools, Workspace (`.withTools({ additionalRoots })`) and `/directories` in chat add folders besides the workspace, read only unless you allow writes. A chat bound to a saved agent shows that agent's folders read only.
- **Prompt snapshots**: **Save as prompt** in the composer footer saves the text plus, with **Include chat configuration** on, the chat's settings. If the chat has a loop or goal, choose to start the prompt as a message, a loop or a goal. Applying a snapshot from the prompt picker restores the settings exactly and shows a note with **Undo**; a loop or goal needs one click (**Start loop** / **Start goal**) and keeps the schedule cap, lifetime and cost caps. A chat bound to a saved agent refuses the configuration part.
- **Secrets in exports and snapshots**: credentials in headers, properties and URL paths (`https://host/v1/sk-abc/mcp`) become `{{secret.NAME}}` or are dropped; they never reach exports or stored snapshots.
- **Tool disclosure** (`/tools`): unset, the framework uses `auto` on local and mid models and `discover` on large and frontier models.
- **Settings, Models**: each provider's Models link opens that provider's model list at `/models/<provider>` (sortable by price; a local model shows **free (local)**), and a model opens its detail page.
## Run status and control
- A run paused on a tool approval or a `request_user_input` question reads **Waiting on you** (`awaiting-approval`, `awaiting-interaction`). It is not counted as running in the top bar or Runs, and Pause and Stop are not offered for it.
- A zero cost on a local provider (Ollama, LiteLLM) reads **free (local)**, not `$0.00`.
- Pause, Stop and Terminate end their pending state on the framework's `RunControlApplied` event and show the latency ("Stopped in 230 ms"); `RunControlRequested` and `RunControlApplied` appear in the run Timeline.
## Spend budgets
Costs (`/runs/costs`) and Settings, Budgets list the same budgets. A budget has a scope (all runs, one agent, one model as `provider/model`), a period (per run, day or month, UTC), a USD limit and a warning percent (default 80). One budget per scope, target and period; at most 50.
- **Per run**: handed to the framework as `.withBudget({ costLimit, warningRatio })`; when the cap is crossed the run stops with `terminationReason: budget_exceeded` (on `AgentCompleted`), a durable run ends with status `failed` (not `stopped`), and the run header says "Stopped by budget: $X cap". The public `terminatedBy` is still `max_iterations`; read the budget cause from `terminationReason`, `result.error` or the `BudgetExhausted` event. The smaller of the agent's own `costLimit` and the cap wins. It is checked before each model call; a run can end up to one call over the cap (measured: a $0.08 cap stopped after 2 calls and $0.09). It is not a hard cap. Day and month budgets are the firm control.
- **Day and month**: a used-up budget blocks new runs and chat turns that spend money, answering HTTP 402 `{ error, blocked: { message, overrideToken, budgets } }`. Repeat the request with header `x-cortex-budget-override: <overrideToken>` to start once: single use, held in memory for 10 minutes, recorded. Nothing already running is stopped.
- **Alerts**: toast, Costs banner, top-bar badge, alert history; one warn and one exceeded per budget and window.
- **Routes**: `GET/POST /api/budgets`, `PATCH/DELETE /api/budgets/:id`, `GET /api/budgets/events?runId=`.
- **Free**: `ollama`, `litellm` and `test` never count or block; a model with no known price adds no dollars.
- **Limits**: running gateway agents are not start-blocked between fires; ad-hoc desk runs count only under the all-runs and model scopes; no channel notifications; Cortex keeps 50 runs per agent but archives budget spend for 62 days; deleting a run by hand does not archive its spend.
## Rerun and fork
- **Rerun** (run header; the chevron opens a drawer) starts a NEW run from a finished run's task and saved launch config, optionally changing provider, model, strategy or iteration cap (1 to 200). The drawer lists what will change; nothing starts until confirmed. Needs a recorded launch config.
- **Fork from here** (an iteration row of a finished run) restarts a new run from the run's durable checkpoint after that iteration, through `agent.fork`, optionally with an edited instruction. Every model call after the fork point is live. A fork's iteration cap counts iterations AFTER the fork point ("Iterations after the fork point"), not from the start. Finished runs stay forkable at every iteration (framework `compactCheckpoints` is off by default); runs from older versions keep only their last iteration. UI iterations count from 1; the API's `at` is 0-based (`at = N - 1`). With durable runs off (or the store gone) the run cannot be forked and Cortex says why. A running run cannot be forked.
- API: `POST /api/runs/:id/rerun` (optional `{ provider?, model?, strategy?, maxIterations? }`), `POST /api/runs/:id/fork` (`{ at, task?, ...changes }`), `GET /api/runs/:id/lineage` (origin, children, fork availability).
- Lineage: the new run shows "Rerun of ..." or "Forked from ... at iteration N", what changed and a Compare link; the origin lists "Reruns (n)". The original run is never changed.
- Both re-check the workspace and Code Action vs approval rules like any new run. Lineage stores only the origin id and non-secret changes (a fork's edited instruction is only a flag), never the config or a secret.
## Eval cases
- UI: **Evals** (`/evals`). Pin a finished run with run view **More actions**, **Save as eval case**, or **Save as eval case** under a chat reply. A case stores the task, the run's config with credentials removed (no key or URL secret is saved) and expectations. Cases live in sets.
- Nine expectation kinds: `includes`, `excludes`, `output-equals`, `regex`, `tool-called`, `tool-not-called`, `max-iterations`, `max-cost-usd`, `rubric`. A bad entry is refused by position, never dropped.
- **Run set** runs each case as a new run and grades each expectation Passed, Failed or Undecided. **Run with changes** reruns a case or set on another provider, model, strategy or iteration cap. A case flags **Regressed** when the latest result is not a pass and the previous was; a set charts its pass rate.
- A rubric is asked only when every other check passed; it is an uncalibrated model reading on the run's own model. A run that failed, was stopped, was blocked, waits on an approval or question, or exceeds 10 minutes is **Not graded**, never a pass. A result's run link 404s if that run is later deleted.
- API (`/api/evals`): `GET|POST /sets`, `GET|PATCH|DELETE /sets/:id`, `GET /sets/:id/export` (framework `EvalSuite` plus notes on checks it cannot express), `GET /draft` (draft a case from a run), `POST /sets/:id/cases`, `PATCH|DELETE /cases/:id`, `GET /cases/:id/results`, `POST /cases/:id/run`, `POST /sets/:id/run` (optional `concurrency`, capped at 3), `GET /batches/:id`, `POST /batches/:id/cancel`.
- Limits: 100 sets, 50 cases per set, 20 expectations per case, 3 cases at once, 2 batches at once (429 beyond that).
- Cases run through the same workspace and approval checks as any new run.
## Safety rules
1. Cortex has no login. Keep it on `127.0.0.1` unless the network is trusted.
2. Behind a DNS name or proxy, set `CORTEX_ALLOWED_HOSTS=name1,name2`. The Host and Origin guard refuses other names with 403.
3. `shell-execute` is off by default; gate risky tools and commands with Approvals (Tools section). "Pause and ask me" waits live without durable execution.
4. Ollama Cloud keys are sent only to non-local endpoints. Judgments cannot use Ollama Cloud.
## Environment variables
`CORTEX_PORT` (4321), `CORTEX_HOST` (127.0.0.1), `CORTEX_TOKEN` (access token; required when `CORTEX_HOST` is not loopback, otherwise Cortex refuses to start), `CORTEX_URL`, `CORTEX_ALLOWED_HOSTS`, `CORTEX_NO_OPEN`, `CORTEX_LOG`, `CORTEX_SKILL_SCAN_ROOT`, `CORTEX_CHAT_MAX_SESSIONS` (8), `CORTEX_TRACE_DIR` (with `REACTIVE_AGENTS_TRACE_DIR`: where run traces go; `dev-stack --isolated`, a non-default port or `--cwd` sets both to the stack's own data directory), `CORTEX_VOICE_STT_API_KEY`, `CORTEX_VOICE_TTS_API_KEY`.
## Voice with a local server
Settings, Voice: pick the server engine and a Speaches preset (`http://localhost:8000/v1`), download models first (`curl -X POST http://127.0.0.1:8000/v1/models/Systran/faster-whisper-small`), then Save endpoint and Test.
## Pitfalls
- Mic access needs `localhost` or https.
- Goals own their chat session: plain messages return 409 while a goal is active.
- Cortex shows judgments and rubric goal checks and keeps saved eval cases (Evals page); the suite format and graders live in `@reactive-agents/eval`.