# fx complete documentation --- --- > Every fx documentation page in one machine-readable file. --- --- --- title: "Quick start" description: "Install fx and send your first prompt." canonical_url: https://fx.sh/docs markdown_url: https://fx.sh/docs.md --- # Quick start fx is an open-source coding agent built as a small native binary. It reads your code, edits files, and runs commands from an interactive shell or a single `fx ask` request. ## Install ```bash curl -fsSL https://fx.sh/setup.sh | bash ``` See [Installation](https://fx.sh/docs/getting-started/installation.md) for other versions or help with `PATH`. ## Start fx Open a project and start an interactive session: ```sh cd path/to/project fx ``` If fx has no credential yet, it opens **Welcome to fx**. Choose **Sign in with Vercel**, **Sign in with Codex** for a ChatGPT subscription, **Sign in with Grok** for a Grok subscription, or **Add an API key** for an AI Gateway key. Complete sign-in or paste the key when prompted. To change how fx connects later, open the provider picker: ```text /provider ``` See [Authentication](https://fx.sh/docs/getting-started/authentication.md) for other login methods. Send a prompt: ```text Run the tests and fix any failures. ``` ## Things to know | Action | How | | --- | --- | | [Steer fx while it works](https://fx.sh/docs/using-fx/working-with-fx.md#steering) | Send a follow-up prompt. | | [Mention a file](https://fx.sh/docs/using-fx/working-with-fx.md#send-a-prompt) | Type `@` and choose it. | | [Browse commands](https://fx.sh/docs/using-fx/slash-commands.md) | Type `/`. | | [Update fx](https://fx.sh/docs/getting-started/installation.md#upgrade) | Run `fx upgrade`, or press `ctrl+g` when an update is ready. | | [Open Full detail](https://fx.sh/docs/using-fx/working-with-fx.md#review-the-result) | Press `ctrl+o`. | | [Interrupt fx](https://fx.sh/docs/using-fx/working-with-fx.md#steering) | Press `escape` twice. | | [Turn on sounds](https://fx.sh/docs/using-fx/slash-commands.md#inspection-and-settings) | Run `/sound on`. | | Change permissions | Run [`/permissions`](https://fx.sh/docs/configure-fx/permissions.md). The default is `auto`. | See [Keyboard shortcuts](https://fx.sh/docs/using-fx/keyboard-shortcuts.md) for every shortcut. ## Run one request Use `fx ask` when you do not need an interactive session: ```bash fx ask "explain what this repository does" ``` See [`fx ask`](https://fx.sh/docs/using-fx/fx-ask.md) for scripting and structured output. ## Resume fx saves your conversations. From the same project, resume with: ```bash fx -c ``` Use `fx -r` to choose another [session](https://fx.sh/docs/using-fx/sessions.md). Next: [Working with fx](https://fx.sh/docs/using-fx/working-with-fx.md). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Installation" description: "Install and update fx on macOS or Linux." canonical_url: https://fx.sh/docs/getting-started/installation markdown_url: https://fx.sh/docs/getting-started/installation.md --- # Installation fx runs on macOS and Linux, on 64-bit Intel and ARM machines. ## Install ```bash curl -fsSL https://fx.sh/setup.sh | bash ``` The installer puts `fx` in `~/.local/bin`. If that directory isn't on your `PATH`, the installer adds it to your shell's startup file: `~/.zshrc` for zsh, `~/.bash_profile` or `~/.bashrc` for bash, or `~/.config/fish/config.fish` for fish. Open a new terminal, then continue with [Quick start](https://fx.sh/docs.md). ## Upgrade While fx is open, it checks for updates in the background and installs them. When an update is installed, the footer in the lower-right shows `update ready: ctrl+g to reload`. Press `ctrl+g` while fx is idle and the composer is empty to restart on the new version and continue the current conversation. Otherwise, fx runs the new version the next time you start it. To install an update now: ```bash fx upgrade ``` `fx update` is an alias. After an update, fx shows a `notes` link to the release's entry in the [changelog](https://fx.sh/changelog). To turn off automatic updates, run `fx config set auto_upgrade false`, or set `FX_AUTO_UPGRADE=0` in the environment. See [Interface and update settings](https://fx.sh/docs/configure-fx/configuration.md#interface-and-update-settings). ## Use development releases The `dev` channel follows changes merged into `main` after CI passes. Switch to it with: ```bash fx upgrade --channel dev ``` fx remembers the channel for later updates. Its startup header shows the release version, short commit SHA, and `[dev]`, such as `v0.0.16-57eadd6 [dev]`. After an update, fx links `changes` to the commits since your previous dev release. Return to stable with: ```bash fx upgrade --channel stable ``` ## Other install options Install a specific release: ```bash curl -fsSL https://fx.sh/setup.sh | bash -s -- ``` Use the release tag with its leading `v`, such as `v0.0.15`. Unless you turn off automatic updates, fx updates itself to the latest release the next time it checks. To install somewhere else, pass `FX_INSTALL_DIR` to the installer. For example, to use `~/bin`: ```bash curl -fsSL https://fx.sh/setup.sh | FX_INSTALL_DIR="$HOME/bin" bash ``` If your terminal cannot find `fx`, open a new terminal or add its install directory to `PATH`: ```bash export PATH="$HOME/.local/bin:$PATH" ``` Run `fx --version` to check the installed version. For installation problems, see [Troubleshooting](https://fx.sh/docs/using-fx/troubleshooting.md). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Authentication" description: "Connect an account or API key for model requests." canonical_url: https://fx.sh/docs/getting-started/authentication markdown_url: https://fx.sh/docs/getting-started/authentication.md --- # Authentication Connect the account or API key fx should use for model requests. ## Model providers Open fx and run `/provider` to choose where fx sends model requests and how you connect. `/login` opens the same picker. | Provider | Connect with | In `/provider` | Terminal command | | --- | --- | --- | --- | | Codex | ChatGPT Plus, Pro, Business, Enterprise, or Edu subscription | `codex` | `fx login codex` | | Grok | SuperGrok or X Premium subscription | `grok` | `fx login grok` | | AI Gateway | Vercel account or API key | `vercel`, then `oauth` for an account or `api-key` for a key | `fx login vercel` for an account, or `fx login vercel --api-key` for a key | `fx login codex`, `fx login grok`, and `fx login vercel` also make that provider active. Without a provider name, `fx login` signs in to Vercel. Your provider determines the available models and where usage is billed. fx remembers the model you selected for each provider. Use `/model` to choose another one, or [learn more about models](https://fx.sh/docs/configure-fx/models.md). To switch providers from your terminal, run `fx provider codex`, `fx provider grok`, or `fx provider gateway`. If you haven't connected that subscription yet, `fx provider` signs you in first. ## Custom endpoints You can also connect Ollama, vLLM, OpenRouter, or another compatible Chat Completions endpoint. Define it in `~/.fx/settings.json`, then select it with `fx provider ` or `FX_PROVIDER`. Custom connections can run without authentication or read a bearer key from an environment variable. See [Custom model connections](https://fx.sh/docs/configure-fx/custom-model-connections.md) for examples and supported fields. ## Use an AI Gateway API key Create an [AI Gateway API key](https://vercel.com/docs/ai-gateway/authentication-and-byok/api-keys), then save it with: ```bash fx login vercel --api-key ``` fx saves the key in the macOS Keychain, or in `~/.fx/api-key` on Linux. `fx setup` still saves a key the same way, with a warning that points to this command. It stops working in fx 0.0.18. In fx, you can instead choose `vercel`, then `api-key` in `/provider` and paste the key, choosing `new` first if fx already has one. fx checks the key with AI Gateway before saving it, then makes it active. For a script or CI job, set `AI_GATEWAY_API_KEY` and select Gateway: ```sh export AI_GATEWAY_API_KEY="your-api-key" fx provider gateway fx ask "Summarize this repository" ``` ## Credential selection Use `/provider` to choose which AI Gateway credential fx should use. Choose `vercel`, then `oauth` for your Vercel login, or `api-key` and then `env` for `AI_GATEWAY_API_KEY`, `saved` for the key fx saved, or `new` to paste another. fx lists `env` and `saved` only when it finds that key. Choosing a source saves that exact source for later runs. `fx login vercel` and `fx teams` save your Vercel login the same way. A saved source takes priority over `VERCEL_OIDC_TOKEN` and `AI_GATEWAY_API_KEY`. If the chosen source is unavailable, fx reports it instead of switching accounts. `fx logout vercel` clears the saved source. When no Gateway credential source is saved, fx checks credentials in this order: | Source | Selected when | | --- | --- | | `VERCEL_OIDC_TOKEN` | The environment contains a non-empty OIDC token. | | `AI_GATEWAY_API_KEY` | The environment contains a non-empty API key but no OIDC token. | | Vercel login | Neither environment credential resolves, and the saved login can be loaded or refreshed. | | Saved API key | The key is available and none of the earlier sources resolves. | Environment values apply to fx processes started with them. `fx login vercel --api-key` saves a key but does not select it. Without a saved choice, fx reaches that key through the order above. Use `/provider` to select it explicitly. ## Manage connections Run `fx status` or `/status` to see the active provider, model, and credential source. To sign out from your terminal: | Provider | Command | | --- | --- | | ChatGPT subscription | `fx logout codex` | | Grok subscription | `fx logout grok` | | Vercel login | `fx logout vercel` | Without a provider name, `fx logout` signs out of Vercel. Signing out of Vercel doesn't remove a saved API key. In fx, `/logout` signs out of the active provider, or of the one you name, such as `/logout codex`. If you sign out of the subscription you're using, fx switches to another connected provider when one is available. ## Change Vercel team `fx teams` chooses the AI Gateway team for your saved Vercel login, selects that login for Gateway requests, and switches fx to AI Gateway. Once you're signed in, choosing `vercel`, then `oauth` in `/provider` lists the same teams. The chosen team determines the models and credits available to fx. API keys and environment credentials do not use this team selection. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Stability" description: "What changes between fx releases, and what auto mode lets fx do without asking." canonical_url: https://fx.sh/docs/stability markdown_url: https://fx.sh/docs/stability.md --- # Stability fx is experimental. Its releases are numbered 0.0.x, and any release can change or remove commands, flags, settings, saved-data formats, and the libfx API. Each release's entry in the [changelog](https://fx.sh/changelog) lists the changes that need action from you under **Breaking Changes**. fx also starts in `auto` permission mode, so it does most work without asking you first. Read [Auto mode](#auto-mode) before you give it a task in a directory you can't restore. ## What can change between releases When a command, flag, or setting is renamed, the old name sometimes keeps working for a few releases. fx then prints a warning that names the replacement and the release where the old name stops working: ```text fx setup is deprecated and stops working in fx 0.0.18; use fx login vercel --api-key ``` Other old names are removed at once. Using one fails with an error that names its replacement, as `fx resume` does now. fx converts conversations saved by earlier versions the first time you open them. See [Sessions from earlier versions](https://fx.sh/docs/using-fx/sessions.md#sessions-from-earlier-versions). A newer libfx can save sessions and checkpoints that older versions can't open. When several workers share a session store, upgrade all of them before they start new turns. See [Compatibility](https://fx.sh/docs/lib/checkpoints.md#compatibility). ## Control updates fx installs updates in the background while it's open. To stay on one release, [install that release](https://fx.sh/docs/getting-started/installation.md#other-install-options) and turn off automatic updates: ```bash fx config set auto_upgrade false ``` The `dev` channel follows changes as they merge, before they reach a release. See [Use development releases](https://fx.sh/docs/getting-started/installation.md#use-development-releases). ## Auto mode In `auto` mode, fx reads and edits project files, searches, and runs recognized commands such as tests, builds, and dependency installs without asking. It sends other actions, such as unrecognized shell commands and MCP tool calls, to a review model first. That review holds an action only for prompt injection or for harm to your machine, so fx can still delete code or tests, push branches, and run scripts it wrote without asking you. [Auto mode](https://fx.sh/docs/configure-fx/permissions.md#auto-mode) lists what runs directly and what gets reviewed. The fx CLI doesn't run commands in a sandbox. Shell commands run with your user account's access. `/undo` reverts changes made by fx's file tools, but not shell commands or changes to external services, so keep work you care about in version control. To approve each action yourself, switch to `ask` mode: ```bash /permissions ask ``` fx saves the mode you choose for later sessions. To use `ask` for one session only, start fx with `fx --ask`. See [Permissions](https://fx.sh/docs/configure-fx/permissions.md#change-the-mode) for the other modes and for rules that allow or deny specific actions. ## Report a problem Run `/feedback` to open the fx issue form. See [Share feedback](https://fx.sh/docs/using-fx/share-feedback.md) for traces and recordings that help reproduce a problem. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Working with fx" description: "Send a prompt, steer fx, and review the result." canonical_url: https://fx.sh/docs/using-fx/working-with-fx markdown_url: https://fx.sh/docs/using-fx/working-with-fx.md --- # Working with fx Start `fx` in a project and send a prompt. ## Send a prompt ```text Fix the search box losing its value when I go back, and add a regression test. ``` Type `@` to mention a file or folder, or `/image ` to attach an image. An image file you mention is attached too. File suggestions rank exact names, name prefixes, and whole-word matches ahead of scattered letters. You can include a file's containing folder in the search, and the highlighted letters show the match. The picker shows up to 10 rows when the terminal has room. Press Enter to mention the selected file or folder, or Tab to open a folder and search inside it. ## Steering Send a follow-up prompt while fx works. fx treats it as steering: - While fx is responding, it stops the response and continues with your follow-up. - While a tool or context compaction is running, fx applies the follow-up when it finishes. A follow-up that includes an image or a [skill](https://fx.sh/docs/capabilities/skills.md) ends the current turn instead, and runs as the next one. While a follow-up waits for a tool or compaction, press `up` in an empty composer to take it back and edit it. Press `escape` twice to interrupt. File changes and commands that already ran remain in place. ## Review the result Press `ctrl+o` to open Full detail, which includes the conversation and complete command output. Press `ctrl+o` or `escape` to close it. `/undo` reverts the latest file operation made with fx's file tools. It does not undo shell commands or changes to external services. ## Input shortcuts Press `shift+enter` to start a new line, or `up` on the first line of your draft to bring back an earlier prompt. [Keyboard shortcuts](https://fx.sh/docs/using-fx/keyboard-shortcuts.md) lists every shortcut. ## Pick up later Run `fx -c` in the same workspace to resume its remembered session. See [Sessions](https://fx.sh/docs/using-fx/sessions.md) for other ways to resume. To delegate part of a task, see [Subagents](https://fx.sh/docs/capabilities/subagents.md). To run several conversations in one terminal, see [Instances](https://fx.sh/docs/using-fx/instances.md). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Sessions" description: "Return to a conversation, recover interrupted work, and manage context." canonical_url: https://fx.sh/docs/using-fx/sessions markdown_url: https://fx.sh/docs/using-fx/sessions.md --- # Sessions fx saves conversations in `~/.fx/sessions/`. Start `fx` for a new conversation, or use `fx -c` to reopen the one remembered for the current workspace. ## Resume a conversation | What you want to do | Command | | --- | --- | | Continue the remembered conversation | `fx -c` | | Choose a saved conversation | `fx -r` or `fx --resume` | | Resume the latest conversation in this workspace | `fx -r last` | | Resume a conversation by ID | `fx -r ` | | Resume and send a first prompt | `fx -c ""` or `fx -r ""` | `fx session resume last` and `fx session resume ` work the same way as `fx -r last` and `fx -r `. `fx -r` and `/resume` open a picker of this workspace's conversations, newest first. Type to search all of them, not only the ones shown, and press `tab` to switch between this workspace and all workspaces. The remembered conversation and the latest one usually match. They differ when another session receives activity without becoming the selected conversation, such as through `fx ask --resume`. You can resume a session from another workspace with its ID. fx then associates it with the workspace where you opened it. A resumed conversation shows the turns since its latest [context compaction](https://fx.sh/docs/using-fx/context-compaction.md). If no turn has run since that compaction, it shows the turns before it. Earlier turns are in [Full detail](https://fx.sh/docs/using-fx/keyboard-shortcuts.md#full-detail). If the session was one of several [instances](https://fx.sh/docs/using-fx/instances.md#quit-and-resume), resuming it brings back the whole group. ## Find a session In the shell, `/status` opens a panel below the prompt. Its first line shows the open conversation's ID and whether it's saved yet. A new conversation is saved when its first prompt starts, and `fx --resume ` opens it from then on. A fork is saved as soon as you make it. Press Esc to close the panel; it leaves nothing in the conversation. When you quit a saved conversation, fx prints `Resume this session with:` and, on the line below it, `fx --resume `. If fx can't save sessions, the panel's session line shows `none`. List conversations in the current workspace: ```bash fx sessions ``` Use `fx sessions --all` to include other workspaces. To inspect a saved conversation and its history, run: ```bash fx session --json ``` `fx ask` can continue a saved conversation without opening the shell: ```bash fx ask --resume last "continue with the tests" ``` ## Fork a conversation Run `/fork` to start a new conversation from an earlier point in the current one. Choose a prompt from the list, and fx creates a conversation with the history before that prompt, switches to it, and puts the prompt in the composer so you can edit it before sending. The original conversation stays as it was. `/fork` works in a saved conversation once the current response finishes. ## Session titles fx creates a short title from the first usable prompt so conversations are easier to find. An untitled conversation can still receive a title after you resume it. Run `/rename ` to set a title yourself. Turn automatic titles off with `session_titles: false` in your profile settings or through `/settings`. See [Usage and costs](https://fx.sh/docs/using-fx/usage-and-costs.md#additional-model-requests) for the separate model request it uses. ## Recover interrupted work fx saves each step of a response as it finishes. When a provider or the network fails, fx keeps retrying until the request goes through, and the status line shows what failed, the attempt, and a countdown to the next try. Once fx sends the request again, the status line goes back to `Thinking` while the model works. Press `escape` twice to stop it. If a response breaks off partway, fx starts it over. The new answer replaces the partial one, or appears after `↻ Restarted the answer` when the partial one can't be replaced, such as after it scrolls out of view. In the shell, a request that only you can continue, such as one out of credits, waits for you instead of retrying. See [fx asks you to act during a response](https://fx.sh/docs/using-fx/troubleshooting.md#fx-asks-you-to-act-during-a-response). When a turn ends on an error that fx can't retry, it keeps the prompt, any partial reply, and the tool calls that finished, so a follow-up prompt continues from that work, including after you resume the session. When the network drops during a response, fx notices that the connection is dead within about 5 seconds of the network returning and retries the request. If your computer joins another network or gets a new address, fx notices within about a second. During a longer outage, the status line shows `Connection lost` 45 seconds after the last data arrived, and fx keeps retrying. A model that thinks for minutes without sending text keeps its connection, and an answer isn't cut short when your computer sleeps. If fx or its terminal closes during a response, run `fx -c`. fx sends the interrupted request again on its own and shows `Resuming the interrupted request`. A tool that was running when fx stopped may have partly run, so fx tells the model to check what finished and rerun only what is safe. Plain `fx` shows `Interrupted turn · /resume to continue` when the conversation `fx -c` opens has an unfinished turn. Pick that conversation in `/resume`, and fx sends the interrupted request again, as `fx -c` would. fx asks before sending the request again in two cases. Press `enter` to send it, or `escape` to end it: | Status line | When | | --- | --- | | `This request crashed fx twice` | fx stopped unexpectedly twice while the request was in flight. | | `Interrupted more than a day ago` | The request was interrupted more than 24 hours ago. | Closing the terminal window counts as a clean close, not a crash. This covers fx and its terminal stopping, not the computer. A power cut or a crash of the whole computer can lose the turn in progress, because fx doesn't wait for the disk to confirm each save before it sends a request. Token usage is saved with each model reply and continues counting after resume; subagent usage stays in each subagent's own session. `fx ask` doesn't send an interrupted request again on its own. Send `continue` to pick up from the steps that finished: ```bash fx ask --resume last "continue" ``` If a saved conversation cannot open, `fx doctor` names it and the command that recovers it. `fx session recover <session-id>` copies the conversation up to the damage into a new session and leaves the original unchanged. ## Sessions from earlier versions fx converts a conversation saved by an earlier version the first time you open it, together with its subagent sessions. `fx -c`, `fx -r`, `fx session resume`, `/resume`, `fx ask --resume`, and ACP `session/load` all convert it. To convert every saved conversation at once: ```bash fx sessions convert ``` Conversion carries saved permission rules, ACP prompts and tool identities, terminal state, and side files. fx removes a conversation's earlier files only after its converted copy is saved. When a file can't be carried across, such as a side file over the per-file limit or terminal state the new format can't hold, fx names it and keeps the conversation's earlier folder, so the file stays where it was, and `fx doctor` counts these folders. Earlier versions of fx read only the earlier format by default, so they don't show converted conversations. Back up `~/.fx/sessions/` before converting if you might go back to one. A session that can't be converted keeps its original files, and fx names the file and the reason. `fx doctor` lists these sessions with the command for each one, and `fx session recover <session-id>` copies what can be read into a new session. `fx sessions convert --json` reports skipped sessions and each file that couldn't be carried across, with its cause. The command exits with status 1 when it skips a session. A subagent session that no version of fx opens also stays as it is, such as a subagent's own subagent from a version before 0.0.8. `fx sessions convert` lists each one under `kept` with the reason, `fx doctor` names it too, and the conversation it belongs to converts without it. ## Compact long sessions fx compacts older conversation history automatically when a model request reaches its context threshold. Run `/compact` to do it between prompts: ```bash /compact ``` See [Context compaction](https://fx.sh/docs/using-fx/context-compaction.md) for the exact threshold, retained history, and model requests. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Context compaction" description: "Understand when fx compacts a conversation and what it keeps." canonical_url: https://fx.sh/docs/using-fx/context-compaction markdown_url: https://fx.sh/docs/using-fx/context-compaction.md --- # Context compaction Compaction lets a long conversation continue by replacing older history with a shorter handoff. ## Automatic and manual compaction fx compacts automatically when a model request reaches 80% of its usable input window, then continues the same prompt. The usable window excludes tokens reserved for the model's response. Set `auto_compact_percent` to an integer from `10` to `80` in `~/.fx/settings.json` to start earlier. The default is `80`; this is a personal setting, not a project `.fx.json` field. The `FX_AUTO_COMPACT_PERCENT` environment variable overrides the setting, and fx ignores a value outside that range. If the provider reports a context overflow before returning text or a tool call, fx compacts and retries once, and the status line shows `Conversation too long · compacting, then retrying`. If the request is still too long, the shell waits with `Still too long after compacting · press Esc and shorten your message`. When a provider rejects a request with images as too large, fx first retries with fewer images; see [Request size](https://fx.sh/docs/capabilities/vision.md#request-size). Run `/compact` between prompts to compact immediately: ```bash /compact ``` This works below the automatic threshold and does not start another prompt. With no history to compact, fx makes no model request. On a [subagent's screen](https://fx.sh/docs/capabilities/subagents.md#switch-to-a-subagent), `/compact` compacts that subagent's conversation and saves the result in its session. ## What fx keeps fx keeps up to four of the newest turns unchanged and compacts everything older. It cuts only between complete tool steps, so each tool call stays with its result. The turns it keeps can use 40% of the room the conversation aims for right after compaction. That room is 20% of the usable input window, or half the compaction threshold when that is smaller, less the instructions and tool definitions that every request carries. In the compacted part, each turn keeps your messages, including ones you sent while it ran, and the assistant's final reply word for word. The model writes notes for the rest: what the assistant did, why it made each tool call, and what the call showed. The notes also keep the session's rules, facts, decisions, and status as numbered entries that later compactions only add to. fx checks each note against the saved turns and tool calls and marks any claim it can't confirm, so the agent checks it before relying on it. fx aims to keep the compacted conversation, with the turns it kept and the request's instructions, within half the compaction threshold. When the compacted text would go past that, fx shortens the longest messages and replies, and each shortened text names the saved turn that keeps it whole. fx saves every compacted turn word for word as `M1`, `M2`, and so on, and every tool call with its result as `T1`, `T2`, and so on. The agent can open and search them with `read_tool_result`. From the second compaction on, fx saves the previous compaction whole as `L1`, `L2`, and so on, and the model writes one summary that stands in for all of them. The rules, status, and open entries that still apply carry over word for word. ## Requests and saved history Automatic compaction asks the conversation's model for its notes in a request that repeats the pending conversation with the same instructions, tools, and settings, so the provider can reuse its prompt cache. `/compact`, compaction after a context overflow, and an automatic attempt that fails or doesn't fit send a separate request instead, with the model's reasoning turned off or at its lowest level. If that request fails or returns nothing, fx tries once more through AI Gateway with a model from another family: `openai/gpt-6-sol` when the conversation uses an Anthropic model, and `anthropic/claude-sonnet-5` otherwise. A large history may take several requests. Compaction requests never use [Ultrafast](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode). They count toward your provider usage and may add cost. See [Usage and costs](https://fx.sh/docs/using-fx/usage-and-costs.md#additional-model-requests). Compaction does not delete the original conversation. [Full detail](https://fx.sh/docs/using-fx/keyboard-shortcuts.md#full-detail) loads earlier turns from the saved session, one compaction at a time. fx switches to the compacted context only after saving its checkpoint. If that fails, it keeps the previous context. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Subagents" description: "Delegate work to named agents that run alongside the main agent and report back." canonical_url: https://fx.sh/docs/capabilities/subagents markdown_url: https://fx.sh/docs/capabilities/subagents.md --- # Subagents Subagents let fx delegate independent work to another agent. Each subagent has a name and its own conversation, works in the same workspace, and reports back to the agent that started it. Ask fx to delegate work that can run independently: ```text Have a subagent review the parser tests and report missing cases. It should not edit files. Meanwhile, investigate the parse error. ``` ## Start a subagent and send it messages The main agent starts a subagent by sending a message to a new name, and continues it by sending more messages to that name: ```text Start a subagent named reviewer to check the parser tests. Ask reviewer whether the new test covers the missing case. ``` Sending a message doesn't wait for an answer. The main agent keeps working, or ends its turn, while the subagent works on its own. It can also wait for the next report, or check what each subagent is doing. Subagents belong to the current fx session and remain available when you resume it. Their conversations do not appear separately in `fx sessions` or the `fx -r` session picker. A subagent that an earlier version of fx started for a single task can't take messages. ## Reports When a subagent's work ends, its report goes to the agent that started it, as that agent's next message: - If the main agent is working, the report joins its turn at the next step. - If the main agent is idle, the report starts its next turn. The main agent can pick up a subagent's result without a new prompt from you. Each report shows as a subagent tool call in the main agent's conversation, such as `reviewer completed · Found 2 bugs in src/parser.zig`. A message a subagent sends the main agent shows the same way, as `from reviewer · …`. When the work failed or was interrupted, the call is marked as failed. Press `ctrl+o` to read the full text. fx marks reports and messages as the subagent's output, not as your instructions. A report also says when you started the turn yourself on the subagent's screen, and why its work was cancelled: you stopped it, or fx quit. A message the subagent sends during a turn you started says so too. A subagent reports when the work it was given ends, whether it finished, failed, or was cancelled. To hear from it more or less often, say so when you start it: | Timing | The subagent reports | | --- | --- | | When its work ends (default) | When the work the main agent gave it ends | | After every turn | After each of its turns, including turns you start on its screen | | Never | Only when its work fails, or fx crashes before it finishes | ```text Start a subagent named watcher that reports after every turn. ``` If fx quits or stops before a report reaches the main agent, fx delivers the report when you resume the session. Work that quitting cut short is reported as cancelled, so after you resume, the main agent can start a turn on its own to handle it. ## While a subagent works You can send a working subagent more instructions through the main agent: ```text Tell reviewer to include invalid UTF-8 input in its review. ``` A working subagent reads a new message at its next step, such as after the tool it is running finishes. When the turn can't take it, the message waits, and every message still waiting when the turn ends goes into the subagent's next turn together. The main agent can change a subagent's saved instructions only while it is idle. Up to 64 messages from other agents can wait for one subagent. The main agent is told when a message doesn't fit. Ask the main agent to stop a subagent to end its turn and drop the messages waiting for it. A stop the main agent makes sends no report, since the main agent already knows. To remove a subagent the main agent no longer needs, ask the main agent to close it, or [close it yourself](#close-a-subagent). ## Switch to a subagent Press `down` with nothing typed, or `ctrl+x` at any time, to open the [agent list](https://fx.sh/docs/using-fx/instances.md#switch-between-instances). Each subagent's row comes right after the agent that started it, titled from its first task. Move to its row with `up` and `down`, and fx shows that subagent as you reach it; press `enter` to stay there, or `esc` to go back. fx clears the screen and prints that agent's conversation in place, and the footer names the subagent on screen, such as `reviewer · done ↓`. Agents off screen keep working, so switching to one shows its output so far, still streaming. On a subagent's screen: - What you type goes to that subagent as your message. Its reply stays in its own conversation. The main agent sees that turn only if the subagent reports after every turn, or if the turn fails. - Press `esc` twice to stop its turn. When it was working on something from the main agent, the main agent's messages it hasn't read yet are dropped, and the main agent is told how many. - An image or `$skill` you send while it works ends its turn so that your prompt runs next. The work the main agent gave it counts as done. - Its approvals and questions appear there. - A change to its model, reasoning effort, fast mode, or permission mode applies to that subagent only. - `/resume`, `/new`, `/fork`, `/clear`, `/reset`, and `/close` aren't available. Switch back to its instance's screen to use them. When a subagent asks for approval or asks a question while it isn't on screen, the prompt also appears on the screen of its instance, titled with the subagent's name. With one instance, that's the main screen. When several of its subagents wait, the oldest prompt shows first. The prompt moves back when you switch to the subagent. While any agent that isn't on screen waits for you, the footer shows a note such as `reviewer needs approval · main ↓`, or `reviewer needs you · main ↓` when its request needs you to continue it, such as when it's out of credits. Otherwise, while subagents that aren't on screen are working, the footer counts them, such as `1 subagent working · main ↓`. After you resume a session, switching to a subagent shows its saved conversation before it runs again. In the agent list, each instance is followed by its own subagents. Closing an instance with `/close` stops its subagents without a report. Reports they already owed stay in that session, and arrive if you reopen it with `fx --resume`. ## Close a subagent Closing a subagent stops it and removes it for good. To close one yourself, open the [agent list](https://fx.sh/docs/using-fx/instances.md#switch-between-instances), move to its row, and press `x`. The footer asks you to press `x` again, and any other key keeps the subagent. When you close a subagent: - Its turn stops, and the messages waiting for it are dropped. - It leaves the agent list, with the subagents it started, and doesn't come back when you resume the session. - If it was working on something from the main agent, the main agent is told that you closed it. The main agent can close a subagent too, and that close sends no report. A later message to a closed subagent's name starts a new subagent. ## Use an agent profile An [agent profile](https://fx.sh/docs/configure-fx/agent-profiles.md) saves what a subagent can use: its tools, MCP servers, permission mode, model, reasoning effort, and instructions. fx tells the main agent which profiles exist, and the main agent names one when a task needs it. Otherwise it starts the subagent without a profile. To choose one yourself, name it in your prompt: ```text Have a subagent in the reviewer profile check the new tests. ``` Whatever its profile, fx tells each subagent its name and which agent started it. On a subagent's screen, you can ask it to tell the main agent something, and it sends the main agent a message. ## Choose a model You can choose a different model and reasoning effort for each subagent. This lets you use a stronger model to plan and review, then delegate implementation to a lower-cost model. For example, keep [GPT-6 Astra](https://vercel.com/ai-gateway/models/gpt-6-astra) in the main conversation and ask: ```text Have a subagent use Kimi K3 to implement this plan. Return the changes and test results for review. ``` Subagents use the model and reasoning effort of the agent that starts them unless you choose others when creating them, or their profile sets them. A subagent keeps that selection for later messages. See [Models](https://fx.sh/docs/configure-fx/models.md). ## Ultrafast inheritance New subagents inherit the parent turn's [Ultrafast request](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode). Their model must also advertise Ultrafast pricing through AI Gateway; choosing another model does not bypass that check. A subagent retains its saved preference when resumed. An explicit child disable remains off, and a parent with Ultrafast off prevents a saved child opt-in from enabling it. Turn the parent off with `/ultrafast off`, `--no-ultrafast`, or `FX_ULTRAFAST=0` before delegating without the tier. Subagent requests are billed separately and can also incur the higher Ultrafast prices. See [Usage and costs](https://fx.sh/docs/using-fx/usage-and-costs.md). ## Access A subagent starts in fx's `main` [profile](https://fx.sh/docs/configure-fx/agent-profiles.md) unless it's given another. `main` sets nothing, so the subagent has the tools and MCP servers of the agent that started it and runs in its permission mode. It follows that mode as it changes, so switching an instance between `ask` and `auto` reaches its subagents at their next tool call. In another profile, it gets what that profile sets instead. A mode you choose on a subagent's own screen wins over both. With several [instances](https://fx.sh/docs/using-fx/instances.md) open, a subagent's "don't ask again" approvals belong to the instance at the top of its tree. A subagent can start subagents of its own unless its profile leaves out the `subagent` tool. Its subagents report to it, not to the main agent, and don't get the `subagent` tool themselves, so subagents nest two levels deep. If several subagents edit files, give each one a separate area to avoid conflicting changes. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Instances" description: "Run several fx conversations in one terminal and switch between them." canonical_url: https://fx.sh/docs/using-fx/instances markdown_url: https://fx.sh/docs/using-fx/instances.md --- # Instances One fx process can run several instances side by side. Each instance is a complete fx conversation with its own session, and each keeps working while another one is on screen. Start fx with three instances: ```bash fx --instances 3 ``` While more than one instance runs, the right side of the footer shows which one is on screen, such as `fx 2/3 ↓`. Press `down` with nothing typed to open the agent list and [switch](#switch-between-instances) to another instance. With a draft, the footer shows `fx 2/3 · ctrl+x`, and `ctrl+x` opens the same list. ## Start and close instances | Command | What it does | | --- | --- | | `fx --instances <n>` | Start fx with `n` instances. | | `/launch` | Start another instance with a fresh session and show it. | | `/launch <profile>` | Start another instance in an [agent profile](https://fx.sh/docs/configure-fx/agent-profiles.md) and show it. | | `/close` | Close the instance on screen and its subagents. | | `/agents` | List the open agents and switch to one. | A new instance starts from the settings fx started with, including launch options such as `--model`. An instance you start in a profile takes the profile's model and effort, unless you chose a model with `--model` or `FX_MODEL`, or an effort with `--effort`. fx doesn't reread your settings for it, so a setting you change after fx starts reaches new instances the next time you start fx. When you close the first instance, the next one becomes `fx 1/n` with its conversation intact. Closing the only open instance exits fx and prints its resume command. `/close` works on an instance's screen. On a [subagent's screen](https://fx.sh/docs/capabilities/subagents.md#switch-to-a-subagent), switch back to its instance first. ## Switch between instances To switch, open the agent list in place of the footer: - Press `down` with nothing typed. - Press `ctrl+x` at any time, even with a draft. Each agent keeps its own draft, so yours stays on the agent you typed it on. - Run `/agents`. Moving through the list with `up` and `down` shows each agent as you reach it. Press `enter` to stay on the agent shown, or `esc` to go back to the one you opened the list from. `ctrl+x` and `ctrl+c` also go back. On a subagent's row, `x` [closes it](https://fx.sh/docs/capabilities/subagents.md#close-a-subagent). While the list is open, other keys do nothing, so no key edits the shown agent's draft or answers its prompts. If the agent shown is waiting for an approval or an answer, the list takes the prompt's place, and the prompt comes back when the list closes. Switching clears the screen and prints the chosen conversation in place. An instance that is off screen keeps working, so switching to it shows its output so far. While an instance that isn't on screen waits for an approval, an answer, or a request only you can continue, such as one out of credits, the footer names it before the instance on screen, such as `fx 3 needs approval · fx 1/3 ↓` or `fx 2 needs you · fx 1/2 ↓`. When several wait, the note counts them, as in `fx 1 and 1 more need you · fx 2/3 ↓`. When one finishes a turn, the footer says so, such as `fx 2 finished · fx 1/2 ↓`, until you show it. Otherwise, while subagents that aren't on screen are working, the footer counts them, such as `2 subagents working · fx 1/3 ↓`. `option+left`, `option+right`, and `option+up` only move the cursor, as they do with one instance. ## See every instance The agent list shows every open agent, one per line. Each instance comes in the order it started, followed by its own subagents: ```text fx 1 (on screen) · Fix the login bug · main · working · opus 4.7 high reviewer · Review the parser · reviewer · idle · haiku 4.5 fx 2 · Review the auth changes · main · needs approval · opus 4.7 fx 3 · new session · main · finished · opus 4.7 ``` Each line shows the instance's number or the subagent's name, its session's title, its agent profile, what it is doing, and its model. What it is doing is `working`, `needs approval`, `has a question`, `needs you` for a request only you can continue, `finished` for a turn that ended since you last looked at it, or `idle`. The model shows its reasoning effort when that isn't the default. A subagent's title comes from its first task, as an instance's comes from its first prompt. `(on screen)` marks the agent you opened the list from, which `esc` goes back to. ## What each instance keeps Each instance has its own: - Session and conversation - Draft and attached images - Model, reasoning effort, and Fast mode - Permission mode and "don't ask again" approvals Changing the [permission mode](https://fx.sh/docs/configure-fx/permissions.md#change-the-mode) with `shift+tab` or `/permissions` changes it only for the instance on screen. Permission rules in your settings apply to every instance. A subagent started in an instance, or by one of that instance's subagents, starts from that instance's tools and permissions, and its prompts show on that instance's screen. See [Subagents](https://fx.sh/docs/capabilities/subagents.md#access). `/new` starts a fresh session in the instance on screen and leaves the others as they are. ## Quit and resume `/exit` ends every instance, and each one that has taken a turn keeps its own saved session. fx then prints the resume command for the instance you quit from, or, if that one hasn't taken a turn, for one that has: ```text Resume this session with: fx --resume <session-id> ``` Resuming any session from a group of instances, with `fx --resume <session-id>`, `fx -c`, or `fx -r`, brings back the whole group. The session you resume becomes `fx 1/n` and is on screen, and the others follow in their saved order. An instance joins its group when its first turn is saved, so one you never used doesn't come back. A session you've deleted since stays out, and if another can't be loaded, fx says so and brings back the rest. An instance whose session stopped during a request sends that request again, as `fx -c` does for the session you resume. Each instance comes back in the [agent profile](https://fx.sh/docs/configure-fx/agent-profiles.md) it ran in. To resume the session in another profile, add `--profile`, as in `fx --profile main --resume <session-id>`. The other instances keep their own. `/resume` inside fx replaces only the session on screen, and the instance keeps its profile. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Web search" description: "Search current public information or read a known URL." canonical_url: https://fx.sh/docs/capabilities/web-search markdown_url: https://fx.sh/docs/capabilities/web-search.md --- # Web search fx can search the public web for current information and return an answer with links to its sources. Web search needs [AI Gateway](https://fx.sh/docs/getting-started/authentication.md#model-providers), which searches with Exa. With a ChatGPT or Grok subscription or a custom connection, fx can't search the web, but it can still read a URL with `web_fetch`. Ask fx to search when an answer depends on recent information or you want sources: ```bash fx ask "What changed in the latest Zig release? Use official sources." ``` ## Search or fetch | Tool | Use | | --- | --- | | `web_search` | Research a question across public sources. | | `web_fetch` | Read a public URL you provide. | Ask for official sources when they matter. If you already know the page, include its URL so fx can read it directly. Both tools access public pages only. They cannot sign in, click controls, or read private pages. `web_fetch` refuses addresses on your machine or local network, such as `localhost`, and URLs that contain a username or password. AI Gateway runs each search, so fx can't ask before one. A `web_search` [permission rule](https://fx.sh/docs/configure-fx/permissions.md#persistent-rules) set to `ask` or `deny` turns web search off instead, except in `full-access` mode. ## Data and privacy Search queries and fetched URLs leave your machine. fx records the activity in the local session, and searches may add cost. See [Data and privacy](https://fx.sh/docs/using-fx/data-and-privacy.md) and [Usage and costs](https://fx.sh/docs/using-fx/usage-and-costs.md). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Vision" description: "Give fx screenshots, diagrams, and other images to work with." canonical_url: https://fx.sh/docs/capabilities/vision markdown_url: https://fx.sh/docs/capabilities/vision.md --- # Vision Give fx a screenshot, diagram, or photo when the prompt needs visual context. <span id="add-visual-context" /> ## Attach an image In fx, run `/image <path>` to add an image to the prompt. You can also drag a local image into the terminal; fx attaches the path it pastes. An image path you type in the prompt, such as `@screenshot.png`, is attached when you send the prompt. On macOS, `/paste` or `ctrl+v` adds an image from the clipboard. `/images` shows the images you have attached, and `/images clear` removes them. For a one-off request, pass the image with `--image`: ```bash fx ask --image <path> "Describe this interface." ``` Repeat `--image` to include more than one image. Editors using ACP can send images with `session/prompt`; see [ACP server](https://fx.sh/docs/using-fx/acp.md). ## Supported inputs Prompt attachments can be PNG, JPEG, GIF, or WebP files up to 20 MiB each. fx saves each original with the session and sends it to the model when it is at most 3.75 MiB and 8,000 pixels per side, or 2,000 pixels per side when the request carries more than 20 images. For a larger image, the model gets a note with the path of the saved copy instead, so the agent can make a smaller copy with an image tool and read that. See [ACP server](https://fx.sh/docs/using-fx/acp.md#protocol-limits) for inline editor image limits. The agent can also read images up to 3.75 MiB and 8,000 pixels per side with `read_file`. Models with image input receive the pixels; other models receive guidance to use the vision tool when available. ## How vision works fx uses the selected model when it can accept image input. The image travels with the prompt and the model reads it directly. Along with the image, the model gets the path of the copy fx saved with the session, so the agent can open the file with its tools instead of searching your disk for it. The model doesn't get the path you attached the image from. With AI Gateway, fx has another route for models that cannot accept images. It sends the image to a fixed helper model, `google/gemini-2.5-flash`, and gives the selected model the resulting visual evidence. This is a separate model request with its own usage and cost; see [Additional model requests](https://fx.sh/docs/using-fx/usage-and-costs.md#additional-model-requests). In `ask` mode, fx asks before it sends images to the helper model. ChatGPT and Grok subscriptions and custom connections have no helper model, so the selected model must accept images. If it doesn't, fx doesn't send a prompt that has images attached. For a [custom connection](https://fx.sh/docs/configure-fx/custom-model-connections.md#model-metadata), set `supports_vision: true` for a model that accepts images. If fx can't confirm that the selected model accepts images, for example because the model catalog is unavailable, it doesn't send the attached images and tells you. Images from earlier turns never block a new prompt. When the model can't use them, fx leaves them out of that request and keeps them in the conversation. ## Request size Each request to the selected model includes the images already in the conversation, so a session with many screenshots sends larger requests as it goes. fx keeps each request within 30 MiB and 100 images. When a request would be larger, fx leaves the oldest images out of that request and keeps the newest ones. The saved conversation does not change. fx leaves images out a block at a time, counting from the oldest. Each block is a quarter of the limit: 25 images, or fewer when they reach 7.5 MiB. Leaving out one more image for each new one would change the start of every request and lose its [prompt cache](https://fx.sh/docs/using-fx/usage-and-costs.md#prompt-caching). With blocks, the start of the request stays the same until the next block is left out. For each image it leaves out, the model receives a note instead. For an image from a tool result, the note names the `read_tool_result` handle that loads it again. For an attached image, it names the path of the saved copy, when fx saved one, so the model can open it with `read_file`. If a provider still rejects a request as too large, fx lowers the limit for that model and retries with fewer images instead of compacting. This includes a size rejection that AI Gateway reports after falling back to another provider. fx keeps retrying as long as each retry leaves out more images, and keeps the lower limit until you start a new conversation or restart fx. When the rejected request carried no images, or a retry couldn't leave out any more, fx treats the rejection as a context overflow; see [Context compaction](https://fx.sh/docs/using-fx/context-compaction.md). ## Trust fx treats instructions found inside an image as untrusted content. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Models" description: "Choose a model and adjust its reasoning effort." canonical_url: https://fx.sh/docs/configure-fx/models markdown_url: https://fx.sh/docs/configure-fx/models.md --- # Models Use `/model` to choose a model. fx remembers your selection for each provider. ## Browse and select Type `/model` and search by name, or press ctrl+p to switch models without losing the prompt you are typing. Search matches abbreviated or slightly misspelled provider and model names. The available models depend on your [provider](https://fx.sh/docs/getting-started/authentication.md#model-providers). Use `/provider` to change it. A [custom connection](https://fx.sh/docs/configure-fx/custom-model-connections.md) uses the model IDs understood by its endpoint. With AI Gateway, fx uses `spacexai/grok-4.7` until you choose another model. Codex and Grok have no default model: `fx provider codex` or `fx provider grok` saves the model you last used with that provider, or the first model in its catalog. To see the available IDs from your terminal: ```bash fx models ``` If fx is already responding, the new model takes over on the next turn. ## Reasoning effort After choosing a model with `/model`, select a reasoning effort if the model supports it. Higher effort gives the model more room to reason and can take longer. Choose `default` to use the model's default effort. To change only the effort, run `/effort`. It lists the current model's levels with the one in use marked; move with the arrow keys and press Enter to apply one. To choose from a list under the prompt instead, as with `/model`, type `/effort` and press Tab. You can also pass the level directly: ```bash /effort high ``` The choice is saved as your personal preference, the same as choosing an effort in `/model`. If fx is already responding, the new effort takes over on the next turn. You can also choose a different model and effort for each [subagent](https://fx.sh/docs/capabilities/subagents.md#choose-a-model). ## Fast mode Use `/fast` to turn faster inference on or off for models that support it, or `/fast on` and `/fast off` to set it. fx saves your preference. Choosing a different model turns Fast mode off unless you choose **fast** in the model picker's speed step. The model picker labels a model **Fast** when it always runs fast, such as a model whose ID ends in `-fast`, and **Fast mode** when it offers Fast mode as an option. A model can show both. Models that offer Ultrafast show **Ultrafast mode**. ## Ultrafast mode Ultrafast is a separate, default-off request for OpenAI's higher-priced service tier through AI Gateway. It requires an OpenAI model whose Gateway catalog advertises Ultrafast pricing. It does not work through custom connections or subscription providers. > **Check pricing before enabling Ultrafast** > > Ultrafast costs more than the standard tier. Check your model's [current Gateway pricing](https://vercel.com/ai-gateway/models) before sending a prompt. Eligible subagents can inherit the request and incur the same higher prices. ### Enable it in fx Select an eligible model, then enable the request: ```text /model openai/gpt-6-astra /ultrafast on /ultrafast status ``` Use `/ultrafast off` to disable it. With no argument, `/ultrafast` reports status; it does not toggle the setting like `/fast`. You can also change **Ultrafast mode** in `/settings`, or choose **ultrafast** in the model picker's speed step. To select the model, effort, and speed together: ```text /model openai/gpt-6-astra xhigh ultrafast ``` The selection notice includes the effort and speed. Both speed modes use one lightning marker: plain for Fast and yellow for Ultrafast. These controls save your personal preference. Switching models without explicitly choosing Ultrafast clears the existing request. ### Enable it for one process These examples select an eligible model without changing your saved defaults: ```sh fx --provider gateway --model openai/gpt-6-astra --ultrafast FX_PROVIDER=gateway fx ask --model openai/gpt-6-astra --ultrafast "Review this change" FX_PROVIDER=gateway fx acp --model openai/gpt-6-astra --ultrafast ``` Or use environment variables with any of those entry points: ```sh FX_PROVIDER=gateway FX_MODEL=openai/gpt-6-astra FX_ULTRAFAST=1 fx ``` `--no-ultrafast` or `FX_ULTRAFAST=0` explicitly disables the request. CLI flags take precedence over environment variables. `FX_ULTRAFAST` accepts `1`, `true`, `on`, or `yes` to enable and `0`, `false`, `off`, or `no` to disable; any other value fails before a model request. When you pass more than one speed flag, the last one wins, so `--ultrafast --fast` runs in Fast mode. ### Save a profile default Add these fields to `~/.fx/settings.json`, preserving your other settings: ```json { "provider": "gateway", "models": { "gateway": "openai/gpt-6-astra" }, "ultrafast_mode": true } ``` To save only the Ultrafast default without editing the file, run `fx config set ultrafast_mode true`. Restart fx after either change. You can also set `ultrafast_mode` in a profile [workspace entry](https://fx.sh/docs/configure-fx/configuration.md#workspace-entries). A committed project `.fx.json` cannot enable it. CLI and environment opt-ins stay process-local and are not saved into a later session. A resumed conversation restores its saved preference unless a CLI or environment override applies. Use an explicit disable when you want to resume without the higher-priced tier. ### Eligibility and served-tier confirmation fx uses Gateway pricing metadata rather than a model-name allowlist. A model such as GPT-5.6 Sol qualifies only when the catalog for your selected Gateway account/team advertises its Ultrafast prices. OpenAI preview access alone does not establish Gateway eligibility. fx rejects unknown or unsupported eligibility before sending a completion request; it does not silently downgrade locally. Ultrafast routes only through OpenAI. A strict provider list that excludes `openai` is rejected. Enabling Fast disables Ultrafast, and enabling Ultrafast disables Fast. `ultrafast_requested` in `fx status --json` and the Ultrafast line of `/status` describe the request, not the tier Gateway served. If Gateway does not confirm Ultrafast, fx warns that the response may have used a standard or lower tier. The footer is not proof of billing or throughput. [ACP clients](https://fx.sh/docs/using-fx/acp.md#ultrafast-per-session) can change the request per session. [Subagents](https://fx.sh/docs/capabilities/subagents.md#ultrafast-inheritance) inherit it subject to their model and saved preference. [libfx](https://fx.sh/docs/lib/models.md#enable-ultrafast) exposes `model.ultrafast` for native and WebAssembly agents. Session titles, permission reviews, and compaction do not inherit it. ## Temporary overrides Choose a provider and model when starting fx: ```sh fx --provider gateway --model '<model-id>' ``` Or choose a model for one prompt: ```sh fx ask --model '<model-id>' "Review the changes in this branch" ``` These flags leave your saved defaults unchanged. `fx ask`, `fx pr`, `fx issue`, and `fx acp` take `--provider`, `--model`, `--effort`, `--fast`, and `--ultrafast` after the command, such as `fx acp --provider codex --model '<model-id>'`. ## AI Gateway routing One AI Gateway model may be available from several inference providers. Use `provider_order` to prefer specific providers, and `provider_strict` to prevent fallback outside that list: ```json { "provider_order": ["bedrock", "anthropic"], "provider_strict": true } ``` These settings work in `.fx.json` and `~/.fx/settings.json`. For one request: ```sh fx ask --provider-order bedrock,anthropic --provider-strict "Review this change" ``` `--no-provider-strict` lifts a saved restriction for that request. To route every request in one process, set `FX_PROVIDER_ORDER=bedrock,anthropic` and `FX_PROVIDER_STRICT=1`. Use provider slugs from the [AI Gateway model catalog](https://vercel.com/ai-gateway/models). `fx ask --json` returns the provider that served the last request in `resolved_provider` when AI Gateway reports it. ## Selection order If fx starts with an unexpected model, check `--model` and `FX_MODEL` first: both override saved preferences, and `--model` takes precedence. Workspace preferences in `~/.fx/settings.json` override global preferences. Use `/status` to check the current selection. See [Configuration](https://fx.sh/docs/configure-fx/configuration.md) for settings and scopes. ## AI Gateway catalogs AI Gateway can include models available to your selected Vercel team. To use another team's catalog, [change teams](https://fx.sh/docs/getting-started/authentication.md#change-vercel-team). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Custom model connections" description: "Connect fx to Ollama, vLLM, OpenRouter, and compatible endpoints." canonical_url: https://fx.sh/docs/configure-fx/custom-model-connections markdown_url: https://fx.sh/docs/configure-fx/custom-model-connections.md --- # Custom model connections Connect fx to an OpenAI-compatible Chat Completions endpoint. A named connection defines the endpoint, authentication, and optional model limits. Connections belong in the top level of `~/.fx/settings.json`. ## Connect Ollama Start Ollama with a 32K context window: ```bash OLLAMA_CONTEXT_LENGTH=32768 ollama serve ``` In another terminal, pull the model: ```bash ollama pull qwen2.5:1.5b ``` Add the connection: ```json { "provider": "local", "providers": { "local": { "protocol": "openai-chat-completions", "base_url": "http://localhost:11434/v1", "auth": { "type": "none" }, "model_metadata": { "qwen2.5:1.5b": { "context_window": 32768, "max_output_tokens": 2048, "supports_tool_use": true } } } }, "models": { "local": "qwen2.5:1.5b" } } ``` The `context_window` must match [Ollama's context setting](https://docs.ollama.com/context-length). Select the connection, then start fx: ```bash fx provider local ``` ```bash fx ``` ## Connect a hosted endpoint For OpenRouter, vLLM, or another endpoint that accepts bearer authentication: ```json { "provider": "openrouter", "providers": { "openrouter": { "protocol": "openai-chat-completions", "base_url": "https://openrouter.ai/api/v1", "auth": { "type": "bearer", "env": "OPENROUTER_API_KEY" } } }, "models": { "openrouter": "openai/gpt-4.1-mini" } } ``` Set your key and start fx: ```sh export OPENROUTER_API_KEY="your-api-key" fx ``` ## Connection fields | Field | Description | Required | | --- | --- | --- | | `protocol` | Must be `openai-chat-completions`. | Yes | | `base_url` | API prefix. fx appends `/chat/completions`. | Yes | | `auth` | `{ "type": "none" }` or bearer authentication from an environment variable. | Yes | | `tool_choice_mode` | `omit` by default; use `send` when the server supports tool-choice controls. | No | | `reviewer_model` | Model used for automatic permission reviews. Defaults to the selected model. | No | | `model_metadata` | Limits and capabilities for known model IDs. | No | Connection names begin with a letter and can contain letters, digits, underscores, or hyphens. `gateway`, `codex`, and `grok` are reserved. Base URLs require HTTPS except for loopback addresses (`localhost`, `127.0.0.1`, and `[::1]`), and can't include a user name, password, query, or fragment. ### Model metadata | Field | Description | | --- | --- | | `context_window` | Context limit used for automatic compaction. | | `max_output_tokens` | Maximum response length in tokens. Must be smaller than `context_window` when both are set. | | `supports_tool_use` | Records whether the model supports function tools. | | `supports_vision` | Enable image input for a model that supports it. | `fx models` lists IDs declared in `model_metadata`. You can still select another ID, but the endpoint must recognize it. Without a known context window, fx cannot calculate its automatic compaction threshold. ## Select a connection `fx provider <name>` saves the selection. The connection needs a model under `models`; without one, fx reports that no model is selected for this connection. Use environment variables for one process: ```bash FX_PROVIDER=local FX_MODEL=qwen2.5:1.5b fx ask "Read README.md" ``` Project `.fx.json` files cannot define or select custom connections. A private workspace entry in `~/.fx/settings.json` can select one, while its definition remains at the top level. ## Compatibility Custom connections support streaming text, reasoning, and function tools through Chat Completions. The server must provide the chat template and tool or reasoning parser required by its model. Image input requires `supports_vision: true` in the model's metadata. Gateway search, credit checks, `/usage` reports, and vision fallback are unavailable. The adapter does not support custom authentication headers or provider-specific reasoning controls. Because the adapter can't lower the reasoning effort, fx sends a reply that ran out of output tokens before any text again only when the model's metadata has no `max_output_tokens`. The second request names a limit. See [A reply runs out of output tokens](https://fx.sh/docs/using-fx/troubleshooting.md#a-reply-runs-out-of-output-tokens). Normal [permission rules](https://fx.sh/docs/configure-fx/permissions.md) still apply. In `auto` mode, reviews use the connection's `reviewer_model`, or its selected model when none is set. Use `fx status --json` to check the selected endpoint in `provider_endpoint` and the model in `model`. If fx reports a missing credential, set the variable named by `auth.env`. For an HTTP error, check the endpoint's response. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Permissions" description: "Control tool execution with modes, rules, and session grants." canonical_url: https://fx.sh/docs/configure-fx/permissions markdown_url: https://fx.sh/docs/configure-fx/permissions.md --- # Permissions Permission settings control whether fx can change files, run commands, and access paths outside your workspace. ## Modes | Mode | Description | | --- | --- | | `ask` | Ask before acting. | | `auto` | Run routine work directly and review other actions. This is the default. | | <code className="!whitespace-nowrap">full-access</code> | Disable fx permission checks. Shown as "full access" in the interface. | <span id="automatic-review-configuration-and-cost" /> ### Auto mode `auto` is the default permission mode. It runs routine development actions directly and reviews other actions before running them. **Runs directly** - Read files and search code or the web - Create or edit ordinary project files - Run recognized project commands, including `git status`, local dependency installs, tests, builds, and development servers **Reviews first** - Run unrecognized or dynamic shell commands - Overwrite files outside the workspace - Change sensitive configuration - Call an MCP server tool For reviewed actions, fx sends the exact action to a model that checks for two problems: prompt injection, where instructions planted in a file, web page, or tool output make the action delete or overwrite files, send data out, run outside code, weaken security, or use credentials you didn't ask for, and harm to your machine, such as wiping your home directory, installing malware, or sending your secrets somewhere you didn't ask for. Everything else runs, including deleting code or tests, pushing branches, running scripts the agent wrote, editing files that contain instructions, and following a tool's own instructions to read, search, build, test, or run its next step, such as a git hint or a workflow tool's next command. To hold an action, the model must quote the text that shows the problem, and fx checks that the quote is really there. When the model flags a problem with that proof, fx asks for a second review of the same action and runs it only if that review clears it. If a review cannot finish, fx also holds the action. A held action doesn't open a prompt or end the turn. fx tells the agent why, and the agent can try another way. The review model depends on your [provider](https://fx.sh/docs/getting-started/authentication.md#model-providers): | Provider | Review model | | --- | --- | | AI Gateway | `openai/gpt-5.6-luna` by default; configurable | | Codex | `gpt-5.6-luna` | | Grok | `grok-4.5` | | Custom connection | Its `reviewer_model`, or the selected model | To choose another AI Gateway reviewer, add `review_model` to `~/.fx/settings.json`: ```json { "review_model": "typesafeai/jev" } ``` `FX_REVIEW_MODEL` overrides it for one process. The setting accepts an AI Gateway chat model ID or `typesafeai/jev`. Jev uses AI Gateway unless `TYPESAFE_API_KEY` is set, in which case fx calls TypeSafe directly. Jev answers without quotes, so fx keeps its decisions as returned, with no quote check or second review. Codex and Grok use their fixed reviewers. Custom connections use their own [`reviewer_model`](https://fx.sh/docs/configure-fx/custom-model-connections.md#connection-fields). Each model review uses tokens and can add to your [usage and costs](https://fx.sh/docs/using-fx/usage-and-costs.md#additional-model-requests). Actions allowed or denied by your rules do not need a model review. To change how fx handles a matching action, add a [persistent rule](#persistent-rules) that allows it, denies it, or asks for your approval. ### See your permissions In the interactive shell, `/permissions` opens a panel above the composer. It shows the mode, your configured rules, the grants collected in this session, and the rules saved with this conversation, with their IDs. Esc closes it, and it leaves nothing in the conversation. ### Change the mode In the interactive shell: ```bash /permissions ask ``` ```bash /permissions auto ``` ```bash /permissions full-access ``` `/permissions reset` switches back to `ask` and clears the grants collected in this session. fx saves the mode you choose as `permission_mode` in `~/.fx/settings.json`, so later sessions start in it. With several [instances](https://fx.sh/docs/using-fx/instances.md) open, these commands and `shift+tab` change the instance on screen. On a [subagent's screen](https://fx.sh/docs/capabilities/subagents.md#switch-to-a-subagent), they change that subagent. An [agent profile](https://fx.sh/docs/configure-fx/agent-profiles.md#permission-mode) can also set the mode an agent starts in. From your terminal, inspect the effective mode and rules: ```bash fx permissions --json ``` To set the mode for one interactive session or `fx ask` request, pass `--permission-mode <mode>` or one of its shortcuts: `--ask`, `--auto`, or `--full-access`. For example, `fx ask --full-access <prompt>` disables fx permission checks for one request. You can also set the mode with `permission_mode` in `~/.fx/settings.json` or the `FX_PERMISSION_MODE` process override. See [Configuration](https://fx.sh/docs/configure-fx/configuration.md). `yolo`, an older name for `full-access`, still works in settings, flags, and `FX_PERMISSION_MODE`. ## When fx asks In `ask` mode, unresolved sensitive calls open an approval prompt with three choices: | Choice | Effect | | --- | --- | | Yes | Run this request without creating a grant. | | Yes, and don't ask again | Run it and create a session grant for the displayed scope. | | No | Do not run the request. | For an MCP tool call, the choices are **Allow once**, **Allow this MCP tool for this session**, and **Deny**. ## Persistent rules Permission rules are stored in `~/.fx/settings.json`, either globally or under the current workspace profile. Project `.fx.json` files cannot define them. ```json { "permission": { "*": "ask", "bash": { "git *": "allow", "git push *": "deny" }, "edit": { "*": "deny", "docs/*": "allow" } } } ``` Shell commands use the `bash` key, and `write_file` and `edit_file` use `edit`. `read_file`, `glob_files`, and `grep_files` use `read`, `glob`, and `grep`, both skill tools use `skill`, and other tools use their own name. Rules use wildcard matching, and the last matching rule wins. A command allow rule matches only a command with no chaining or substitution, so `git *` doesn't allow `git status && rm -rf build`. A deny rule also matches a command chained with others. Rules under a workspace replace your global rules in that workspace instead of adding to them, and an empty `permission` object there clears them. Put broad rules before specific exceptions. In the example above, edits are denied by default and then allowed under `docs/`. Use [`/allowlist`](https://fx.sh/docs/using-fx/slash-commands.md) in the interactive shell to inspect or change rules. Choose `workspace` for the current project or `global` for rules that apply across projects, as in `/allowlist global add command "git status"`. Without a scope, `/allowlist` changes workspace rules, so the first workspace rule you add stops your global rules from applying in that project. The older words `local` and `user` still work, with a warning, until fx 0.0.18. ## Rules saved with a conversation You can remember an exact allow or deny decision for a saved conversation without granting it to the whole project. In an active saved session: ```text /permissions remember allow shell {"action":"run","command":"git status"} ``` fx shows the prepared action for confirmation. Confirming saves the rule; it does not run the command. A different command is a different action. The `/permissions` panel lists the saved rules and their IDs. Remove one with `/permissions revoke <rule-id>`. Revocation also asks for confirmation. These rules survive resuming the conversation. A configured deny still takes precedence over a saved allow. A saved deny blocks an action your configured rules allow, and a saved allow answers a configured `ask` rule without prompting. ## Session grants Choosing "Yes, and don't ask again" creates a live session grant. It is not written to settings and is not restored when you resume the session. The `/permissions` panel lists this session's grants. If you run more than one instance, a grant belongs to the one whose turn asked for it. A grant for a subagent is kept with the instance at the top of its tree. | Permission choice | Scope | Survives resume? | | --- | --- | --- | | Profile rule | Global or workspace | Yes | | `/permissions remember` | One saved conversation, exact action | Yes | | Approval prompt's session grant | Current running session | No | If a call is denied or reviewed when you did not expect it, see [Troubleshooting](https://fx.sh/docs/using-fx/troubleshooting.md#fx-stops-before-running-a-tool). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Agent profiles" description: "Limit what fx or a subagent can use, and set its model and prompt." canonical_url: https://fx.sh/docs/configure-fx/agent-profiles markdown_url: https://fx.sh/docs/configure-fx/agent-profiles.md --- # Agent profiles An agent profile is a saved setup for one agent: the tools and MCP servers it can use, its permission mode, its model and reasoning effort, and instructions of its own. What a profile sets is what the agent gets. What it leaves out comes from the agent that started it. Run fx in a profile, or ask fx to start a [subagent](https://fx.sh/docs/capabilities/subagents.md) in one. This profile describes a reviewer that can read the workspace but can't edit files or run commands: ```json { "description": "Reviews changes without editing files", "tools": ["read_file", "glob_files", "grep_files"], "mcp_servers": [], "effort": "high" } ``` Save it as `~/.fx/agents/reviewer/profile.json`, then ask fx: ```text Have a subagent in the reviewer profile review the parser change. ``` ## Where profiles live Each profile is a folder named after the profile. It holds `profile.json` and, if you want one, `prompt.md`. `profile.json` can be up to 64 KiB and `prompt.md` up to 256 KiB. | Folder | Available in | | --- | --- | | `~/.fx/agents/<name>/` | Every workspace | | `.fx/agents/<name>/` in a repository | That repository | fx looks up a name in `~/.fx/agents` first, then in the repository's `.fx/agents`, then among its [built-in profiles](#built-in-profiles). A profile in your home folder takes precedence over a repository profile with the same name. A repository's profile decides an agent's tools, MCP servers, and prompt the same way yours do. It can give an agent tools its parent doesn't have, and with `"prompt": "replace"` it replaces fx's system prompt, including under a built-in name such as `agent`. Read the `.fx/agents` folder of a repository you clone before you let fx start subagents there, or keep a profile with the same name in `~/.fx/agents`, which fx uses instead. A repository's profile files must stay inside the repository. fx refuses a `profile.json` or `prompt.md` that links to a file outside it, and any profile file that isn't a regular file, such as a link to a terminal, and says which file and why. Your own profiles in `~/.fx/agents` can link anywhere, such as into a dotfiles folder. Profile names use lowercase letters, digits, `-`, and `_`, and are at most 64 characters long. ## profile.json | Key | Value | If you leave it out | | --- | --- | --- | | `description` | What the profile is for. fx shows it to the main agent when it chooses a profile for a subagent. | The profile doesn't load. | | `tools` | The [tools](https://fx.sh/docs/capabilities/tools.md) the agent can use | The tools of the agent that started it | | `mcp_servers` | The [MCP](https://fx.sh/docs/capabilities/mcp.md) servers the agent can use | The servers of the agent that started it | | `permission_mode` | `ask`, `auto`, or `full-access` | The parent's mode | | `model` | A model ID | The model fx would use otherwise | | `effort` | A [reasoning effort](https://fx.sh/docs/configure-fx/models.md#reasoning-effort) | The effort fx would use otherwise | | `prompt` | `append` or `replace`; see [Instructions](#instructions) | `append` | In `tools` and `mcp_servers`, `"*"` stands for every tool or server fx has, and `"!name"` removes one. `["*", "!shell"]` allows every tool except `shell`, and `[]` allows none. fx ignores keys it doesn't know. A value it can't use, such as an unknown effort, stops the profile from loading. ## Instructions Write the agent's instructions in `prompt.md`, next to `profile.json`. With `"prompt": "append"`, fx adds them after its own system prompt. With `"prompt": "replace"`, they take its place. ## Permission mode An agent in a profile that sets `permission_mode` runs in that mode, even when it's looser than its parent's. A profile without one leaves the agent in its parent's mode: the mode you configured for `fx --profile`, or, for a subagent, the current mode of the agent that started it, which the subagent follows as that mode changes. A mode you choose on a [subagent's own screen](https://fx.sh/docs/capabilities/subagents.md#switch-to-a-subagent) takes precedence over both. A repository's profile can't set `permission_mode`. fx ignores the key there, so a repository you clone can't change how its agents' tool calls are approved. To give a profile a mode, keep it in `~/.fx/agents`. See [Permissions](https://fx.sh/docs/configure-fx/permissions.md). ## Use a profile Run the whole session in a profile: ```bash fx --profile reviewer ``` `--profile` works only for interactive sessions; `fx ask` doesn't accept it. If no profile has that name, fx stops and lists the ones it found: ```text fx: no profile named 'reviwer'. Profiles: agent, main, reviewer ``` To run another fx [instance](https://fx.sh/docs/using-fx/instances.md) in a profile next to your current one, use `/launch reviewer`. Resuming a session brings back the profile it ran in, so `fx --resume <session-id>` on a session started with `fx --profile reviewer` runs in `reviewer` again, unless you pass another `--profile`. A model you choose with `--model` or `FX_MODEL`, or an effort you choose with `--effort`, overrides the profile's, both for `fx --profile` and for instances you launch. So does `--provider`: fx starts with that provider's model instead of the profile's. ## Subagents in a profile fx gives the main agent the name and description of every profile. The main agent names one when a task needs it, and otherwise starts the subagent in `main`. Profiles from the repository are marked as the repository's. To choose one yourself, name it in your prompt. A model or reasoning effort you ask for when you start the subagent overrides the profile's. A subagent keeps the profile it started in. fx reads the profile the first time the subagent runs during a session, so an edit applies to subagents that start after it, and to existing ones the next time you start fx. A profile decides the tools and MCP servers it lists, even ones the agent that started the subagent doesn't have. A subagent in the built-in `main` or `agent` profile is a copy of the agent that started it. If a subagent's profile can't be loaded, the subagent can't use any tools. To stop a subagent from starting subagents of its own, leave `subagent` out of its tools, for example with `["*", "!subagent"]`. Subagents nest at most two levels deep, so a subagent's own subagents never get `subagent`, whatever their profile lists. ## Built-in profiles | Name | Description | | --- | --- | | `main` | fx itself, with every tool. fx uses it when you don't pass `--profile`, and for a subagent started without one. | | `agent` | A copy of the agent that starts it. | Neither sets anything, so an agent in either is a copy of the one that started it. `main` always means fx's own profile, and fx ignores a `main` folder in `~/.fx/agents` or a repository. A profile of yours named `agent` replaces the built-in one wherever that name is used. A subagent started without a profile runs in fx's `main`, so no profile of yours changes it. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Project instructions" description: "Give fx the commands and conventions it needs for your project." canonical_url: https://fx.sh/docs/configure-fx/project-instructions markdown_url: https://fx.sh/docs/configure-fx/project-instructions.md --- # Project instructions Create an `AGENTS.md` in your project root with the commands and conventions fx should follow: ```markdown # Project instructions - Run `npm test` after changing application code. - Reuse components from `src/components`. - Regenerate API clients from the schema instead of editing them. ``` ## Instruction sources fx reads `AGENTS.md` from the directory where you start it. For projects under your home directory, it also reads parent directories' `AGENTS.md` files up to, but excluding, your home directory. Use `~/.fx/AGENTS.md`, or `$FX_HOME/AGENTS.md` when you set [`FX_HOME`](https://fx.sh/docs/configure-fx/configuration.md#files-and-precedence), for personal instructions across projects. It can be a link to a file elsewhere in your home directory, such as one in a dotfiles repository. Your prompts take priority over instructions in these files. Any other `AGENTS.md` can be a link only to a file inside its own folder, such as a `CLAUDE.md` beside it. fx skips a link that points anywhere else. <span id="target-scoped-instructions" /> ## Instructions for a subdirectory A nested `AGENTS.md` adds instructions for that part of the project: ```text project/ ├── AGENTS.md ├── apps/ │ └── web/ │ ├── AGENTS.md │ └── src/ └── packages/ ``` When fx works on a file in `apps/web/src/`, it loads `apps/web/AGENTS.md` alongside the root instructions. If they conflict, the instructions closest to the file take precedence. fx adds a folder's instructions the first time a tool call reaches that folder, such as reading, searching, or editing a file there. When a later turn returns to the folder, fx reminds the model that those instructions still apply. fx loads these files only inside the primary workspace. <span id="what-reaches-the-model" /> ## Missing instructions fx shortens or leaves out instructions in these cases: - A file longer than `project_instruction_file_bytes`, 64 KiB by default, is cut at its last complete line within the limit. - When the combined instructions pass `project_instructions_total_bytes`, 128 KiB by default, fx leaves out whole files. It keeps your personal instructions first, then the file closest to the work, then any others that still fit. - When more than 32 folder `AGENTS.md` files apply at once, fx loads the 32 closest to the work. - fx skips a file that is empty, isn't valid UTF-8, or is larger than 64 MiB, and a link that points outside the places [Instruction sources](https://fx.sh/docs/configure-fx/project-instructions.md#instruction-sources) allows. See [context limits](https://fx.sh/docs/configure-fx/context-limits.md) to change the two size limits. <span id="boundaries" /> [Additional directories](https://fx.sh/docs/configure-fx/additional-workspaces.md) give fx access to files, but do not load those directories' `AGENTS.md` files or configuration. ## Disable project instructions To stop loading `AGENTS.md` files automatically, including your personal instructions, set `context` to `false` in the project's `.fx.json`: ```json { "context": false } ``` You can also set it in `~/.fx/settings.json`. See [Configuration](https://fx.sh/docs/configure-fx/configuration.md#files-and-precedence) for how the files combine. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Additional workspaces" description: "Give fx access to additional directories while keeping one primary workspace." canonical_url: https://fx.sh/docs/configure-fx/additional-workspaces markdown_url: https://fx.sh/docs/configure-fx/additional-workspaces.md --- # Additional workspaces Add another directory so fx can work across repositories, such as an app and its shared library. <span id="save-directories-for-a-workspace" /> ## Add a directory From your project directory, run: ```bash fx workspace add ../shared ``` The directory must already exist. fx remembers it for future runs from this project. Inside fx, use `/workspace add ../shared` when fx is idle. <span id="what-an-additional-directory-contributes" /> The project where you start fx remains the primary workspace. Added directories share its [permissions](https://fx.sh/docs/configure-fx/permissions.md); their configuration, `AGENTS.md` files, and skills are not loaded. You can add up to 16 directories. fx stores the list in your [workspace settings](https://fx.sh/docs/configure-fx/configuration.md#workspace-entries). <span id="process-only-directories" /> ## Add a directory for one run ```bash fx --add-dir ../shared ``` Repeat `--add-dir` to add more directories. To start fx without the saved directories for this run: ```bash fx --no-additional-dirs ``` These flags also work before `ask`, `acp`, `pr`, `issue`, and `session resume`, and alongside `--resume` and `--continue`. <span id="remove-directory-access" /> ## List or remove directories | Command | Description | | --- | --- | | `fx workspace list` | Show additional directories and their availability. | | `fx workspace remove ../shared` | Remove a saved directory. | | `fx workspace clear` | Remove all saved directories for this project. | Inside fx, use `/workspace list`, `/workspace remove ../shared`, or `/workspace clear`. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Skills" description: "Discover, load, install, and create reusable agent instructions." canonical_url: https://fx.sh/docs/capabilities/skills markdown_url: https://fx.sh/docs/capabilities/skills.md --- # Skills Skills extend fx with reusable instructions for tasks and workflows. fx can choose a relevant skill for your prompt, or you can select one yourself. ## Browse and invoke Browse available skills: ```bash /skills ``` Search by name or filter by source. Press enter to add a skill to your prompt, then describe what you need. You can also type `$` to open the skill picker. Both match a name by each word and by its letters in order, so `fxcommit` finds `fx-commit`. For a skill named `review-tests`: ```text $review-tests Review the tests changed in this branch. ``` fx loads the selected skill's full instructions when you send the prompt and sends them with that turn. Later turns carry a short note naming the skill, so the model can load it again when it needs to. You can also name a skill at the start of a prompt, as in `Use the review-tests skill to check this branch.` fx doesn't select a skill named inside quotes or code, or one you tell it not to use, as in `don't use $review-tests`. Find a specific skill: ```bash /skills show <name> ``` If several skills have the same name, typing `$name` loads none of them. Select the one you want in `/skills` or the `$` picker, which show each skill's source. ## Install Install one skill from a repository: ```bash /skills install vercel-labs/skills --skill find-skills ``` Install from a local directory: ```bash /skills install ./review-tests ``` A source can also be a Git URL, a `skills.sh` page, `owner/repo@skill`, or an `npx skills add` command. `/skills add` works the same as `/skills install`. Installed skills go to `~/.fx/skills/`. Use `--skill` to choose one from a repository; omit it to install all skills in the source. Installing a skill that's already there replaces it. You can also ask fx to install a skill. fx uses the `install_skill` tool for that request, and for an `npx skills add` command the model runs. The tool needs approval under your [permission rules](https://fx.sh/docs/configure-fx/permissions.md). `/skills path` shows where fx stores installed skills. <span id="create-and-remove" /> ## Create a skill Create a template: ```bash /skills create review-tests ``` Open `~/.fx/skills/review-tests/SKILL.md` in your editor and replace the template with instructions for the task. Running `/skills create` again for the same name replaces that file with a new template. For a skill shared with your project, create `.fx/skills/review-tests/SKILL.md` in the repository instead. For example: ```md --- name: review-tests description: Review tests for missing cases and brittle assertions. --- # Review tests - Read the changed code and its tests. - Find missing cases and assertions tied to incidental output. - Report findings with file paths. Edit files only when asked. ``` fx checks for new and changed skills each time you send a prompt or run `/skills`, so you can use your skill in your next prompt. ### File format Include a `name` in the YAML header. Use `description` to explain when fx should use the skill, and write the instructions below the header. Without a header, fx uses the directory name. A header without a `name` is a discovery issue, and fx doesn't load the skill. ## Remove an installed skill ```bash /skills remove review-tests ``` This removes the skill from `~/.fx/skills/`. Remove workspace or third-party skills at their source. The `/skills` catalog shows each skill's source. ## Discovery roots fx checks `.fx/skills/`, `skills/`, and compatible directories from the workspace upward, stopping before your home directory: ```text .fx/skills/ skills/ .opencode/skills/ .codex/skills/ .claude/skills/ .agents/skills/ .claw/skills/ ``` It then checks user roots: ```text ~/.fx/skills/ ~/.config/opencode/skills/ ~/.codex/skills/ ~/.claude/skills/ ~/.agents/skills/ ~/.claw/skills/ ``` Additional workspace directories do not contribute skills. fx doesn't follow symbolic links in `~/.fx/skills/`. In the other roots, a skill folder can be a symbolic link, and fx loads it when the link resolves inside the folder that holds the root, such as the workspace or your home folder. To allow links to other places, list those directories in `skill_symlink_authorities` in `~/.fx/settings.json`, as up to 32 absolute paths without `..`: ```json { "skill_symlink_authorities": ["/Users/example/shared-skills"] } ``` Skills that fx can't load, such as a link outside these places or a `SKILL.md` it can't read, are listed as discovery issues in [Full detail](https://fx.sh/docs/using-fx/keyboard-shortcuts.md#full-detail), which `ctrl+o` opens. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "MCP" description: "Connect fx to MCP servers, sign in, and use their tools." canonical_url: https://fx.sh/docs/capabilities/mcp markdown_url: https://fx.sh/docs/capabilities/mcp.md --- # MCP MCP connects fx to tools and data from other services. Add a server, then describe what you need in your prompt. fx finds relevant tools as it works. ## Add a remote server Open fx and add the server's name and URL. For example, to connect [Prisma](https://www.prisma.io/docs/ai/tools/mcp-server#fx): ```bash /mcp add prisma https://mcp.prisma.io/mcp ``` fx saves the server in `~/.fx/mcp.json` and starts it. A URL means a remote server, so there is no transport to choose. If the server asks you to sign in, fx opens your browser right away, as in the [sign-in steps](#sign-in-to-a-remote-server) below. To add a server without signing in, put `--no-login` before its name. ## Connect Slack Add Slack. fx knows Slack's server address, so you don't need to give one, and it opens your browser to sign in once the server asks for a login: ```bash /mcp add slack ``` To sign in again later, run `/mcp login slack`. fx signs in with its own Slack app. Approve access in your browser, then return to fx. Your browser comes back to fx at `http://localhost:3118/callback`, the one address fx's Slack app allows, so port 3118 must be free while you sign in. To use your own Slack app instead, set its client ID in the [OAuth options](https://fx.sh/docs/capabilities/mcp/protocol.md#oauth-configuration). ## Add a local stdio server Local servers run as a process on your machine. Put the command and its arguments after `--`. For example, with Node.js and npm installed, you can try the [MCP Everything test server](https://github.com/modelcontextprotocol/servers/tree/main/src/everything): ```bash /mcp add local-tools -- npx -y @modelcontextprotocol/server-everything ``` Everything after `--` is passed to the command as written. To set environment variables, add `--env KEY=VALUE` before the name. For other options, see [stdio configuration](https://fx.sh/docs/capabilities/mcp/protocol.md#stdio-configuration-details). ## Sign in to a remote server ### Browser sign-in fx starts this sign-in when you add a server that asks for one. To sign in later, or again, run: ```bash /mcp login prisma ``` Replace `prisma` with the name you used when adding the server. fx opens your browser. If it didn't open, select **Open the sign-in page** in the transcript or on the server's screen in `/mcp`. Approve access, and fx finishes signing in while you keep working. fx saves the login and renews it when needed. On a machine without a browser, such as over SSH, run `fx mcp login --no-browser prisma`. fx prints the address to open on any device, and you paste back the address your browser ends up on. Use `/mcp logout <name>` to sign out. fx also revokes the login when the server supports it. Servers that need a client ID or a fixed callback port have additional [OAuth options](https://fx.sh/docs/capabilities/mcp/protocol.md#oauth-configuration). ### API tokens For a server that accepts a bearer token, add `bearer_token_env` to its entry in `~/.fx/mcp.json`: ```json { "mcpServers": { "protected": { "type": "http", "url": "https://mcp.example.com/mcp", "bearer_token_env": "MCP_TOKEN" } } } ``` Replace the URL with your server's endpoint. Set `MCP_TOKEN` to the token issued by that service, then start fx from the same terminal: ```sh export MCP_TOKEN="your-token" fx ``` For servers that require custom headers, see [HTTP authentication fields](https://fx.sh/docs/capabilities/mcp/protocol.md#http-authentication-fields). ## Manage servers ```bash /mcp ``` Select a server to see its status and tools, and type to filter them. Its actions, such as **Log in**, **Approve**, or **Remove**, are listed with the command each one runs. Press Esc to go back, or Ctrl+C to close the menu. Servers start in the background when fx opens, so their tools are ready when you need them. While they work, the status line says nothing about them. It names a server that needs you, such as `linear needs login · /mcp`. If a server stops working, fx restarts it on its own, waiting longer between tries. After 8 tries in a row it gives up, and the status line shows `linear failed · /mcp`. A server that stays up for a minute starts its count over. | Command | Description | | --- | --- | | `/mcp list` | List servers with the file that defines each one and its status. | | `/mcp show <name>` | Connect to a server and list its tools. | | `/mcp remove <name>` | Remove a server and its saved login. | In a terminal, `fx mcp list --json` prints your servers as JSON for scripts. A usage mistake, such as an unknown flag, prints `{"kind": "mcp_list", "error": ..., "code": ...}` instead and exits 2. See the [MCP command reference](https://fx.sh/docs/using-fx/slash-commands.md#interactive-mcp-commands) for all commands, or [CLI commands](https://fx.sh/docs/using-fx/cli.md#mcp-management) to manage servers from your terminal. ## Servers with fx setup guides These providers maintain setup instructions for connecting their servers to fx: | Server | Guide | | --- | --- | | AWS | [Getting Started with fx](https://github.com/awslabs/mcp#getting-started-with-fx) | | Brave Search | [Usage with fx](https://github.com/brave/brave-search-mcp-server#usage-with-fx) | | Cal.com | [Cal.com MCP server](https://cal.com/docs/mcp-server) | | Clerk | [Use Clerk's MCP server](https://clerk.com/docs/guides/ai/mcp/clerk-mcp-server#connecting-fx-to-clerks-mcp-server) | | Exa | [fx by Vercel Labs](https://exa.ai/docs/integrations/fx) | | Hugging Face | [MCP Server Settings](https://huggingface.co/mcp) | | Kernel | [fx MCP client setup](https://www.kernel.sh/docs/reference/mcp-server/clients/fx) | | Knock | [Knock MCP server](https://docs.knock.app/ai/mcp-server#fx) | | MongoDB | [Get started with the MongoDB MCP Server](https://www.mongodb.com/docs/mcp-server/get-started/?ai-client=fx) | | Neon | [Connect MCP clients to Neon](https://neon.com/docs/ai/connect-mcp-clients-to-neon) | | Notion | [Connect to Notion MCP](https://developers.notion.com/guides/mcp/get-started-with-mcp#fx) | | Plain | [Plain MCP server](https://www.plain.com/docs/agents/mcp-server#fx) | | Prisma | [Prisma MCP server](https://www.prisma.io/docs/ai/tools/mcp-server#fx) | | Resend | [Resend MCP server](https://resend.com/docs/mcp-server) | | Sentry | [Sentry MCP](https://mcp.sentry.dev/?ide=fx) | | Stagehand | [fx integration](https://docs.stagehand.dev/v4/integrations/fx) | | Supabase | [Supabase MCP server](https://supabase.com/docs/guides/ai-tools/mcp) | | Upstash | [Install by agent](https://upstash.com/docs/agent-resources/clients#fx) | ## Profile configuration Servers added with `/mcp add` are saved in `~/.fx/mcp.json` and available across projects. A name that's already in the file is refused, so remove the old entry first. Edit this file to set headers and environment variables, or to turn a server off with `"enabled": false`. Changes made with `/mcp` apply right away. A running fx loads changes made any other way, such as your own edit or `fx mcp add` in another terminal, when you send your next prompt or run a `/mcp` command. See the [profile reference](https://fx.sh/docs/capabilities/mcp/protocol.md#profile-fields) for available options. ## Project configuration and trust To share server configuration with your project, create `.mcp.json` in its root, or run `/mcp add --project`. Define servers under `mcpServers`: ```json { "mcpServers": { "prisma": { "type": "http", "url": "https://mcp.prisma.io/mcp" } } } ``` fx doesn't start a project server until you approve it, and the status line names the servers waiting. To approve one: ```bash /mcp approve prisma ``` fx shows exactly what you're trusting: the command it will run, or the URL it will connect to. Approvals are saved per workspace. A project server you sign in to keeps its login for that project only: it never uses a login from another project or from your own servers. Use `/mcp approve --all` to approve every server in the project, or `/mcp reject <name>` to keep one from starting. For `fx ask`, approve the server first with `fx mcp approve prisma`. A server added with `/mcp add --project` waits for approval too, so fx doesn't sign in to it when you add it. If it needs a login, run `/mcp login <name>` after you approve it. If your profile and project define the same name, the profile entry takes precedence. Project configuration also supports environment variables; see [project configuration details](https://fx.sh/docs/capabilities/mcp/protocol.md#project-configuration-limits). ## How tools reach the model fx discovers and loads relevant tool definitions as needed. MCP calls follow your [permission mode and rules](https://fx.sh/docs/configure-fx/permissions.md). Each MCP tool gets a name of the form `mcp_<server>_<tool>`, such as `mcp_linear_list_issues`. Use this name in permission rules and with `fx mcp call`. Characters other than letters, digits, `_`, and `-` become `_`, names are cut to 64 characters, and a name that would repeat another gets a suffix such as `_2`. See the [protocol reference](https://fx.sh/docs/capabilities/mcp/protocol.md#discovery-and-isolation) for discovery and context limits, or [Troubleshooting](https://fx.sh/docs/using-fx/troubleshooting.md#an-mcp-server-is-missing) if a server does not appear. ## Large results in shell commands When a tool's result is large, such as a long list of Linear issues, a command can run the tool and save the result to a file instead of sending it to the model: ```sh fx mcp call mcp_linear_list_issues '{"team":"ENG"}' > issues.json jq '[.issues[] | select(.state == "open")] | length' issues.json ``` Only what the command prints reaches the model. fx tells the model to use `fx mcp call` for large or filtered results. `fx mcp call` takes the tool's full name, as `capability_search` returns it, and its arguments as one JSON object, or `-` to read them from standard input. It prints the tool's structured content as JSON when the tool returns some, and its text otherwise. Structured content that is only a `result` string, as some servers wrap a tool's text, prints as that text. When standard output goes to a file or a pipe, `fx mcp call` also prints one line on standard error with the result's size and shape: its field names, the length of each list, and the values of short text fields that repeat, such as a status. The model sees that line, so it can filter the file without reading it first. Unique values, such as titles and IDs, never appear in it. ```text fx mcp call: wrote 18342 bytes of JSON: {issues: [120 × {id, title, statusType: "started"|"completed"}], hasNextPage: boolean} ``` A command can also look up tools. `list` prints every tool of a server, and `search` the tools that best match a query, one per line: the name, a tab, and a description. `help` prints a tool's description and the arguments it takes, with `?` after an optional one. ```sh fx mcp call list linear fx mcp call search open issues fx mcp call help mcp_linear_list_issues ``` These need no permission, like the model's own tool search, and they show only the tools the agent may use. - It works only in a command that fx's shell tool runs, not in an interactive terminal, and only while that command's shell call runs. From your own terminal it exits `3`. - Each call meets the same permission rules, prompt, and automatic review as a direct call of the tool, with the access of the agent or subagent that ran the command. When a call needs your approval, the command waits for your answer. - In the terminal UI, each call shows as its own tool row beside the command, the row a direct call of the tool gets. - A result can be up to 16 MiB, or 8 MiB when the tool returns text. - It's available on macOS and Linux. | Exit code | Meaning | | --- | --- | | `0` | The tool ran, and standard output has its data. | | `1` | The call failed, or the connection to fx was lost. | | `2` | A usage mistake, such as arguments that aren't a JSON object. | | `3` | No running fx shell call to reach, or the session runs a different fx version. | | `4` | Too many calls are running. Nothing ran. | | `5` | Permission wasn't granted. Nothing ran. | | `6` | The tool returned an error, printed on standard error. | --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "CLI commands" description: "Reference for top-level fx commands and global flags." canonical_url: https://fx.sh/docs/using-fx/cli markdown_url: https://fx.sh/docs/using-fx/cli.md --- # CLI commands Run `fx` to start an interactive session, or `fx "<prompt>"` to start one with a first prompt. Use `fx <command> --help` for command options, or see [Slash commands](https://fx.sh/docs/using-fx/slash-commands.md) for commands inside fx. Add `--json` after the command for machine-readable output with `ask`, `status`, `doctor`, `permissions`, `models`, `workspace`, `config`, `session`, `sessions`, `usage`, `credits`, `upgrade`, `slack`, `mcp list`, and `mcp show`. ## Run fx | Command | Description | | --- | --- | | `fx` | Start a fresh interactive session. | | `fx "<prompt>"` | Start an interactive session and send the prompt as the first message. Quote the prompt so the shell passes it as one argument. | | `fx ask <prompt>` | Run one noninteractive request. See [`fx ask`](https://fx.sh/docs/using-fx/fx-ask.md). | | `fx pr [context]` | Draft a pull request; add `--create` to publish with `gh`. | | `fx issue [context]` | Draft an issue; add `--create` to publish with `gh`. | | `fx acp` | Start an ACP server over stdio. See [ACP server](https://fx.sh/docs/using-fx/acp.md). | `fx pr` requires a Git repository. Use `--create` to publish through an authenticated GitHub CLI (`gh`), or omit it to print the draft. Both commands take the same model and permission flags as `fx ask`, such as `fx pr --model <id> --auto`. A flag they don't take is an error, so context that starts with a dash goes after `--`. ## Sessions and local records | Command | Description | | --- | --- | | `fx sessions` | List sessions in this workspace. Add `--all` for every workspace. | | `fx sessions convert` | Convert every session saved by an earlier fx version. Add `--json` for the conversion report; see [Sessions from earlier versions](https://fx.sh/docs/using-fx/sessions.md#sessions-from-earlier-versions). | | `fx session <last\|id>` | Inspect one session. `--id <id>` forces an exact ID. | | `fx session recover <id>` | Copy a recoverable corrupt session without changing the source. | | `fx usage [--period <today\|7d\|month>]` | Show your provider's usage and spend. Add `--json` for structured output. | Use `--limit <1-100>` and `--cursor <cursor>` to paginate `fx sessions`. | Command | Description | | --- | --- | | `fx -c` | Continue the conversation remembered for this workspace. | | `fx -r` | Choose a saved conversation. | | `fx -r last` / `fx -r <id>` | Resume the latest workspace session or a session by ID. | | `fx session resume [last\|<id>]` | Resume the latest workspace session or a session by ID. | Add a quoted prompt to send it as the first message after resuming: `fx -c "<prompt>"` or `fx -r <id> "<prompt>"`. See [Sessions](https://fx.sh/docs/using-fx/sessions.md) for resuming and recovery. ## Account and configuration | Command | Description | | --- | --- | | `fx login [vercel\|codex\|grok]` | Connect the named account. Omitting the argument selects Vercel. | | `fx login vercel --api-key` | Save an AI Gateway API key instead of signing in through the browser. Replaces `fx setup`, which works with a warning until fx 0.0.18. | | `fx logout [vercel\|codex\|grok]` | Sign out of the named account. Omitting the argument selects Vercel. | | `fx provider <name>` | Choose a built-in provider or configured model connection. | | `fx teams` | Choose the Vercel team used by AI Gateway. | | `fx credits` / `fx balance` | Show the AI Gateway credit balance. | | `fx models` | List the models of the active provider. | | `fx permissions` | Show the permission mode and rules. | | `fx config [list\|get <key>]` | Show the values set in the settings files. Add `--show-origin` to see where each one is set, `--global` or `--workspace` to read only the profile's global settings or this workspace's entry, or `--json` for scripts. | | `fx config schema [--project]` | Print the JSON Schema for `~/.fx/settings.json`, or with `--project` for `.fx.json`. See [Check settings in your editor](https://fx.sh/docs/configure-fx/configuration.md#check-settings-in-your-editor). | | `fx config set <key> <value>` / `fx config unset <key>` | Save or remove a preference in `~/.fx/settings.json`, such as `fx config set fast_mode on`. | | `fx workspace [list\|add PATH\|remove PATH\|clear]` | Manage additional workspace directories. | | `fx slack <install\|status\|refresh>` | Manage the workspace Slack bot's credentials on this computer. `install` authorizes the bot through fx.sh and saves its credentials in `~/.fx/slack/installation.json`, `status` shows the saved installation, and `refresh` renews its tokens without the browser. This is separate from Slack's MCP server, which `fx mcp add slack` sets up. | Selecting Codex, Grok, or Gateway with `fx provider` can start sign-in when credentials are missing. See [Authentication](https://fx.sh/docs/getting-started/authentication.md). ## MCP management Manage MCP servers from your terminal without starting a model request: | Command | Description | | --- | --- | | `fx mcp add <name> <url>` | Save a remote server in your profile. If it asks for a login, fx opens your browser and waits for the sign-in; without a browser, it prints the `fx mcp login` command to run. Add `--no-login` to save the server without contacting it. | | `fx mcp add <name> -- <command> [args...]` | Save a local server in your profile. | | `fx mcp add slack` | Save Slack's server in your profile and sign in to it. | | `fx mcp list` | List servers, the file that defines each one, and their status, without connecting. | | `fx mcp show <name>` | Connect to a server and show its status, version, and tools. | | `fx mcp login <name>` | Sign in to a remote server through your browser. | | `fx mcp login --no-browser <name>` | Print the sign-in address and take the returned address pasted back. | | `fx mcp logout <name>` | Sign out, revoking the login where the server supports it. | | `fx mcp remove <name>` | Remove a server and its saved login. | | `fx mcp approve <name>` | Approve a project server for the current workspace. | | `fx mcp approve --all` | Approve every server now in the current workspace's `.mcp.json`. A server added later still waits for approval. | | `fx mcp reject <name>` | Reject a project server for the current workspace. | | `fx mcp call <tool> [<json>]` | Run an MCP tool from a command fx's shell tool runs, and print only its data. Pass `-` instead of `<json>` to read the arguments from standard input. | | `fx mcp call list <server>` | From such a command, list a server's MCP tools, one per line. | | `fx mcp call search <query>` | From such a command, list the MCP tools that best match a query. | | `fx mcp call help <tool>` | From such a command, print an MCP tool's description and arguments. | `add` takes `--header KEY=VALUE` for a remote server and `--env KEY=VALUE` for a local one; repeat either flag for more values. Add `--project` to `add` or `remove` to use the project's `.mcp.json`, and `--json` to `list` or `show` for machine-readable output; with `--json`, a usage mistake is reported as JSON too. `add` and `remove` don't change a config file that's a link; they name what it points to, so you can edit that file instead. Commands exit `0` on success, `1` on failure, and `2` for a usage mistake; `show` exits `1` when the server isn't ready. `call` has more exit codes; see [Large results in shell commands](https://fx.sh/docs/capabilities/mcp.md#large-results-in-shell-commands). See [MCP](https://fx.sh/docs/capabilities/mcp.md) for setup, authentication, and project configuration. ## Diagnostics and maintenance | Command | Description | | --- | --- | | `fx status` | Show configuration and runtime information. | | `fx doctor` | Run local health and preflight checks. | | `fx upgrade [--channel <stable\|dev>]` | Upgrade fx and optionally remember a release channel. `fx update` is an alias. | | `fx completion bash\|zsh\|fish` | Print a shell completion script. See [Shell completion](#shell-completion). | | `fx help` | Show top-level help. `-h` and `--help` are aliases. | <span id="global-flags" /> ## Launch options ### Model and routing These options apply when starting or resuming an interactive session. Put them before or after a first prompt, as in `fx --model <id> "<prompt>"`, and before or after `-c`, `-r`, or `fx session resume` and the session they resume, as in `fx -c --model <id>` or `fx -r <id> --fast`. | Flag | Description | | --- | --- | | `--provider <name>` | Choose a built-in provider or configured connection. | | `--model <id>` | Choose a model. | | `--effort <level>` | Set reasoning effort. | | `--fast` / `--no-fast` | Enable or disable fast mode. | | `--ultrafast` / `--no-ultrafast` | Request or disable the higher-priced [Ultrafast tier](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode) for an eligible AI Gateway model. Process-only; also supported after `ask` or `acp`. | | `--provider-order <a,b>` | Prefer these AI Gateway providers in order. | | `--provider-strict` / `--no-provider-strict` | Restrict routing to that list or allow fallback. | | `--permission-mode <ask\|auto\|full-access>` | Set the permission mode for this session without saving it. | | `--ask` / `--auto` / `--full-access` | Shortcuts for each permission mode. `--yolo` means `--full-access`. | `fx ask`, `fx pr`, `fx issue`, and `fx acp` take the same options after the command, such as `fx ask --model <id> "your prompt"`. `fx acp` leaves out the two provider-routing flags. See [`fx ask`](https://fx.sh/docs/using-fx/fx-ask.md) for its options, including `--auto` and `--full-access`. Placed on the wrong side of a command, these flags fail with a message that says where they go: ```sh $ fx --model <id> ask "your prompt" fx: put agent-run flags after the command, as in fx ask --model <id> ``` ### Agents and instances These options apply to interactive sessions, including resumed ones, and go in the same places as the model and routing flags, as in `fx -c --profile <name>`. Before `ask`, `pr`, `issue`, or `acp`, they're an error. | Flag | Description | | --- | --- | | `--profile <name>` | Run the session in an [agent profile](https://fx.sh/docs/configure-fx/agent-profiles.md). | | `--instances <n>` | Start `n` [instances](https://fx.sh/docs/using-fx/instances.md), each with its own conversation. | ### Workspace and context Place these flags before the command. When you start or resume an interactive session, they go in the same places as the model and routing flags: | Flag | Description | | --- | --- | | `--add-dir <path>` | Add a directory for this run. Repeat for more directories. | | `--no-additional-dirs` | Ignore saved additional directories for this run. | | `--context-limit <name=bytes\|off>` | Override a context limit. Repeat for more limits. | Directory flags work with interactive sessions, `ask`, `pr`, `issue`, and `acp`. See [Additional workspaces](https://fx.sh/docs/configure-fx/additional-workspaces.md) and [Context limits](https://fx.sh/docs/configure-fx/context-limits.md). ### Session and help aliases `--continue` is equivalent to `-c`, and `-r` is short for `--resume`. With no value, `-r` or `--resume` opens the session picker; `last` resumes the latest workspace session, and an ID resumes that session. `--resume=<id>` also works. The older spellings `--resume-last`, `--resume-<id>`, and `fx resume` were removed. Use `fx --resume last`, `fx --resume <id>`, or `fx session resume [last|<id>]` instead; each old spelling's error names its replacement. Use `-h` or `--help` for help, and `-v` or `--version` for the installed version. ## Flags and errors Flags accept `--flag value` or `--flag=value`. When a flag repeats or conflicts with another, the last one wins, so `fx --fast --no-fast` runs with Fast mode off. When fx can't use the command line, it exits with status 2 and says what's wrong: - A typo gets the closest match: `fx stauts` suggests `status`, and `fx --modle` suggests `--model`. - Several unquoted words, such as `fx fix the login bug`, ask you to quote the prompt. - `fx -p` and `fx --print` point to `fx ask` for a one-shot request. Other failures exit with status 1. ## Shell completion `fx completion <shell>` prints a completion script for bash, zsh, or fish. Tab then completes commands, subcommands, flags, setting keys after `fx config get`, `set`, and `unset`, and fixed values such as `--permission-mode ask|auto|full-access`. The script comes from the fx that prints it, so it matches the installed version, and it never runs fx while you type. To load it in every new shell, add one line to your shell's startup file: | Shell | File | Line | | --- | --- | --- | | bash | `~/.bashrc` | `eval "$(fx completion bash)"` | | zsh | `~/.zshrc`, after `compinit` | `source <(fx completion zsh)` | | fish | `~/.config/fish/config.fish` | `fx completion fish \| source` | ## Environment overrides See [Configuration](https://fx.sh/docs/configure-fx/configuration.md#environment-variables) for `FX_PROVIDER`, `FX_MODEL`, `FX_PERMISSION_MODE`, and other environment variables. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Slash commands" description: "Reference for commands inside the interactive shell." canonical_url: https://fx.sh/docs/using-fx/slash-commands markdown_url: https://fx.sh/docs/using-fx/slash-commands.md --- # Slash commands Type `/` in fx to browse commands. For commands you run from your terminal, see [CLI commands](https://fx.sh/docs/using-fx/cli.md). Type after the `/` to filter the menu. It matches a command or alias in any letter case, by each word, and by its letters in order, so `/mdl` finds `/model`. Exact names come first, then names that start with what you typed, then other matches. After a command and a space, the menu suggests its arguments where it knows them, such as `auto` after `/permissions` or a server name after `/mcp show`. In `/help`, typing also matches each command's description and category. ## Sessions and shell | Command | Description | | --- | --- | | `/help` | Show interactive help. | | `/clear` / `/new` | Start a fresh conversation and keep background processes running. | | `/reset` | Start a fresh conversation and stop workspace background processes. | | `/resume` | Open the saved-session picker. | | `/fork` | Start a new conversation from before a chosen prompt, with that prompt in the composer to edit. See [Fork a conversation](https://fx.sh/docs/using-fx/sessions.md#fork-a-conversation). | | `/rename <title>` | Rename the current conversation. | | `/launch [profile]` | Start another fx [instance](https://fx.sh/docs/using-fx/instances.md), optionally in an [agent profile](https://fx.sh/docs/configure-fx/agent-profiles.md), and show it. | | `/close` | Close the instance on screen. Closing the last one exits fx. | | `/agents` | List the open agents and switch to one. | | `/compact` | Summarize older conversation context. | | `/shell reload` | Reload shell startup configuration and clear remembered command approvals. | | `/quit` | Exit fx. `/exit` is an alias. | See [Sessions](https://fx.sh/docs/using-fx/sessions.md) for saving, recovery, and compaction. ## Account, model, and runtime | Command | Description | | --- | --- | | `/provider` | Choose a provider and how to connect to it. `/setup` still opens it with a warning until fx 0.0.18. | | `/login` | Open the provider picker to sign in. | | `/logout [vercel\|codex\|grok]` | Sign out of the active or named provider. | | `/model [id-or-query]` | Choose a model and reasoning effort, or pass a model ID or search term. | | `/effort [level]` | Choose the reasoning effort for the current model, or pass a level such as `high`. | | `/fast [on\|off]` | Toggle Fast mode, or turn it on or off. Turning it on needs a model that supports it. | | `/ultrafast [on\|off\|status]` | Enable, disable, or inspect the higher-priced [Ultrafast request](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode). With no argument, show status without changing it. | | `/permissions [ask\|auto\|full-access\|reset]` | Show the permission mode, rules, and session grants in a panel, or change the mode. `reset` switches back to `ask` and clears the session grants. | | `/allowlist` | Inspect or change [persistent permission rules](#persistent-permission-rules). | Use `/permissions full-access` to disable fx permission checks. `/permissions full access` and the legacy `/permissions yolo` are also accepted. See [Permissions](https://fx.sh/docs/configure-fx/permissions.md) for permission rules and modes. ### Saved permission rules Save an exact allow or deny rule for the current saved conversation, or remove one by ID: ```text /permissions remember allow|deny <tool> <arguments-json> /permissions revoke <rule-id> ``` Both commands ask for confirmation. The `/permissions` panel lists saved rules and their IDs. See [Saved conversation rules](https://fx.sh/docs/configure-fx/permissions.md#rules-saved-with-a-conversation) for an example. ### Persistent permission rules `/allowlist` alone lists the allow rules in effect from `~/.fx/settings.json`. These forms view or change them: ```text /allowlist view [effective|workspace|global] /allowlist [workspace|global] add command|tool|url|web-fetch-domain <pattern> /allowlist [workspace|global] remove command|tool|url|web-fetch-domain <pattern> /allowlist [workspace|global] reset commands|tools|urls|web-fetch-domains|all ``` `add` saves an allow rule. Changes apply to the current workspace unless you name `global`. Quote a pattern that contains spaces, as in `/allowlist global add command "git status"`. The older scope words `local` and `user` still work with a warning until fx 0.0.18. See [Persistent rules](https://fx.sh/docs/configure-fx/permissions.md#persistent-rules) for how rules match. ## Inspection and settings | Command | Description | | --- | --- | | `/status` | Show the session ID, model, workspace, and permissions in a panel. | | `/stats` | Show terminal rendering counters for this fx process: bytes of terminal output, redraws, debounced resizes, footer updates, and stream chunks. For usage and spend, use `/usage`. | | `/usage` | Show your provider's usage and spend: AI Gateway reports, or your Codex or Grok plan usage. | | `/credits` | Show the AI Gateway credit balance. `/balance` is an alias. | | `/settings [startup-scrollback [on\|off]]` | Open settings. With `startup-scrollback`, turn the `startup_scrollback` setting on or off, or toggle it. | | `/statusline [context\|session\|workspace]` | Choose which fields appear in the footer, or toggle the one you name. | | `/sound [on\|off\|max]` | Turn sounds and terminal bells on or off, or toggle them with no argument. `max` adds interaction sounds. | | `/version` | Show the installed version. | ## Tools and local data | Command | Description | | --- | --- | | `/image <path>` | Attach an image. `/img` is an alias. | | `/images [clear]` | List pending images, or remove them with `clear`. | | `/paste` | Attach a clipboard image when supported. | | `/mcp [command]` | Connect and manage [MCP](https://fx.sh/docs/capabilities/mcp.md) servers. See [Interactive MCP commands](#interactive-mcp-commands). | | `/skills [command]` | Browse and manage [skills](https://fx.sh/docs/capabilities/skills.md) with `show`, `install`, `create`, `remove`, and `path`. `add` is an alias of `install`. | | `/workspace [list\|add <path>\|remove <path>\|clear]` | Manage saved additional directories. With no argument, open them in a list. | | `/undo` | Undo the most recent tracked file operation. | | `/copy` | Copy the latest assistant response. | | `/feedback` | Open the fx feedback form. | | `/trace` | Create and copy a private diagnostic trace. | See [Additional workspaces](https://fx.sh/docs/configure-fx/additional-workspaces.md) for directory access and [Share feedback](https://fx.sh/docs/using-fx/share-feedback.md) for diagnostics. ### Undo tracked file changes Repeat `/undo` to undo earlier changes made by fx’s file tools. Shell commands and edits made outside those tools are not tracked. ## Interactive MCP commands Use these inside fx. They take the same arguments as [`fx mcp`](https://fx.sh/docs/using-fx/cli.md#mcp-management) and print the same text. For setup and examples, see [MCP](https://fx.sh/docs/capabilities/mcp.md). ```text /mcp /mcp list /mcp show <name> /mcp add [--global | --project] [--no-login] [--header KEY=VALUE]... <name> <url> /mcp add [--global | --project] [--env KEY=VALUE]... <name> -- <command> [args...] /mcp add [--global | --project] [--no-login] slack /mcp remove [--global | --project] <name> /mcp login [--no-browser] <name> /mcp logout <name> /mcp approve <name> /mcp approve --all /mcp reject <name> ``` `fx mcp call` has no `/mcp` form, because it runs only in a command that fx's shell tool runs. `/mcp` alone opens the server menu; see [Keyboard shortcuts](https://fx.sh/docs/using-fx/keyboard-shortcuts.md#mcp) for its keys. `/mcp add` signs in to a remote server that needs a login unless you pass `--no-login`. `/mcp login` signs in while you keep working and says when it's done. `--project` writes or removes the entry in the project's `.mcp.json` instead of `~/.fx/mcp.json`; when both files define a name, `remove` asks for `--global` or `--project`. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Keyboard shortcuts" description: "Reference for keyboard shortcuts in the interactive shell." canonical_url: https://fx.sh/docs/using-fx/keyboard-shortcuts markdown_url: https://fx.sh/docs/using-fx/keyboard-shortcuts.md --- # Keyboard shortcuts Press these keys in the interactive shell that `fx` opens. For commands that start with `/`, see [Slash commands](https://fx.sh/docs/using-fx/slash-commands.md). On Linux, press `alt` wherever this page says `option`. Shortcuts with `cmd` work only in terminals that pass `cmd` key presses to fx, and many terminals keep some of them, such as `cmd+c`, for their own copy and paste. ## Control fx | Shortcut | Action | | --- | --- | | `escape` twice | Interrupt fx while it works or retries. File changes and commands that already ran stay in place. The footer shows `esc again to interrupt` after the first press. | | `ctrl+c` | Clear your draft. With an empty draft, stop what fx is doing. | | `ctrl+c` twice | Exit fx. The footer shows `press ctrl+c again to exit` for 3 seconds after the first press. | | `ctrl+d` | Exit fx when your draft is empty and fx isn't working. Otherwise, delete the character after the cursor. | | `ctrl+z` | Suspend fx and return to your shell. Run `fg` to resume it. | | `ctrl+o` | Open or close [Full detail](#full-detail). | | `ctrl+x` | When another agent is open, open the [agent list](https://fx.sh/docs/using-fx/instances.md#switch-between-instances) to switch to a [subagent](https://fx.sh/docs/capabilities/subagents.md#switch-to-a-subagent) or another [instance](https://fx.sh/docs/using-fx/instances.md), even with a draft. Press it again to go back. | | `ctrl+p` | Open the model picker without losing your draft. Press `ctrl+p` again to close it. | | `shift+tab` | Cycle the [permission mode](https://fx.sh/docs/configure-fx/permissions.md) through ask, auto, and full access. | | `cmd+r` | Open saved sessions from every workspace. Send or clear your draft first. | | `ctrl+g` | Reload fx when the footer shows `update ready: ctrl+g to reload`. | | `ctrl+l` | Redraw the screen. | | `escape` | End a request that is waiting for you, such as at `Out of credits` or `This request crashed fx twice`. | | `enter` | Send a request again when fx asks first, such as at `This request crashed fx twice` or `Interrupted more than a day ago`. | ## Write a prompt | Shortcut | Action | | --- | --- | | `enter` | Send your prompt. While fx works, the prompt [steers](https://fx.sh/docs/using-fx/working-with-fx.md#steering) the current task. | | `shift+enter`, `option+enter`, or `ctrl+j` | Insert a newline. | | `\`, then `enter` | Replace the backslash with a newline. This works in every terminal. | | `@` | Choose a file or folder to include. On a folder, `tab` opens it to list its contents, and `enter` includes the folder itself. | | `/` | Browse slash commands. | | `$` | Choose a [skill](https://fx.sh/docs/capabilities/skills.md). | | `tab` | Complete the highlighted file, command, model, or reasoning effort. | | `up` or `down` | Move between lines. On the first or last line, move to the start or end of the draft, then browse your earlier prompts. | | `up` with nothing typed | While a steering prompt waits for a running tool or compaction, bring it back to edit before fx applies it. | | `down` with nothing typed | When another agent is open, open the [agent list](https://fx.sh/docs/using-fx/instances.md#switch-between-instances). | | `ctrl+n` | Show the next prompt in your history. | | `ctrl+v` | Attach a clipboard image, like `/paste`. | | `escape` twice | Clear your draft while fx is idle. The footer shows `esc again to clear` after the first press. | ### Move the cursor | Shortcut | Action | | --- | --- | | `left` or `right`, `ctrl+b` or `ctrl+f` | Move one character. | | `option+left` or `option+right`, `ctrl+left` or `ctrl+right`, `option+b` or `option+f` | Move one word. | | `home` or `end`, `ctrl+a` or `ctrl+e`, `cmd+left` or `cmd+right` | Move to the start or end of the line. | | `option+up` or `option+down` | Move to the previous or next paragraph. A blank line separates paragraphs. | | `ctrl+home` or `ctrl+end`, `cmd+up` or `cmd+down` | Move to the start or end of the draft. | | `page up` or `page down` | Move through a long draft one page at a time. | ### Select and undo | Shortcut | Action | | --- | --- | | `shift` with a movement key | Select text, for example with `shift+left` or `shift+option+right`. Typing replaces the selection. | | `cmd+a` | Select the whole draft. | | `cmd+c` | Copy the selection. | | `cmd+x` | Cut the selection. | | `cmd+z` or `ctrl+_` | Undo. | | `cmd+shift+z` | Redo. | ### Delete text On a Mac keyboard, `backspace` is the `delete` key and `forward delete` is `fn+delete`. | Shortcut | Action | | --- | --- | | `backspace` or `ctrl+h` | Delete the character before the cursor. | | `forward delete` or `ctrl+d` | Delete the character after the cursor. | | `option+backspace` or `ctrl+backspace` | Delete the word before the cursor. A terminal that doesn't report `ctrl+backspace` as its own key deletes one character instead. | | `ctrl+w` | Delete back to the previous space. | | `option+d`, `option+forward delete`, or `ctrl+forward delete` | Delete the word after the cursor. | | `ctrl+u` or `cmd+backspace` | Delete to the start of the line. At the start of a line, join it to the line above. | | `ctrl+k` or `cmd+forward delete` | Delete to the end of the line. | | `ctrl+y` | Paste the text you last deleted with `ctrl+w`, `ctrl+u`, or `ctrl+k`. | ## Menus and pickers These keys work in lists such as `/model`, `/resume`, `/help`, and `/settings`, and in the suggestions that appear when you type `/`, `@`, or `$`. | Shortcut | Action | | --- | --- | | `up` or `ctrl+k` | Move up. | | `down` or `ctrl+j` | Move down. | | `enter` | Choose the highlighted item. | | typing | Filter a list that shows `type to filter`. | | `tab` or `shift+tab` | Switch the category in `/help` and `/settings`, the provider in `/model`, or the source in `/skills`. In `/resume`, switch between the current workspace and all workspaces. | | `left` or `right` | Change the highlighted value in `/settings` and `/statusline`. | | `escape` | Close the list. | ### `/usage` | Shortcut | Action | | --- | --- | | `tab`, `shift+tab`, `left`, or `right` | Change the period. | | `up` or `down` | Select a model. | | `enter` | Show details for the selected model. | | `r` | Refresh. | | `escape` | Close, or return from model details. | ### `/mcp` | Shortcut | Action | | --- | --- | | typing | Filter the servers, or on a server's screen, its tools. | | `up` or `down` | Move through the servers, or through a server's actions and tools. | | `enter` or `right` | Open the highlighted server, or run the highlighted action, such as **Log in**, **Log out**, **Approve**, **Reject**, or **Remove**. | | `left` | Go back a screen. | | `escape` | Go back a screen, or close the menu from the server list. | | `ctrl+c` | Close the menu from any screen. | When you've typed a filter, `left` and `right` move the cursor in it. At the end of the filter, `right` acts as `enter`. **Remove** and **Reject** ask on their own row. `left` chooses yes, `right` chooses no, and `enter` confirms the highlighted answer. Typing any other character answers no. **Approve** opens a screen that shows what the server connects to or runs. Press `enter` to approve it or `escape` to cancel. ## Approval prompts These keys work when fx asks before it runs a tool. | Shortcut | Action | | --- | --- | | `1`, `2`, or `3` | Choose that option and answer right away. The prompt shows what each number does. | | `up`, `down`, `left`, or `right` | Move between options. While you type a note, `left` and `right` move the cursor in it. | | `tab` | Add a note for fx to a yes or no answer. When the prompt doesn't take a note, move to the next option. | | `enter` | Confirm the highlighted option. | | `escape` | Cancel the request and stop fx's turn. | | `ctrl+c` | Answer no, without a note. | | mouse wheel | Scroll a long file review. | ## Questions from fx These keys work when fx asks you a question with options. | Shortcut | Action | | --- | --- | | `1` to `9` | Choose that option. | | `up` or `down` | Move between options. | | `shift+up` or `shift+down` | Move between options while you type an answer. | | `tab` | Go to the next question. | | `left` | Go back to the previous question, unless you're typing an answer. | | `enter` | Answer. | | `escape` | Cancel the questions. If you've typed an answer, press `escape` twice to clear it first. | | `ctrl+c` | Cancel the questions. | ## Full detail Full detail shows the conversation and complete command output. It opens on the latest turns. Scrolling up past them loads earlier turns from the saved session, one context compaction at a time. If earlier turns can't be loaded, the footer says so, and `page up` tries again. If a damaged line in the saved session hides some earlier turns, the footer says so and points to `fx doctor`, which names the session and [the command that recovers it](https://fx.sh/docs/using-fx/sessions.md#recover-interrupted-work). | Shortcut | Action | | --- | --- | | `ctrl+o`, `escape`, or `ctrl+c` | Close Full detail. fx keeps working. | | `up` or `down`, mouse wheel | Scroll. | | `page up` or `page down` | Scroll one page. | --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Configuration" description: "Reference for fx settings, scopes, defaults, and environment variables." canonical_url: https://fx.sh/docs/configure-fx/configuration markdown_url: https://fx.sh/docs/configure-fx/configuration.md --- # Configuration Use [`/settings`](https://fx.sh/docs/using-fx/slash-commands.md#inspection-and-settings) to change your preferences in fx, or `fx config set` from a terminal or script: ```bash fx config set fast_mode on ``` `fx config set` saves a preference in `~/.fx/settings.json` for every workspace and prints where it went; `fx config unset` removes it. Both also remove an older copy of the key from [workspace entries](#workspace-entries), so the change takes effect everywhere. Switches take `true` or `false` (`on` and `off` work too). Permission, model, provider, and account settings keep their own commands, such as `/permissions`, `/model`, `fx provider`, and `fx login`. Edit `~/.fx/settings.json` for the rest, such as `review_model`, `first_call_tool_choice`, `provider_order`, and `context_limits`, and `.fx.json` for shared project defaults. When `fx config` refuses a key, it says what to use instead. ## Files and precedence | File | Purpose | | --- | --- | | `~/.fx/settings.json` | Personal settings and workspace overrides. | | `<workspace>/.fx.json` | Shared project defaults. | [MCP servers](https://fx.sh/docs/capabilities/mcp.md) use separate files: `~/.fx/mcp.json` and `<workspace>/.mcp.json`. To keep a separate profile, set `FX_HOME` to an absolute path. fx then uses that folder in place of `~/.fx` for settings, sessions, and everything else it stores there, and messages name it `$FX_HOME`. For example, `FX_HOME=/tmp/fx-test fx` reads `/tmp/fx-test/settings.json`. `fx status` shows the folder in use. fx creates the folder, and any missing folders above it, on first use, and `FX_HOME` works even when `HOME` isn't set. It must be a folder, not a file. It can't be `/` or your home folder itself, because fx keeps its folder private to your user. The OS keychain is shared between profiles. For each setting, the highest available source wins: 1. command-line flag, where supported 2. environment variable 3. [`fx ask --config key=value`](https://fx.sh/docs/using-fx/fx-ask.md#override-a-setting-for-one-request), for one request 4. matching workspace entry in `~/.fx/settings.json` 5. global entry in `~/.fx/settings.json` 6. `<workspace>/.fx.json` 7. built-in default Settings files have a 64 KiB limit. fx ignores unknown keys. A value fx can't use, such as text where a setting takes a number, can make fx skip the rest of that file or workspace entry, keeping only its provider and model choices. fx reports the problem at startup. Run `fx doctor` to list unknown keys, such as a misspelled setting, with the closest known key. It also lists older names, such as `statusLine` and a saved `permission_mode` of `yolo`, which fx still reads until 0.0.18. If other users can write to `~/.fx` or `~/.fx/settings.json`, fx removes their write access at startup and loads the settings, with a note asking you to check `settings.json` if you didn't write it yourself. `fx ask` and other commands print the same note on stderr. If fx can't change the permissions, such as on a folder you don't own, it skips those settings. ### Check settings in your editor Editors that read JSON Schema, such as VS Code, can complete and check settings files. Add a `$schema` key to the top of the file: ```json { "$schema": "https://fx.sh/schemas/settings.json" } ``` Use `https://fx.sh/schemas/fx.json` in a project `.fx.json`. The editor then flags unknown keys, wrong types, and values fx doesn't accept, and marks older names as deprecated. fx ignores `$schema` when it reads the file. `fx config schema` prints the schema for the installed version, and `fx config schema --project` prints the one for `.fx.json`. ## Project configuration Create `.fx.json` in the directory where you run fx, or add these fields to the existing file: ```json { "max_agent_steps": 40, "max_tool_result_bytes": 131072 } ``` | Field | Description | Type and values | Default | | --- | --- | --- | --- | | `max_agent_steps` | Maximum agent steps per turn; `0` means unlimited. | Non-negative integer | `0` | | `max_tool_result_bytes` | Tool output budget in model context; saved results can be larger. | Integer of at least `1024` | `65536` | | `context` | Load [project instructions](https://fx.sh/docs/configure-fx/project-instructions.md). | Boolean | `true` | | `provider_order` | Preferred AI Gateway providers, in order. | Array of up to 8 provider slugs | No preference | | `provider_strict` | Restrict Gateway requests to `provider_order`. | Boolean | `false` | Only the fields above apply in `.fx.json`; fx ignores any other setting there and warns about it. Keep personal settings, including models and permissions, in `~/.fx/settings.json`. See [Model routing](https://fx.sh/docs/configure-fx/models.md#ai-gateway-routing) for `provider_order` and `provider_strict`. ## User profile Add these fields to `~/.fx/settings.json` to collapse tool output and turn off generated conversation titles: ```json { "collapse_tool_calls": true, "session_titles": false } ``` Restart fx after editing a settings file by hand. The profile also accepts the [project settings](#project-configuration) listed above. ### Agent and model settings | Field | Description | Values and default | | --- | --- | --- | | `provider` | Service used for model requests. | `"gateway"`, `"codex"`, `"grok"`, or a configured connection name. Default: `"gateway"`. | | `providers` | Named [custom model connections](https://fx.sh/docs/configure-fx/custom-model-connections.md). | Object stored only at the top level of the private profile. | | `models` | Saved model ID for each provider or connection. | Object keyed by provider, such as `{"gateway": "moonshotai/kimi-k3"}`. | | `permission_mode` | How fx handles tool calls that need permission. | `"ask"`, `"auto"`, or `"full-access"`; legacy `"yolo"` is also accepted. Default: `"auto"`. | | `first_call_tool_choice` | Tool choice for the first model request of each turn; required vision fallback takes precedence. | `"auto"` or `"none"`. Default: `"auto"`. | | `review_model` | AI Gateway reviewer used by Auto mode. | An AI Gateway model ID or `"typesafeai/jev"`. See [review models](https://fx.sh/docs/configure-fx/permissions.md#auto-mode). | | `fast_mode` | Use faster inference when supported. | Boolean. Default: `false`. | | `ultrafast_mode` | Request the higher-priced [OpenAI Ultrafast tier](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode) for an eligible AI Gateway model. Cannot be set by project `.fx.json`. | Boolean. Default: `false`. | | `effort` | Reasoning effort for the selected model. | `"auto"` or an effort name supported by the model; `null` resets to auto. Default: `"auto"`. | | `auto_compact_percent` | Start automatic compaction at this percentage of usable input capacity. | Integer from `10` to `80`. Default: `80`. | | `cache_warming` | Keep a waiting Claude conversation's [prompt cache](https://fx.sh/docs/using-fx/usage-and-costs.md#cache-warming) alive through AI Gateway for up to 30 minutes after its last request. | Boolean. Default: `true`. | For `context_limits`, see [Context limits](https://fx.sh/docs/configure-fx/context-limits.md). For `permission` rules, see [Permissions](https://fx.sh/docs/configure-fx/permissions.md). For `skill_symlink_authorities`, see [Skills](https://fx.sh/docs/capabilities/skills.md#discovery-roots). ### Interface and update settings | Field | Description | Values and default | | --- | --- | --- | | `slash_menu_categories` | Show command categories and skill sources in search results. | Boolean. Default: `true`. | | `auto_upgrade` | Download and install updates in the background; press ctrl+g to reload. | Boolean. Default: `true`. | | `update_channel` | Release channel used for updates. | `"stable"` or `"dev"`. Default: `"stable"`. | | `startup_scrollback` | Restore terminal output at startup. | Boolean. Default: `true`. | | `collapse_tool_calls` | Show a summary for each tool-call group. | Boolean. Default: `false`. | | `session_titles` | Generate a title from the first prompt. | Boolean. Default: `true`. | | `theme` | Built-in or custom terminal theme. | `"light"`, `"dark"`, or a file name from `~/.fx/themes/`. Default: follows the terminal. | | `prompt_history.enabled` | Save prompts and slash commands for input history. | Boolean. Default: `true`. | | `status_line.context` | Show context usage in the footer. | Boolean. Default: `false`. | | `status_line.session` | Show the session title in the footer. | Boolean. Default: `false`. | | `status_line.workspace` | Show the workspace path and Git branch. | Boolean. Default: `false`. | | `sound.turn_end` | Play a sound when a turn finishes. | Boolean. Default: `true` on macOS, `false` elsewhere. | | `sound.attention_required` | Play a sound when fx needs your attention. | Boolean. Default: `true` on macOS, `false` elsewhere. | | `sound.max` | Enable extra interaction sounds when sound is on. | Boolean. Default: `false`. | Press ctrl+o to see collapsed tool output in Full detail. [Automatic titles](https://fx.sh/docs/using-fx/sessions.md#session-titles) make a separate model request. ### Terminal themes fx follows the terminal's light or dark mode by default. Set `theme` to `"light"`, `"dark"`, or the name of a JSON file in `~/.fx/themes/`: ```json { "theme": "github-dark" } ``` This loads `~/.fx/themes/github-dark.json`. fx accepts VS Code color themes and its native theme format. For a native theme, use `colors` for the interface and `syntax` for code: ```json { "colors": { "link": "#58A6FF" }, "syntax": { "function": "#D2A8FF", "variable": "#FFA657", "operator": "#FF7B72" } } ``` Other syntax slots are `keyword`, `string`, `number`, and `comment`. Omitted colors keep their defaults. Set `"syntax": false` to turn syntax highlighting off. When a named theme ends in `-dark`, `-light`, `_dark`, or `_light`, fx uses the matching sibling when the terminal changes appearance, if that file exists. ## Workspace entries To override a setting for one project, add its absolute path under `workspaces` in `~/.fx/settings.json`: ```json { "max_agent_steps": 40, "workspaces": { "/path/to/project": { "max_agent_steps": 80 } } } ``` This allows 80 agent steps per turn in that project and 40 elsewhere. Workspace settings override global and project settings. fx also stores local permission rules here, along with keys it reads only inside a workspace entry: `additional_directories`, which `fx workspace` manages for [additional directories](https://fx.sh/docs/configure-fx/additional-workspaces.md), and the project MCP server approvals `enabledMcpjsonServers`, `disabledMcpjsonServers`, and `enableAllProjectMcpServers`, which `fx mcp approve` and `fx mcp reject` manage. Custom connection definitions (`providers`) and `$schema` belong at the top level. Model and interface changes made through fx's menus are saved globally. ## Environment variables Environment variables override saved settings for the current process. For example: ```bash FX_MAX_AGENT_STEPS=20 fx ``` | Variable | Description | | --- | --- | | `AI_GATEWAY_API_KEY` | Authenticate with a Vercel AI Gateway API key. | | `VERCEL_OIDC_TOKEN` | Authenticate in a Vercel-managed environment. | | `FX_PROVIDER` | Select a built-in provider or custom connection for this process. | | `FX_MODEL` | Override the model for this process. | | `FX_ULTRAFAST` | Request [Ultrafast](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode) with `1`, `true`, `on`, or `yes`; disable with `0`, `false`, `off`, or `no`. Values are trimmed and case-insensitive; invalid values fail startup. CLI flags take precedence. | | `FX_REVIEW_MODEL` | Override the AI Gateway permission reviewer for this process. | | `TYPESAFE_API_KEY` | Call TypeSafe directly when the review model is `typesafeai/jev`. | | `FX_PROVIDER_ORDER` | Set comma-separated AI Gateway provider slugs in preference order. | | `FX_PROVIDER_STRICT` | Restrict Gateway routing to the configured provider order with `1`, `true`, `on`, or `yes`; lift the restriction with `0`, `false`, `off`, or `no`. | | `FX_PERMISSION_MODE` | Override with `ask`, `auto`, or `full-access`; legacy `yolo` is also accepted. | | `FX_MAX_AGENT_STEPS` | Override the agent step limit. | | `FX_AUTO_COMPACT_PERCENT` | Override `auto_compact_percent` with a whole number from 10 to 80; other values are ignored. | | `FX_THEME` | Select `light`, `dark`, or a custom theme for this process. | | `FX_SOUND` | Override all three `sound` settings: `off`, `0`, or `false` turns every sound off, `max` turns every sound on, and another value, such as `on`, turns on the turn-end and attention sounds. | | `FX_AUTO_UPGRADE=0` | Disable automatic upgrades for the process; `false` works too. | | `FX_NO_OPEN_BROWSER=1` | Print authentication URLs instead of opening a browser. | | `FX_HOME` | Use this absolute folder in place of `~/.fx` for settings, sessions, and other state. | | `NO_COLOR` | Set to any non-empty value to turn color off in help, `fx ask`, and the interactive session. The interactive session keeps bold, dim, and reverse text; help prints no styling at all. | | `TERM=dumb` | Turn color off in help and `fx ask`. The interactive session needs cursor movement, so `fx` exits and suggests `fx ask` instead. | ### Diagnostics Use these controls when investigating a problem: | Variable | Description | | --- | --- | | `FX_DEBUG_RECORD=1` | Write an automatic private terminal recording under `~/.fx/recordings/`. | | `FX_DEBUG_RECORD_SILENT_BANNER=1` | Hide the recording notice from the inline transcript while keeping it in Ctrl-O. | | `FX_RECORD` | Write a terminal recording to an explicit path. | | `FX_RECORD_INPUT=1` | Include raw terminal input events in a recording. | | `FX_TRACE=1` | Write a trace to the default private trace path. | | `FX_TRACE_LOG` | Write a trace to an explicit path; relative paths resolve from the primary workspace. | | `FX_TRACE_SCOPES` | Limit traces to an exact comma-separated list of scopes. | | `FX_TRACE_STDERR=1` | Write trace lines to stderr, alone or alongside a trace file. | | `FX_SYNC_UPDATES` | Set `on` or `off` to troubleshoot terminal synchronized updates. | | `FX_DISABLE_KEYCHAIN=1` | Disable the native macOS API-key store; `fx login vercel --api-key` cannot save a key while set. | | `FX_HERDR=0` | Disable automatic Herdr lifecycle reporting. | Environment and command-line overrides affect only the current process and are not written back to settings. ## Herdr integration When launched inside Herdr, fx names its pane `fx` and reports whether it is idle, working, or waiting for input. A waiting report says why: a permission request, a question, or a request only you can continue, such as one that ran out of credits. With several [instances](https://fx.sh/docs/using-fx/instances.md) open, it reports the busiest one: waiting for input over working, and working over idle. Herdr supplies the local socket and pane ID through `HERDR_SOCKET_PATH` and `HERDR_PANE_ID`. Reports include the session state and session ID, but no prompts or tool output. If Herdr doesn't answer, fx keeps running without the reports. Set `FX_HERDR=0` or `FX_HERDR=false` to disable reporting. <span id="inspect-effective-configuration" /> ## Check which settings fx is using Show the settings in effect for this run: ```bash fx status ``` ```bash fx status --json ``` Use `fx permissions --json` for the resolved permission rules and `fx workspace --json` for active additional directories. To see what each settings file sets, list the values in order from lowest to highest precedence: ```bash fx config list --show-origin ``` Each line starts with where the value comes from, then `key=value`, with nested keys in dotted form such as `status_line.context`. Values from a settings file or workspace entry come first. A set environment variable that overrides a setting comes last, as `env:FX_MAX_AGENT_STEPS`, because it overrides the files; a value fx ignores isn't listed. When a key appears more than once, the last line is the one fx uses. `fx config get <key>` prints the value a run uses, including the default when nothing sets it; with `--show-origin`, it names where that value comes from, or `default`. If fx rejects or ignores what a file sets, `get` shows the value fx uses instead and prints the same warning `fx status` does. Command-line flags can still override it for one run. Add `--global` to `list` or `get` to read only the global settings in `~/.fx/settings.json`, or `--workspace` to read only this workspace's entry. `set` and `unset` don't take `--workspace`, because they change a preference for every workspace. <span id="fx-managed-fields" /> ## Compatibility fx still reads the older `model`, `codex_model`, and `grok_model` keys. Saving a model moves it under `models`. fx saves full access as `"permission_mode": "full-access"` and still reads the older `"yolo"` until fx 0.0.18. fx manages `yolo_acknowledged`, `credential_source`, and `fast_mode_model_bound` when you change permissions, sign in, or turn Fast mode on or off. fx still reads the older `statusLine` and `notifications` keys until fx 0.0.18. Saving a status line or sound setting moves them to `status_line` and `sound`. If a file sets both spellings, the newer key wins, and `fx doctor` names the older one to remove. `fx config` accepts either spelling. fx no longer supports `skill_match_fuzzy`. A `~/.fx/settings.json` that still sets it is ignored, and fx prints `remove skill_match_fuzzy` until you delete the key. Skills load only when you invoke them or the agent calls the skill tool. fx ignores the retired `input_appearance`, `maxxing_mode`, `sandbox`, and `web_fetch_worker_model` keys without a warning, and editors mark them as deprecated. You can delete them. ## Local state See [Data and privacy](https://fx.sh/docs/using-fx/data-and-privacy.md) for saved conversations, credentials, and other local state. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Context limits" description: "Adjust how much text fx loads from instructions, skills, MCP tools, and image analysis." canonical_url: https://fx.sh/docs/configure-fx/context-limits markdown_url: https://fx.sh/docs/configure-fx/context-limits.md --- # Context limits Context limits control how much text fx loads from instructions, skills, MCP tools, and image analysis. If content is shortened or omitted, press ctrl+o to see the limit notice in [Full detail](https://fx.sh/docs/using-fx/working-with-fx.md#review-the-result). ## Available limits | Field | Description | Default | | --- | --- | --- | | `skill_description_bytes` | Each skill's description in the catalog | 1 KiB | | `skill_catalog_bytes` | Combined skill catalog | Based on the model's context window | | `skill_chunk_bytes` | Skill content returned by one read | Whole file | | `skill_file_bytes` | Each skill file or reference file | 1 MiB | | `mcp_description_bytes` | Each MCP tool description in search results | 1 KiB | | `mcp_search_result_bytes` | Combined MCP tool search results | 16 KiB | | `mcp_server_instructions_bytes` | Instructions from each MCP server | 2 KiB | | `mcp_selected_schema_bytes` | One tool's schema, the combined schemas loaded by a search, or the combined schemas of always-loaded ACP client servers | 64 KiB | | `project_instruction_file_bytes` | Each instruction file | 64 KiB | | `project_instructions_total_bytes` | Combined project instructions | 128 KiB | | `image_adapter_output_bytes` | Text returned by the vision tool | 20 KiB | The skill catalog budget is estimated from 2% of the model's context window, using four bytes per token. If the context size is unknown, it defaults to 8,000 characters. Setting `skill_catalog_bytes` replaces this with a fixed byte limit. Skills load as complete files. If a file exceeds `skill_file_bytes` or an explicit `skill_chunk_bytes` limit, fx rejects the load instead of returning partial instructions. Instruction files work differently: fx cuts a file longer than `project_instruction_file_bytes` at its last complete line within the limit, and leaves out whole files once the combined instructions pass `project_instructions_total_bytes`. See [Missing instructions](https://fx.sh/docs/configure-fx/project-instructions.md#missing-instructions) for which files fx keeps. ## Settings Add `context_limits` to `~/.fx/settings.json`. This example doubles the per-file and combined instruction limits: ```json { "context_limits": { "project_instruction_file_bytes": 131072, "project_instructions_total_bytes": 262144 } } ``` Use a non-negative integer in bytes, or `"off"` to disable a limit. All values, including `"off"`, are capped at 64 MiB. An unknown limit name or any other value makes fx skip the rest of that settings file or workspace entry, keeping only its provider and model choices, and report the problem at startup. You can also set limits in a [workspace entry](https://fx.sh/docs/configure-fx/configuration.md#workspace-entries). Restart fx after editing the file. Project `.fx.json` does not accept `context_limits`. ## Command-line overrides Place `--context-limit` before the command to override a limit for one run: ```bash fx --context-limit project_instruction_file_bytes=131072 ``` Repeat the flag to change more than one limit: ```bash fx --context-limit project_instruction_file_bytes=off --context-limit project_instructions_total_bytes=off ``` Command-line values override workspace and global settings. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Tools" description: "Built-in tools available to the fx agent." canonical_url: https://fx.sh/docs/capabilities/tools markdown_url: https://fx.sh/docs/capabilities/tools.md --- # Tools fx uses tools to read and edit files, run commands, and gather information. Describe what you need in your prompt; fx chooses the tools and shows their results in the conversation. <span id="subagent-requests" /> <span id="vision" /> ## Built-in tools | Tools | Description | | --- | --- | | `glob_files`, `grep_files`, `read_file` | Find files, search their contents, and read them | | `write_file`, `edit_file` | Create or update files | | `shell` | Run commands, including interactive programs and development servers | | [`web_search`](https://fx.sh/docs/capabilities/web-search.md), `web_fetch` | Search the web (AI Gateway) and read public URLs | | [`vision`](https://fx.sh/docs/capabilities/vision.md#how-vision-works) | Analyze images for models without image input (AI Gateway) | | [`skill`, `install_skill`](https://fx.sh/docs/capabilities/skills.md) | Read skill instructions and references, or install skills | | [`subagent`](https://fx.sh/docs/capabilities/subagents.md) | Delegate work to another agent | | `capability_search` | Find installed skills and configured MCP tools | | `mcp_select_tool` | Load a specific MCP tool for use | | `ask_user_question` | Ask you for input | | `read_tool_result` | Search or read a stored tool result, or search turns saved by compaction | Models with image input analyze attached images directly. See [Vision](https://fx.sh/docs/capabilities/vision.md#how-vision-works). `glob_files` matches file paths with glob patterns. `grep_files` searches for literal text. MCP tools found by `capability_search` load automatically within the [schema budget](https://fx.sh/docs/configure-fx/context-limits.md); `mcp_select_tool` selects one by name. `write_file` and `edit_file` handle files up to 16 MiB. If an edit would exceed that limit, the tool returns an error so the agent can use a shell command instead. Saved sessions retain the edit's diff for Ctrl+O, with a notice when rows exceed the saved-text limit. ## Background commands fx can keep a development server or file watcher running while it continues working. Ask it to check the output, send input to an interactive program, or stop a command: ```text Start the development server and keep it running while you update the homepage. ``` The `shell` tool uses `run` to start a command, `interact` to read output or send input, and `stop` to end it. A running command remains available across prompts in the same conversation. fx loads shell startup files once per process and reuses that configuration for later commands. Use `/shell reload` after changing your startup files; this also clears remembered command approvals. The agent can also reload them before a command, for example after it installs a tool. Terminals launched by the shell tool stop when fx exits and are not recovered on resume. ## Large tool results In saved conversations, fx stores large tool results separately and gives the model a preview and a handle. The agent uses `read_tool_result` to search that output or read a specific range, including after you resume the conversation. After [context compaction](https://fx.sh/docs/using-fx/context-compaction.md#what-fx-keeps), it also searches the turns and tool calls fx saved. [`max_tool_result_bytes`](https://fx.sh/docs/configure-fx/configuration.md#project-configuration) sets the tool output budget for model context. Results stored for later reads can exceed this budget. ## Scope and permissions File and command tools start from the primary workspace. [Additional directories](https://fx.sh/docs/configure-fx/additional-workspaces.md) extend that scope. Tool actions follow your [permission mode and rules](https://fx.sh/docs/configure-fx/permissions.md). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "MCP protocol reference" description: "Transports, protocol coverage, schema handling, and isolation for the fx MCP client." canonical_url: https://fx.sh/docs/capabilities/mcp/protocol markdown_url: https://fx.sh/docs/capabilities/mcp/protocol.md --- # MCP protocol reference fx connects to MCP servers over stdio or Streamable HTTP. For setup commands and examples, see [MCP](https://fx.sh/docs/capabilities/mcp.md). > **Core MCP client scope** > > fx is an MCP client for tools. It does not currently implement MCP resources, prompts, completion, sampling, or roots, or the MCP Tasks, MCP Apps, Skills over MCP, Client Credentials, or Enterprise-Managed Authorization extensions. fx does not connect to legacy HTTP+SSE servers, install servers from a registry, or expose itself as an MCP server. ## Protocol compatibility | Transport | Supported versions | | --- | --- | | stdio | `2026-07-28`, `2025-11-25`, `2025-06-18`, `2025-03-26` | | Streamable HTTP | `2026-07-28`, `2025-11-25`, `2025-06-18`, `2025-03-26` | fx detects each server's version, so there is nothing to configure. It asks for [MCP `2026-07-28`](https://modelcontextprotocol.io/specification/2026-07-28) first with `server/discover`. A server that doesn't answer it gets `initialize` with `2025-11-25` and may choose `2025-06-18` or `2025-03-26` instead. With `2026-07-28` servers, fx uses stateless requests and `subscriptions/listen`. It accepts JSON and SSE responses and supports Multiple Round-Trip Requests (MRTR) for user input. Legacy HTTP+SSE servers (`"type": "sse"`) are not supported, and `/mcp list` shows them as not supported. A server that speaks only `2024-11-05` fails to connect. ## Core protocol coverage | Feature | Support | | --- | --- | | Tools | Discovery with pagination, calls, progress, and cancellation. | | Updates | Tool list-change notifications, and `subscriptions/listen` with `2026-07-28` servers. | | Elicitation | Forms and URLs that request user input. | | Resources, prompts, and completion | Not supported. | | Sampling and roots | Not supported. fx doesn't offer them, and answers a server's request for either with an error. | <span id="elicitation-by-surface" /> ## Requests for user input An MCP server can ask you to fill in a form or open a URL; the protocol calls this elicitation. Interactive fx shows the form, or asks before opening the URL in your browser. fx does not fetch these URLs or see what the browser shows. `fx ask` asks the same way when stdin, stdout, and stderr are terminals. `--json` and `--quiet` turn this off, and then a server's request for input ends that call. ACP forwards form and URL requests to the client when the client supports them. ## Tool schemas A tool's input schema must be a JSON object with `"type": "object"`. fx accepts JSON Schema 2020-12 and Draft 7, up to 64 levels deep, 4,096 nodes, and 256 KiB. A tool outside these limits is left out of its server's tools. Arguments must be a JSON object of at most 1 MiB. The server validates them against its schema, and fx reports the tool errors it returns. A tool's result can be up to 8 MiB. As with other [tools](https://fx.sh/docs/capabilities/tools.md), a large result in a saved conversation is stored whole for `read_tool_result`. Otherwise the model gets its first 64 KiB. Through [`fx mcp call`](https://fx.sh/docs/capabilities/mcp.md#large-results-in-shell-commands), a structured result can be up to 16 MiB, and it goes to the command instead of the model. ## Discovery and isolation `capability_search` finds tools and loads their schemas when needed. `mcp_select_tool` selects a specific tool. MCP tool names include the server name to avoid collisions. [Context limits](https://fx.sh/docs/configure-fx/context-limits.md) bound server instructions, descriptions, search results, and schemas. | Session | Available servers | Same-name entries | | --- | --- | --- | | Interactive fx and `fx ask` | Profile and approved project servers. | Profile wins. | | ACP | Client-supplied and approved project servers; profile servers only with explicit client opt-in. | Client, then profile, then project. | | [Subagent](https://fx.sh/docs/capabilities/subagents.md) | The servers its parent can use, checked again at each call, or the servers its [agent profile](https://fx.sh/docs/configure-fx/agent-profiles.md#profilejson) lists in `mcp_servers`. | Inherited from the parent. | Pending and rejected project servers stay disconnected. In ACP, the tools of a client-supplied server are offered to the model on every turn, without a search, unless the client sets `_meta.fx.alwaysLoaded` to `false` for that server. Their schemas share the `mcp_selected_schema_bytes` [context limit](https://fx.sh/docs/configure-fx/context-limits.md); tools past it stay available through `capability_search`. ## Trust and security MCP content is external input, and it cannot grant permissions. MCP calls follow fx's [permission rules](https://fx.sh/docs/configure-fx/permissions.md). `fx mcp list`, `fx status`, and `fx doctor` read configuration without connecting. Use `fx mcp show <name>` to connect to a server and see its status, version, and tools. <span id="conformance" /> ## Stdio configuration details Use a `command` array for the executable and arguments. A command string with a separate `args` array is also accepted. Local servers get only `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, and `USER` from the fx process environment, as in the MCP SDKs, so your AI Gateway key and other variables stay with fx. Pass anything else a server needs in `env`, such as `"GITHUB_TOKEN": "${GITHUB_TOKEN}"`. Values in `env` override inherited variables and must be strings; `environment` is also accepted and is used when both are present. Servers communicate through newline-delimited JSON-RPC on stdin and stdout. Each server runs in its own process group. When fx exits, it sends each group `SIGTERM` without waiting; a server still running 2 seconds later gets `SIGKILL`, even if fx crashed. ## Profile fields Put server entries under `mcpServers` in `~/.fx/mcp.json`. Older files that use the `mcp` key keep loading; don't use both keys in one file. Server names use letters, numbers, `_`, and `-`. ```json { "mcpServers": { "local-tools": { "type": "stdio", "command": ["npx", "-y", "@modelcontextprotocol/server-everything"], "env": { "LOG_LEVEL": "warn" } }, "remote-tools": { "type": "http", "url": "https://mcp.example.com/mcp" } } } ``` | Field | Description | Default | | --- | --- | --- | | `enabled` | Set to `false` to keep an entry without starting it. | `true` | | `startup_timeout_ms` | How long the server may take to start. | `30000` | | `operation_timeout_ms` | How long a request may wait without an answer or a progress update before fx stops waiting and tells the model the server did not answer in time. Raise it for tools that run longer without reporting progress. | `300000` | A request also ends after 10 minutes, or after `operation_timeout_ms` when that is longer, even while the server reports progress. A server that stops or fails to start is started again, up to 8 tries in a row, waiting from 1 to 30 seconds between tries. The count starts over once the server has stayed up for a minute. fx ignores `required` and `restart_limit`, and `/mcp list` notes an entry that sets them so you can remove them. ## Reload behavior `/mcp add`, `/mcp remove`, `/mcp approve`, and `/mcp reject` take effect right away and touch only the servers they change. A server whose configuration stays the same keeps running, along with its connection, sign-in, and calls in progress. A removed server stops, and a call still running on it ends with an error saying the MCP config changed. An added or changed server starts once its earlier process has exited, so only one copy runs at a time. A browser sign-in in progress continues unless the change removes or changes that server. fx loads a change made outside these commands the same way, touching only the servers it changes. That includes your own edit to `~/.fx/mcp.json` or `.mcp.json`, `fx mcp add` or `fx mcp remove` in another terminal, and an approval made in another fx window. fx checks for it when you send a prompt and when you run a `/mcp` command. A prompt sent while a turn is still running keeps the current servers, and the next prompt after it loads the change. ## HTTP authentication fields Use `"type": "http"` with a `url`. fx also reads `"streamable-http"` as `http`. | Field | Description | | --- | --- | | `headers` | Static header names and values. | | `header_env` | Maps header names to environment variables containing their values. | | `bearer_token_env` | Environment variable containing the bearer token. | | `oauth` | Browser sign-in configuration. | fx reads these variables when it starts. If one is missing, `/mcp list` shows the server as needing it. If one holds a line break or another control character, which a header can't carry, `/mcp list` shows `can't use $NAME` and fx sends nothing to that server. Profile entries reject a literal `Authorization` header, and `header_env` can't set one. Use `bearer_token_env` for that credential. ## OAuth configuration fx discovers the server's sign-in endpoints, signs in with `fx mcp login <name>`, and refreshes saved tokens. All `oauth` fields are optional: | Field | Description | | --- | --- | | `client_id` | ID for a registered OAuth client. | | `client_secret_env` | Environment variable holding the client secret; requires `client_id`. | | `client_metadata_url` | Client ID Metadata Document URL, used when the server supports it and no `client_id` is set. | | `callback_port` | Port for localhost callbacks, from `1` to `65535`. Omit to use an available port. | | `resource` | The protected resource to request tokens for, when it must be written differently from the server's own, such as with a trailing slash. | | `scopes` | An array of scopes to ask for instead of the ones the server lists. Scopes the server requests when it rejects a token still take precedence. | Without a client ID or supported metadata document, fx uses Dynamic Client Registration. Without `scopes`, fx asks for the scopes the server lists or requests. If the server rejects a token refresh, the server needs a new sign-in. Temporary refresh failures keep the saved login. When several fx windows use one server, one window refreshes its sign-in at a time and the others use the login it saved. If fx can't save a new login, it says so: the login keeps working in that window, and the server needs a new sign-in after fx restarts. Slack uses fx's own Slack app unless you set `client_id`. Its sign-in returns to `http://localhost:3118/callback`, and fx asks for the scopes the app has. Slack renews this login without the app's secret while fx uses it; after 30 days without a renewal, sign in again. On macOS, credentials use Keychain, with the private file `~/.fx/mcp-credentials/credentials-v3.json` as fallback when no default Keychain exists. Other platforms use the file. `FX_DISABLE_KEYCHAIN=1` selects file storage explicitly. ACP sessions do not open sign-in. The ACP client can supply an `Authorization` header for its servers. ## Project configuration limits Project `.mcp.json` files use a top-level `mcpServers` object. Servers require approval. Files must be regular files, not symlinks, and cannot exceed 1 MiB. After approval, `${VAR}` and `${VAR:-default}` expand in commands, arguments, environment values, and HTTP header values. A missing variable without a default skips that server, and `/mcp list` explains why. Expanded values have a separate 1 MiB total limit. `~/.fx/mcp.json` expands variables the same way in interactive fx and `fx ask`. ACP sessions read profile strings as written. Project approvals are saved per workspace. Manage them with [`/mcp approve` and `/mcp reject`](https://fx.sh/docs/capabilities/mcp.md#project-configuration-and-trust). Unapproved servers stay disconnected. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "fx ask" description: "Run noninteractive requests, return JSON, and continue saved sessions." canonical_url: https://fx.sh/docs/using-fx/fx-ask markdown_url: https://fx.sh/docs/using-fx/fx-ask.md --- # fx ask `fx ask` runs one noninteractive request and exits. [Connect an account](https://fx.sh/docs/getting-started/authentication.md), then run it from your project directory: ```bash fx ask "explain what this repository does" ``` ## Pass a prompt to `fx ask` Pass the prompt as command arguments. In a shell script, `printf` can send generated prompt text to `fx ask` through standard input (`stdin`): ```bash printf "summarize src/core\n" | fx ask ``` Put `--` before a prompt that starts with a dash; every argument after it is prompt text. Use `--image <path>` to attach an image. Repeat the flag to attach multiple images. Use `--system <text>` to replace fx's built-in system prompt for one request. [Project instructions](https://fx.sh/docs/configure-fx/project-instructions.md), such as `AGENTS.md`, still apply. ```bash fx ask --image ./ui.png "describe this interface" ``` See [Vision](https://fx.sh/docs/capabilities/vision.md) for supported formats and image routing. ## Choose the model Use `--model` for one request: ```bash fx ask --model <model-id> "Review this change" ``` Add `--effort high` or `--fast` if the model supports them. For a supported OpenAI model through AI Gateway, `--ultrafast` requests the higher-priced Ultrafast tier instead. The flags do not change your saved defaults. Use `--provider <name>` when the request should use another provider: `gateway`, `codex`, `grok`, or the name of a [custom connection](https://fx.sh/docs/configure-fx/custom-model-connections.md). Setting `FX_PROVIDER` does the same for every run. For AI Gateway, `--provider-order` sets a routing preference and `--provider-strict` prevents fallback outside it. See [AI Gateway routing](https://fx.sh/docs/configure-fx/models.md#ai-gateway-routing). ### Request Ultrafast [Ultrafast](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode) uses a higher-priced OpenAI service tier. Select a model whose AI Gateway catalog advertises Ultrafast pricing, then opt in for one run: ```sh FX_PROVIDER=gateway fx ask --model openai/gpt-6-astra --ultrafast "Review this change" ``` Use `--no-ultrafast` to disable a profile or resumed-session request. These flags override `FX_ULTRAFAST` and leave saved defaults unchanged. `--fast` and `--ultrafast` turn each other off, so when you pass more than one speed flag, the last one wins. If Gateway does not confirm the requested tier, fx writes a warning to stderr. Neither a successful run nor `ultrafast_requested` in `fx status --json` proves that the provider served Ultrafast. ## Override a setting for one request Use `--config key=value` to change a setting for one request without saving it. It takes the same keys and values as [`fx config set`](https://fx.sh/docs/configure-fx/configuration.md): ```bash fx ask --config max_agent_steps=20 --config fast_mode=on "fix the failing test" ``` Repeat `--config` for each setting. If a key appears twice, the last value wins. A `--config` value replaces the one in your settings files and `.fx.json`, but a dedicated flag such as `--no-fast` and an environment variable such as `FX_MAX_AGENT_STEPS` still take precedence. `--config` refuses the keys that `fx config set` refuses, such as `permission_mode` and model choices. Use `--permission-mode` or `--model` for those. Interactive sessions don't take `--config`; change their settings with `/settings`. ## Use `fx ask` in scripts For shell scripts and CI, redirect standard output (`stdout`) to receive raw assistant Markdown. Progress and diagnostics remain on standard error (`stderr`). Add `--quiet` to print no assistant text when only the exit status matters; `--json` takes precedence over it. In a terminal, `--no-color` keeps the layout but drops colors and hyperlinks. Setting `NO_COLOR` or `TERM=dumb` does the same. Use `--json` when a program needs structured fields instead of Markdown: ```bash fx ask --json "summarize the current changes" ``` The command returns one JSON object: ```json { "output": "Assistant Markdown", "final_output": "Final assistant response", "exit_code": 0, "model": "provider/model-id", "resolved_provider": "bedrock", "session_id": "session-id", "steps": 1, "usage": { "input_tokens": 1200, "output_tokens": 450 }, "tool_calls": [ { "name": "read_file", "status": "success" } ] } ``` `exit_code` matches the command's exit status: `0` on success, `1` when the request fails, and `2` for a usage mistake, such as an unknown flag or `--no-save` with `--resume`. A failure can include an `error` field with the error's name. Tool calls always include `name` and `status`; some tools include additional result fields. `output` includes the assistant text produced during the request. `final_output` contains the completed final response, or an empty string when no final response completed. `resolved_provider` identifies the AI Gateway provider that served the last model request. It is `null` when the provider does not report routing. `usage.input_tokens` and `usage.output_tokens` sum the counts reported by main-agent completions, including usage recorded before an error. A count is `null` when no completion reported it; reported zero remains `0`. When the provider reports caching, `usage.cache_read_tokens` and `usage.cache_write_tokens` include its cached-read and cache-write counts. These fields are omitted when the provider does not report them. These totals exclude subagent, helper-model, and provider-tool usage. Use [`fx usage`](https://fx.sh/docs/using-fx/usage-and-costs.md) for the usage and spend your provider reports. When fx had to retry or stop the last model request, `recovery` reports how it ended. Its `state` is `recovered` after a retry succeeded, `failed` when the request ended on an error, or `need_user` when it [needs you](#retries-and-requests-that-need-you). `attempt` counts the sends, `message` carries fx's status text when there is one, and a `need_user` result names what it needs in `need`, such as `quota`, `content_filter`, `rejected`, or `too_long`. When the provider refuses your credential, `auth_failure` names the credential's `source`, such as `fx login` or `AI_GATEWAY_API_KEY`, the `reason`, and the `http_status` when there is one. In a script, check the command's exit status before using the reply. This example needs `jq`: ```sh #!/bin/sh result=$(mktemp) trap 'rm -f "$result"' EXIT if fx ask --json --no-save "Summarize this repository without editing files" > "$result"; then jq -r '.final_output' "$result" else status=$? cat "$result" >&2 exit "$status" fi ``` Add `--no-save` for a run that should not create a session. In JSON output, `session_id` is an empty string. `--no-save` cannot be combined with `--resume`. Use `--timeout <seconds>` to cap how long each shell command the agent runs can take. When the agent starts [subagents](https://fx.sh/docs/capabilities/subagents.md), `fx ask` waits until every one of them has finished. Each subagent's report runs as another turn before the command exits. Subagents need a saved session, so a `--no-save` run can't start them. ## Retries and requests that need you `fx ask` retries network and provider failures like the interactive shell, and prints each wait to stderr, such as `[notice] Gateway error · next try in 8s · attempt 4`. It keeps retrying until the request goes through. Press `ctrl+c` to stop it, and the shell reports exit status `130`, or `143` after `SIGTERM`. With `--json`, an interrupted run writes no result. A reply that runs out of output tokens before any text is sent again once, as in the interactive shell. See [A reply runs out of output tokens](https://fx.sh/docs/using-fx/troubleshooting.md#a-reply-runs-out-of-output-tokens). `fx ask` can't wait for you. When a request needs you, such as when you're out of credits, a content filter blocks it, the provider rejects it, the conversation is too long for the model, or the provider refuses your credential, the run ends at once with exit status `1` and the reason on stderr. With `--json`, the result has `"exit_code": 1`. ## Continue a session with `fx ask` Use `--resume last` to continue the latest session for the current workspace: ```bash fx ask --resume last "now add tests" ``` You can pass a session ID instead of `last`. See [Sessions](https://fx.sh/docs/using-fx/sessions.md) to inspect sessions or recover an interrupted response. ## Handle permissions in noninteractive runs Set the [permission mode](https://fx.sh/docs/configure-fx/permissions.md) for one request with `--permission-mode ask`, `auto`, or `full-access`, or the shorter `--ask`, `--auto`, and `--full-access`. Your saved mode stays the same. Saved [permission rules](https://fx.sh/docs/configure-fx/permissions.md) apply to `fx ask`. In a terminal, actions that require approval can prompt on stderr. With `--json` or `--quiet`, add `--prompt-permissions` to allow those prompts. This requires terminal input; piped or redirected input cannot receive approval prompts. In `auto` mode, a security concern holds the action and returns guidance to the agent without asking you for approval. `--full-access` disables fx permission checks for the run. An interrupted run exits with code `130`. See [Troubleshooting](https://fx.sh/docs/using-fx/troubleshooting.md#fx-stops-before-running-a-tool) when a run ends before the tool executes. Run `fx ask --help` for the complete flag reference. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "ACP server" description: "Run fx from editors and clients that support Agent Client Protocol." canonical_url: https://fx.sh/docs/using-fx/acp markdown_url: https://fx.sh/docs/using-fx/acp.md --- # ACP server `fx acp` connects fx to editors that support Agent Client Protocol (ACP). The editor sends prompts and displays replies and tool activity; fx runs the agent. ## Configure an ACP client Configure your client to launch fx with the `acp` argument. Use the executable and arguments fields in its agent settings: ```json { "command": "/absolute/path/to/fx", "args": ["acp"] } ``` Set the server process's working directory to your project. Clients can supply an absolute `cwd` with `session/new`, `session/load`, or `session/resume` to bind that session to another workspace. File access, project instructions, skills, and project MCP servers follow that directory. `fx acp` accepts these options: | Option | Description | | --- | --- | | `--permission-mode <mode>` | Set the mode new, loaded, and resumed sessions start in: `ask`, `auto`, or `full-access`. Overrides the saved mode for this process without saving it. `--ask`, `--auto`, and `--full-access` are shortcuts, and `--yolo` means `--full-access`. | | `--provider <name>` | Use `gateway`, `codex`, `grok`, or a configured connection for this process. | | `--model <id>` | Set the startup model, overriding the saved model when loading a session. | | `--effort <level>` | Set the reasoning effort new sessions start with. A loaded or resumed session keeps its saved effort. | | `--fast` / `--no-fast` | Enable or disable Fast mode for new sessions when the model supports it. A loaded or resumed session keeps its saved setting. | | `--ultrafast` / `--no-ultrafast` | Request or disable the higher-priced [Ultrafast tier](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode) for this process. Overrides `FX_ULTRAFAST` and saved preferences. | | `--log-file <path>` | Write ACP diagnostics to an absolute file path. | These are the same flags `fx ask` takes, except `--provider-order` and `--provider-strict`: ACP sessions don't apply AI Gateway provider routing. If the startup model doesn't support the requested effort, Fast mode, or Ultrafast, the client's `initialize` request fails with error `-32602`. Global workspace flags such as `--add-dir`, `--no-additional-dirs`, and `--context-limit` must appear before `acp`. ## Authentication and fx settings [Connect a provider](https://fx.sh/docs/getting-started/authentication.md) before starting the client. ACP uses your fx provider settings and credentials. Project instructions and personal settings also apply when you use fx through an editor. MCP servers follow the [client-specific rules](#mcp-servers) below. ## Supported ACP methods The client must call `initialize` first. fx responds with ACP protocol version `1` and supports these methods: | Method | Description | | --- | --- | | `initialize` | Negotiate protocol capabilities and initialize the connection. | | `session/new` | Create and activate a saved session. | | `session/load` | Load an exact session ID and replay its history. | | `session/resume` | Reconnect to a saved session without replaying its history. | | `session/close` | Close the active session. | | `session/list` | List saved sessions across workspaces, or filter by an absolute `cwd`. | | `session/prompt` | Run one turn in the active session. | | `session/cancel` | Cancel the active prompt. | | `session/set_config_option` | Change provider, model, mode, supported reasoning effort, Fast mode, or eligible Ultrafast mode. | | `session/set_mode` | Change the active mode. | Each connection runs one session and one prompt at a time. Wait for the prompt response, including after cancellation, before sending another prompt. Until then, `session/list`, `session/set_config_option`, and a `session/prompt` that isn't a [steering message](#steering-and-instructions) fail with `-32600`. `session/new`, `session/load`, `session/resume`, and `session/close` cancel the running prompt first. A `$/cancel_request` notification that names the prompt's request ID cancels it like `session/cancel`. ## Sessions, models, and permissions Clients can select a provider, model, and mode. Models that support reasoning also expose an `effort` selector, and models with a Fast lane expose a `fast` selector. Supported OpenAI models through AI Gateway expose an `ultrafast` selector for the higher-priced inference tier. `fast` and `ultrafast` take the strings `"true"` and `"false"`, and turning one on turns the other off. Switching to a model or provider that doesn't support the current speed turns it off. Provider, model, effort, Fast, and Ultrafast choices are saved with the session and restored on load or resume. | ACP mode | Permission mode | | --- | --- | | `auto` | [`auto`](https://fx.sh/docs/configure-fx/permissions.md#auto-mode): run routine work and review other actions. | | `ask` | [`ask`](https://fx.sh/docs/configure-fx/permissions.md#modes): ask for approval. | | `full-access` | [`full-access`](https://fx.sh/docs/configure-fx/permissions.md#modes): run every action without fx permission checks. | A mode change applies to the active session and is saved as your permission mode in `~/.fx/settings.json`, so later CLI and ACP sessions start in it. Each new, loaded, or resumed session starts in the saved mode, or in the mode set by `--permission-mode` when the server was launched with it. **Allow for this session** approvals last until the session closes and are not restored on load. ### Ultrafast per session Ultrafast is a higher-priced OpenAI tier through AI Gateway. Select an eligible model before opting in. For a process-only launch request, set your client's arguments to `["acp", "--model", "openai/gpt-6-astra", "--ultrafast"]`. `FX_ULTRAFAST` and the profile's `ultrafast_mode` also apply to the server. For eligible models, the returned `configOptions` include a select option with `id: "ultrafast"`. After `session/new`, use its returned session ID in `session/set_config_option`: ```json { "jsonrpc": "2.0", "id": 3, "method": "session/set_config_option", "params": { "sessionId": "your-session-id", "configId": "ultrafast", "value": "true" } } ``` Use the string `"false"` to disable it before the next prompt. JSON booleans and other values are rejected with `-32602`. Enabling it for an unsupported model is also rejected before a completion request. Client changes are saved with the session and restored on load or resume. Launch flags and environment overrides remain process-local and can override that saved preference. An enabled option means the tier was requested, not that Gateway confirmed it was served. See [Ultrafast eligibility and confirmation](https://fx.sh/docs/configure-fx/models.md#eligibility-and-served-tier-confirmation). ## Prompt and MCP support `session/prompt` accepts text, embedded resources, and inline images. Images use the selected model's image support or the [vision fallback](https://fx.sh/docs/capabilities/vision.md#how-vision-works) and are saved for history replay. Unsupported images return `-32602`. fx skips audio and `resource_link` blocks. ### Steering and instructions Send a text `session/prompt` with `_meta.fx.steer: true` to guide an active turn without cancelling its current work. Check `agentCapabilities._meta.fx.steering` first. fx applies the message at the next safe model boundary; the steering request completes with the active turn. Steering takes text blocks only, up to 64 KiB. Its response reports `_meta.fx.steering: "absorbed"` when the turn took the message, or `"dropped"` when a cancellation ended the turn first. If the turn ends on its own before taking the message, the request fails with `-32600` so you can send it as a new prompt. To add session instructions, supply `systemPrompt` as text content blocks with `session/new`. Only append mode is supported; instructions follow fx's own system prompt and are restored with the session. The combined text is limited to 64 KiB. `_meta.fx.systemPrompt` is accepted for clients that cannot send the standard field; do not send both. ### Session updates Clients receive streamed messages, tool activity, permission requests, session titles, retry status, and context usage. | Update | Content | | --- | --- | | Message chunks | `agent_message_chunk` and `user_message_chunk` text with a stable `messageId`, also used during history replay. A delivered steering message appears as a user message chunk. | | `agent_thought_chunk` | Reasoning text from the model. | | `tool_call` | Tool name, kind, pending status, and redacted JSON arguments. | | `tool_call_update` | Tool progress, completion, or failure. | | `session_info_update` | Session title after a prompt or when loading history. While fx retries a model request, `_meta.fx.modelResponseRecovery` carries its `state`, `attempt`, and status `message`; `null` clears it. | | `usage_update` | Provider-confirmed context usage when the context window is known. | | `notice` | Context notices, such as content left out to fit a [context limit](https://fx.sh/docs/configure-fx/context-limits.md), for clients that set `session.notices` in `clientCapabilities`. Other clients receive them as message text. | When the agent starts [subagents](https://fx.sh/docs/capabilities/subagents.md), the `session/prompt` response waits until each one reports. A report completes the subagent's tool call and then runs as another turn of the same prompt. Cancellation also stops pending permission and MCP input requests, and stops waiting for subagent reports. ### MCP servers Clients can supply stdio and HTTP servers through `mcpServers`. A stdio entry needs an absolute `command` path, and an HTTP entry needs an HTTPS or loopback HTTP `url`. An invalid entry, or two entries with the same name, fails the request with `-32602`. fx does not connect to SSE servers or `type: "acp"` servers, and its `initialize` response does not advertise them. fx combines client entries with approved servers from the project's `.mcp.json`; a client entry wins a same-name project entry. The model sees a client-supplied server's tools on every turn, without searching for them, unless the client sets `_meta.fx.alwaysLoaded` to `false` on that entry. Those schemas share the `mcp_selected_schema_bytes` [context limit](https://fx.sh/docs/configure-fx/context-limits.md), and tools that don't fit stay available through `capability_search`. ACP sessions do not open sign-in. The client can supply an `Authorization` header for its servers. Profile servers from `~/.fx/mcp.json` are not inherited unless the client sets `_meta.fx.profileMcpServers: true` when creating, loading, or resuming a session. See [MCP protocol reference](https://fx.sh/docs/capabilities/mcp/protocol.md#discovery-and-isolation) for authentication and isolation details. ## Protocol limits ACP uses newline-delimited JSON-RPC 2.0 over stdin and stdout. Input messages are limited to 8 MiB; a larger message gets error `-32000`. fx saves an inline image that is too large for the model request, such as one over 5 MiB encoded, but doesn't send it. The model gets the image's size and the saved original's path instead, so it can make a smaller copy. Stdout carries ACP messages. Send diagnostics to `--log-file` or `FX_TRACE_LOG`. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Troubleshooting" description: "Diagnose install, authentication, model, permission, session, and terminal problems." canonical_url: https://fx.sh/docs/using-fx/troubleshooting markdown_url: https://fx.sh/docs/using-fx/troubleshooting.md --- # Troubleshooting If fx cannot start, sign in, or resume a conversation, run: ```bash fx doctor ``` The report checks configuration, credentials, and saved sessions, with recovery commands when available. ## Diagnostic commands | Command | Description | | --- | --- | | `fx status` | Check the provider, model, and credential source. | | `fx permissions --json` | List active permission rules. | | `fx workspace --json` | List accessible directories. | | `fx models --json` | List available models. | | `fx config list --show-origin` | List the values in each settings file and where each one is set. | | `/trace` | Create a [private diagnostic trace](https://fx.sh/docs/using-fx/share-feedback.md#create-a-private-diagnostic-trace). | ## `fx: command not found` Open a new terminal to pick up the installer's `PATH` change. If fx is still missing, add its default install directory: ```bash export PATH="$HOME/.local/bin:$PATH" ``` If you chose a different `FX_INSTALL_DIR`, use that path instead of `~/.local/bin`. ## Sign-in is missing or expired Run `fx status` to check the provider and credential source, then reconnect: | Provider | Command | | --- | --- | | ChatGPT | `fx login codex` | | Grok | `fx login grok` | | Vercel | `fx login vercel` | To change providers, use `/provider` in fx. Environment credentials can take precedence over saved logins; check [Credential selection](https://fx.sh/docs/getting-started/authentication.md#credential-selection) if reconnecting does not change the account. If the browser does not open, use the authorization URL printed by the login command. If your sign-in expires while fx is responding, fx opens sign-in for you and continues the request once you finish. See [fx asks you to act during a response](#fx-asks-you-to-act-during-a-response). ## fx cannot reach AI Gateway `fx needs access to Vercel AI Gateway` means the selected Gateway credential is unavailable. Run `fx login vercel` to sign in, `fx login vercel --api-key` to save an API key, or set `AI_GATEWAY_API_KEY`. For stored-key errors: - **`fx could not read the stored API key`:** save the key again with `fx login vercel --api-key`, or select another credential source in `/provider`. To see which step failed, [turn on a debug log](https://fx.sh/docs/using-fx/share-feedback.md#turn-on-a-debug-log) and retry. - **`fx login` reports that stored API keys are disabled:** unset `FX_DISABLE_KEYCHAIN` and retry, or use `AI_GATEWAY_API_KEY`. To use a different provider, follow [Authentication](https://fx.sh/docs/getting-started/authentication.md). ## fx asks you to act during a response When a request can't continue without you, fx pauses it and the status line says what it needs. Press `escape` at any of these to end the request. | Status line | What to do | | --- | --- | | `Sign-in expired · opening /login` | Finish signing in. The request continues on its own. | | `Out of credits` | Choose `I added credits, retry`, `Switch to another model`, or `Cancel this turn`. Switching puts your message back in the composer. | | `Blocked by the content filter · press Esc and rephrase` | Press `escape`, then rephrase your message. | | `The provider rejected this request · press Esc` | Press `escape`, then change the request. | | `Still too long after compacting · press Esc and shorten your message` | Press `escape`, then shorten your message. | | `This request crashed fx twice · Enter to retry, Esc to cancel` | Press `enter` to send the request again. | | `Interrupted more than a day ago · Enter to resume, Esc to cancel` | Press `enter` to send the request again. | `fx ask` and ACP clients don't wait: fx ends the request with a message instead. `fx ask` exits with status `1`; see [Retries and requests that need you](https://fx.sh/docs/using-fx/fx-ask.md#retries-and-requests-that-need-you). ## A custom model connection fails Run `fx status --json` and check `provider_endpoint` and the selected model. Connection definitions belong under top-level `providers` in `~/.fx/settings.json`, not project `.fx.json`. Check the API prefix, the exact served model ID, and the environment variable named by `auth.env`. `fx login vercel --api-key` saves only an AI Gateway key, not a custom-provider key, and fx does not fall back to a Gateway key for that connection. If text works but tools fail, check the model's function-tool support and the server's tool-call parser. A rejected resume can mean that the saved endpoint or credential slot changed. See [custom connection troubleshooting](https://fx.sh/docs/configure-fx/custom-model-connections.md#compatibility) for these cases and the adapter's limits. ## The model is not the one I chose Check the model and account with `/status`. The `--model` flag and `FX_MODEL` override the choice saved in your profile; remove them if you want the picker selection to apply. Also check workspace overrides in `~/.fx/settings.json`; `fx config list --show-origin` shows which file sets each value. See [Model selection order](https://fx.sh/docs/configure-fx/models.md#selection-order). ## A model is missing from the catalog Run `fx models` to see the current catalog and `fx status` to check the provider and account. Use `/provider` to change them. With a Vercel login, the selected team also affects the catalog. Run `fx teams` to choose it; the Team line of `/status` shows it. ## fx stops before running a tool Open `/permissions` to check the mode and rules. A deny rule blocks the matching action. In `auto` mode, a review may hold an action and return guidance to the agent. To use approval prompts, switch to `/permissions ask`. For `fx ask --json` or `--quiet`, add `--prompt-permissions` and run from a terminal to answer approvals. With piped input, configure a rule for the action or run it interactively. See [Permissions](https://fx.sh/docs/configure-fx/permissions.md). ## A reply runs out of output tokens A model can use its whole output limit before it answers, for example by reasoning for a long time or by writing a very large tool call. fx never runs a tool call that the limit cut off. When the reply ran out before any text, fx drops it and sends the request once more if it can change the request. It asks for `low` effort when the model offers `low` and you selected a higher effort or the default, and it sends a higher output limit when the first request named none and the provider accepts one. fx prints what it changed, such as `The reply ran out of output tokens before any text. Retrying with low effort.` The next request uses your selected effort again. The turn ends when the reply already showed text, when the second reply also runs out, or when fx can't change the request. If a cut-off tool call ends the turn, fx says `The reply ran out of output tokens before its tool calls were complete, so I did not run them.` Send your message again, or ask for a smaller step, such as writing a large file in parts. ## fx ignores my AGENTS.md Check these settings and locations: - `context: false` in `.fx.json` or your profile disables project instructions. - A nested `AGENTS.md` can override instructions from its parent directory. - An [additional workspace](https://fx.sh/docs/configure-fx/additional-workspaces.md) does not contribute project instructions. - Files that exceed the per-file or combined [context limit](https://fx.sh/docs/configure-fx/context-limits.md) may be truncated or omitted. Shorten the file or increase the relevant limit. ## A session will not open or resume `fx doctor` reports session damage and suggests recovery commands. To recover readable history into a separate session, preserving the original: ```bash fx session recover <session-id> ``` To inspect one session without starting a turn: ```bash fx session --id <session-id> --json ``` fx retries provider and network failures until the request goes through. Press `escape` twice to stop. If fx exits during a response, the next `fx` you start in that workspace shows `Interrupted turn · /resume to continue`. Reopen the session with `/resume` or `fx -c`, and fx sends the interrupted request again on its own. For a noninteractive run, use `fx ask --resume last "continue"`. See [Sessions](https://fx.sh/docs/using-fx/sessions.md#recover-interrupted-work). ## An MCP server is missing ```bash fx mcp list ``` This lists configured servers and their status without connecting. Run `fx mcp show <name>` to connect to one and see why it isn't ready, or open `/mcp` inside fx. The status line also names a server that needs you. | What you see | What to check | | --- | --- | | A project server is waiting for approval | Approve it with `/mcp approve <name>`. | | A server needs login | Sign in with `/mcp login <name>`. | | A server needs an environment variable | Set that variable before starting fx, or provide a default with `${VAR:-default}`. | | A local server stops as soon as it starts | Local servers get only `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, and `USER` from fx. Add any other variable the command needs to the server's `env`. | | A server is not supported | fx doesn't connect to legacy HTTP+SSE servers. Use the server's Streamable HTTP URL. | | A server failed | Run `fx mcp show <name>` to see its error, then check its command or URL. | | A manual config edit has not taken effect | Run `/mcp list`. fx loads a changed `mcp.json` or `.mcp.json` when you send your next prompt or run a `/mcp` command. | | The wrong server appears under a name | Profile entries take precedence over same-name project entries. | | A profile server is missing in an editor | ACP uses client-supplied and approved project servers. Profile servers need the client to opt in. | See [MCP](https://fx.sh/docs/capabilities/mcp.md) for setup and configuration. ## A skill is missing Open `/skills` and check: - The skill is in a supported [discovery location](https://fx.sh/docs/capabilities/skills.md#discovery-roots). - Its `SKILL.md` has valid frontmatter. [Full detail](https://fx.sh/docs/using-fx/keyboard-shortcuts.md#full-detail), which `ctrl+o` opens, lists skills fx couldn't read or parse. - If the skill folder is a symbolic link, its target is in a place fx [loads links from](https://fx.sh/docs/capabilities/skills.md#discovery-roots). - It is in the primary project or a user skill directory. Additional workspaces do not contribute skills. ## An embedded agent cannot load Check the Node SDK's [backend diagnostic](https://fx.sh/docs/lib/node.md#handle-a-missing-backend). It distinguishes a missing native addon from a WebAssembly runtime without JSPI. The embedded agent needs explicit credentials and tools; it does not load your fx CLI profile. ## The terminal renders incorrectly Try disabling synchronized terminal updates: ```bash FX_SYNC_UPDATES=off fx ``` If the problem persists, capture it so it can be reproduced: ```bash FX_RECORD=./repro.fxtape fx ``` After reproducing the issue, exit fx and replay the recording: ```bash fx replay ./repro.fxtape ``` See [Share feedback](https://fx.sh/docs/using-fx/share-feedback.md#record-a-terminal-issue) for attaching the recording to a report. ## Costs are higher than expected `fx usage` shows what your provider reports for the account, including other devices and applications, and the latest requests can take a few minutes to appear. Auto reviews, subagents, context compaction, vision fallback, session titles, cache warming, and resent replies can add model requests. Web search can also add costs. See [Additional model requests](https://fx.sh/docs/using-fx/usage-and-costs.md#additional-model-requests). For a problem not covered here, [report it](https://fx.sh/docs/using-fx/share-feedback.md) with the steps to reproduce it. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Usage and costs" description: "Check usage, spend, and plan limits from your provider." canonical_url: https://fx.sh/docs/using-fx/usage-and-costs markdown_url: https://fx.sh/docs/using-fx/usage-and-costs.md --- # Usage and costs Use `/usage` to see the usage your provider reports for the account you use with fx. The numbers come from the provider, so they include requests from other devices and applications that use the same account. A [custom connection](https://fx.sh/docs/configure-fx/custom-model-connections.md) has no usage report, so `/usage` says that provider's usage isn't shown. ## Check AI Gateway usage With AI Gateway selected, `/usage` shows spend, requests, and tokens for today, the last 7 days, and the calendar month, with a breakdown by model. Days follow UTC. What the numbers cover depends on how you sign in: | Sign-in | What `/usage` shows | | --- | --- | | fx login | Your spend on the selected team, and your user budget when the team sets one. | | API key | The spend of that key. | Press tab or the left and right arrow keys to change the period, and the up and down arrow keys to select a model. Press enter to see the selected model's spend, share, requests, token types, cache hit rate, 90th-percentile time to first token and output speed, and error rate. There, the up and down arrow keys move between models and esc goes back to the table. Press r to refresh and esc to close `/usage`. AI Gateway can take a few minutes to include a new request in its reports, so the latest requests may not appear yet. ## Check Codex and Grok plan usage With Codex selected, `/usage` shows your ChatGPT plan: its usage limits and when they reset, its credits, and its spend limit. It also shows your token activity, with shares by model and by surface, and records such as your longest chat. fx reads all of it from ChatGPT with your Codex sign-in. With Grok selected, `/usage` shows your plan's allowance for the current period and when it resets, usage by product when Grok reports it, bought credits, and pay-as-you-go spending. For an account that a team manages, `/usage` points to the team's usage page instead. ## How fx refreshes usage `/usage` opens with the numbers fx already has and refreshes in the background, so it never waits on the network. While it stays open, fx refreshes every 15 minutes. Press r to refresh at any time, unless a refresh is already running. If you reopen `/usage` within a minute of a refresh in the same fx process for the same sign-in, fx shows what it has without refreshing again. The same minute applies after a failed refresh. After you switch to another provider or sign-in, the next `/usage` refreshes right away. fx keeps the numbers in `~/.fx/usage-cache/`, shared by every fx process on the machine, so a refresh in one fx window shows up within a minute in any other window that has `/usage` open. For AI Gateway, each refresh reads today, and reads the finished days of the 7-day and monthly views only when the cache doesn't already hold them for the current UTC day. ## Check usage from the terminal From your terminal, show the same tables for the calendar month: ```bash fx usage ``` Choose a period or return structured output: ```bash fx usage --period today --json ``` Periods are `today`, `7d`, and `month`. Each run asks your provider for current numbers and reuses the finished days already in `~/.fx/usage-cache/`. `fx usage` exits with a nonzero status when it can't read usage, for example when you aren't signed in to AI Gateway. To see the tokens that one `fx ask` run used, including cached-read and cache-write counts when the provider reports them, read `usage` in [`fx ask --json`](https://fx.sh/docs/using-fx/fx-ask.md#use-fx-ask-in-scripts). ## Account billing For invoices, payment methods, and plan changes, use your provider's dashboard. A request that `/usage` doesn't show yet may still be billed. ## Ultrafast pricing [Ultrafast](https://fx.sh/docs/configure-fx/models.md#ultrafast-mode) is an explicit opt-in to a higher-priced OpenAI tier through AI Gateway. Check the selected model's [current pricing](https://vercel.com/ai-gateway/models) before enabling it. Main-agent and eligible subagent requests can both use the tier. The footer's single yellow lightning marker and `ultrafast_requested` report what fx requested, not a billing guarantee. When Gateway does not confirm that it served Ultrafast, fx warns that the response may have used a standard or lower tier. Check Gateway's billed usage for the charge; missing confirmation does not mean the request was free. Session titles, permission reviews, and context compaction do not inherit Ultrafast. ## Prompt caching On supported models, fx reuses shared instructions across workspaces and worktrees. Branch changes, permission changes, newly read folder rules, and resumed conversations preserve earlier conversation content for prompt caching. Named skills send their full instructions with the turn that invokes them instead of adding them to every later request. Cache use and savings depend on the model and provider. ### Cache warming Claude's prompt cache keeps a conversation for 5 minutes after the last request that read or wrote it. While a Claude conversation through AI Gateway waits for your next message or for a long tool run, in the terminal or `fx acp`, fx keeps the cache warm: it resends the last request with a one-token reply limit, which reads the cached conversation and starts its 5 minutes again. The first resend goes out 4.5 minutes after the request, a tenth of the cache's lifetime before it expires, and the next ones follow every 4.5 minutes, for up to 30 minutes after the request. That is at most six resends per pause. Each resend reads the conversation at Anthropic's cache-read price, a tenth of the input price, instead of writing it again at the cache-write price, 1.25 times the input price. Its tokens count toward the session's usage. Warming stops: - When you send your next message, start a new conversation with `/new` or `/clear`, or quit fx. - 30 minutes after the last request. - When a resend fails, or writes the cache instead of reading it because the provider dropped the entry. - When the computer sleeps through a resend. A resend more than 15 seconds late could arrive after the cache expired and pay for a full write. fx doesn't warm subagent requests, requests through a Codex or Grok sign-in or a custom connection, or requests that use a credential supplied by the app hosting fx. It also skips Claude models that use a fixed thinking budget instead of effort levels when thinking is on, because a one-token reply limit doesn't stop them from thinking. To turn warming off, run `fx config set cache_warming false`, or set `cache_warming: false` in your [profile](https://fx.sh/docs/configure-fx/configuration.md#agent-and-model-settings). ## Additional model requests These features can make requests in addition to the main conversation: | Feature | When it runs | | --- | --- | | [Auto mode](https://fx.sh/docs/configure-fx/permissions.md#auto-mode) | A tool action needs a model review. | | [Subagents](https://fx.sh/docs/capabilities/subagents.md) | Each subagent makes its own model requests. | | [Vision fallback](https://fx.sh/docs/capabilities/vision.md#how-vision-works) | AI Gateway analyzes images for a model without image input. | | [Context compaction](https://fx.sh/docs/using-fx/context-compaction.md) | fx summarizes older context automatically or through `/compact`. | | [Session titles](https://fx.sh/docs/using-fx/sessions.md#session-titles) | fx generates a title from the first prompt. | | [Cache warming](#cache-warming) | A Claude conversation through AI Gateway waits for your next message or a long tool run. | | [Resent replies](https://fx.sh/docs/using-fx/troubleshooting.md#a-reply-runs-out-of-output-tokens) | A reply runs out of output tokens before any text, or the provider stops it for another reason before any text or tool call, and fx asks the model once more. | To turn off session titles, set `session_titles: false` in your profile or use `/settings`. [Web search](https://fx.sh/docs/capabilities/web-search.md) can also add provider charges. ## Check your AI Gateway balance With AI Gateway selected, check the balance for the active credential: ```bash fx credits ``` `fx balance` is an alias, and `--json` returns structured output. In a session, run `/credits` or `/balance`. For billing details, open your [AI Gateway dashboard](https://vercel.com/ai-gateway). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Data and privacy" description: "Understand what leaves your machine and what fx stores locally." canonical_url: https://fx.sh/docs/using-fx/data-and-privacy markdown_url: https://fx.sh/docs/using-fx/data-and-privacy.md --- # Data and privacy Conversations and settings are saved locally. To answer a request, fx sends the relevant context to your selected provider. Networked tools send data to the services they use. ## Model request data Each model request includes your prompt and the context assembled for that turn. Context can include conversation history, applicable `AGENTS.md` and skill instructions, attached images, and file or tool content already loaded into the session. fx does not automatically package or upload your workspace, Git history, session files, traces, or recordings. That data can still leave the machine when it is loaded into model context or sent by a networked tool. [Context compaction](https://fx.sh/docs/using-fx/context-compaction.md) sends older prompts, responses, tool calls, and tool results to the current session model for summarization. On AI Gateway, when that model can't write the summary, fx can send the same request to a model from another provider family: `anthropic/claude-sonnet-5`, or `openai/gpt-6-sol` when the session uses an Anthropic model. Reviews in `auto` mode, vision fallback, and generated session titles can also make additional model requests. Titles use up to 2 KiB of the first prompt; disable them with `session_titles: false`. While a Claude conversation through AI Gateway waits, cache warming resends its last request for up to 30 minutes; disable it with `cache_warming: false`. See [Additional model requests](https://fx.sh/docs/using-fx/usage-and-costs.md#additional-model-requests). <span id="inference-apis" /> ## Where requests go Your selected connection determines where model requests go: | Connection | Where fx sends model context | | --- | --- | | Codex | The service associated with your ChatGPT subscription | | Grok | The service associated with your Grok subscription | | AI Gateway | Gateway, which forwards the request to the selected model provider | | Custom connection | The endpoint configured in `base_url` | Remote requests are subject to the selected service’s data controls and retention policy. MCP servers and web search send requests to their own services. Reviews in `auto` mode send the pending action and context from the conversation to the selected connection's reviewer. With an AI Gateway connection whose [`review_model`](https://fx.sh/docs/configure-fx/permissions.md#auto-mode) is `typesafeai/jev`, fx sends reviews to TypeSafe directly when `TYPESAFE_API_KEY` is set, and through Gateway otherwise. ## Local credentials and sessions fx stores settings, saved sign-ins, conversations, prompt history, a cache of the usage your provider reports, MCP configuration, and installed skills under `~/.fx/`, or under the folder `FX_HOME` names when it is set. fx creates that folder with access for your user account only. Opt-in [debug logs](https://fx.sh/docs/using-fx/share-feedback.md#turn-on-a-debug-log) and [recordings](https://fx.sh/docs/using-fx/share-feedback.md#record-a-terminal-issue) also go there by default. To stop saving prompt history, set `prompt_history.enabled` to `false`. On macOS, your Vercel sign-in and a saved AI Gateway API key live in Keychain, which `FX_HOME` does not change. On Linux, they are the files `~/.fx/auth.json` and `~/.fx/api-key`, with `0600` permissions. Setting `FX_DISABLE_KEYCHAIN=1` keeps the Vercel sign-in in `~/.fx/auth.json` on macOS too, and turns off stored API keys on every platform. ChatGPT and Grok sign-ins are always files: `~/.fx/chatgpt-auth.json` and `~/.fx/grok-auth.json`. MCP OAuth credentials also use Keychain on macOS when available; see [OAuth configuration](https://fx.sh/docs/capabilities/mcp/protocol.md#oauth-configuration) for the file fallback. Session files remain local, but fx sends the relevant conversation context again when you continue a session. Use [`fx ask --no-save`](https://fx.sh/docs/using-fx/fx-ask.md#use-fx-ask-in-scripts) when a one-off request should not create a session. ## Product telemetry fx does not send product telemetry or usage analytics to a separate fx service. `/usage` and `fx usage` read usage from your selected provider with your sign-in, and `/trace` assembles diagnostics locally. ## Update checks Automatic updates are on by default. Native fx reads static release metadata from `releases.fx.sh` shortly after startup and every 30 minutes until an update is ready. The request contains no fx-generated machine or installation identifier. To turn automatic updates and their checks off, set `auto_upgrade` to `false` in `~/.fx/settings.json`, or set `FX_AUTO_UPGRADE=0`. ## Local inference Use a [custom connection](https://fx.sh/docs/configure-fx/custom-model-connections.md) to send model requests to a local server such as Ollama. Update checks, web search, and remote MCP servers can still contact external services. ## Sharing diagnostics [`/trace`](https://fx.sh/docs/using-fx/share-feedback.md#create-a-private-diagnostic-trace) writes a diagnostic report to a local temporary file and, on macOS, copies the file to your clipboard. [`/feedback`](https://fx.sh/docs/using-fx/share-feedback.md#report-a-problem) opens the feedback form without uploading diagnostic data. To [share a trace as a link](https://fx.sh/docs/using-fx/share-feedback.md#share-a-trace-as-a-link), [fx.sh/share](https://fx.sh/share) redacts and encrypts it in your browser and uploads only the encrypted text. The decryption key stays in the part of the link after `#`, which your browser never sends to fx.sh. Anyone with the link can read the redacted trace until the link expires, 7 days after you create it. Review and redact prompts, code, paths, commands, model output, and secrets before sharing a trace or recording. See [Share feedback](https://fx.sh/docs/using-fx/share-feedback.md) for details. ## AI Gateway controls For a Gateway connection, account and team settings apply to requests from fx. See Gateway's [Zero Data Retention settings](https://vercel.com/docs/ai-gateway/security-and-compliance/zdr) for its routing and retention controls. Those settings apply to Gateway requests, not to separate Codex or Grok connections. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Share feedback" description: "Report an fx problem and collect private diagnostics for terminal issues." canonical_url: https://fx.sh/docs/using-fx/share-feedback markdown_url: https://fx.sh/docs/using-fx/share-feedback.md --- # Share feedback Report a problem with `/feedback`. For rendering or interaction bugs, you can attach a trace or terminal recording to help reproduce it. ## Report a problem Inside the interactive shell: ```bash /feedback ``` The command opens [fx.sh/feedback](https://fx.sh/feedback), which goes to the fx issue form on GitHub. If fx can't open a browser, open that address yourself. Include what happened, what you expected, and the steps to reproduce the problem. ## Create a private diagnostic trace Inside the interactive shell: ```bash /trace ``` `/trace` writes a Markdown report to an `fx-trace-*.md` file in your temporary directory, readable only by you. It includes the fx version and platform, the model, permission mode, workspace path, session ID, recent tool calls, network and renderer diagnostics, and the transcript with obvious secrets masked. When a [debug log](#turn-on-a-debug-log) is on, the report also includes the log's most recent lines. On macOS, `/trace` copies the file to the clipboard; on other platforms, it prints the saved path. Paste or attach the reviewed trace in the issue form's **Trace** field, or share it as a link. Traces, debug logs, and recordings stay local until you share them. They can contain prompts, code, paths, and secrets, so remove anything private before attaching them. ### Share a trace as a link [fx.sh/share](https://fx.sh/share) turns a trace into a link that shows it the way fx does: 1. Open [fx.sh/share](https://fx.sh/share) and paste the `/trace` output, or drop the `.md` file onto the page. On macOS, `/trace` copies the file itself, so drop it or open it and copy its text. Traces up to 1 MB are supported. 2. Review the highlighted redactions. The page replaces home directory names, known credential formats, sensitive URL parameters, long random-looking tokens, email addresses, IP addresses, phone numbers, and card and social security numbers with placeholders. Keep any value you want to show. 3. Choose **create secret link**, then put the link in your report. Your browser encrypts the redacted text before uploading it. The decryption key is the part of the link after `#`, which your browser never sends to fx.sh, so a lost link can't be recovered. Anyone with the link can read the redacted trace, and the link expires 7 days after you create it. ## Record a terminal issue Start fx with recording enabled, then reproduce the problem: ```bash FX_DEBUG_RECORD=1 fx ``` fx shows the recording path in the transcript and writes a private `.fxtape` file under `~/.fx/recordings/`. Choose an explicit path with `FX_RECORD`, which overwrites any file already at that path: ```bash FX_RECORD=./repro.fxtape fx ``` Add `FX_DEBUG_RECORD_SILENT_BANNER=1` to keep the recording notice out of the inline transcript during a screen share. Recording stays on, and the notice still appears in [Full detail](https://fx.sh/docs/using-fx/keyboard-shortcuts.md#full-detail), which `ctrl+o` opens. Recordings capture everything fx draws on screen, including the prompt text you type, plus resizes, interrupts, and markers. Set `FX_RECORD_INPUT=1` only when the fx team needs raw terminal input to reproduce the issue. ### Replay a recording Exit fx, then replay the recording to confirm that it captures the issue: ```bash fx replay ./repro.fxtape ``` ## Turn on a debug log Start fx with `FX_TRACE=1` to write a debug log to `~/.fx/logs/trace.log`: ```bash FX_TRACE=1 fx ``` To choose the file, set `FX_TRACE_LOG` to its path instead. A relative path is relative to the workspace. While a log is on, `/trace` includes its most recent lines. ## Check your setup first For startup or session problems, run: ```bash fx doctor ``` When fx can recover a session problem, the output includes the command to run. [Troubleshooting](https://fx.sh/docs/using-fx/troubleshooting.md) covers the problems it reports most often. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Overview" description: "Run the fx agent from JavaScript in Node.js or the browser." canonical_url: https://fx.sh/docs/lib markdown_url: https://fx.sh/docs/lib.md --- # Overview <span id="embed-fx" /> `libfx` is the fx agent as a JavaScript library. You give it a model, instructions, and your own tools, and it runs the conversation: the model loop, streaming, tool calls, retries, steering, and images. It's the same engine that runs fx in your terminal, as a native addon in Node.js on macOS and Linux, and as WebAssembly everywhere else. Its sessions are durable. libfx stores each prompt before it accepts it and each step of a turn as it runs, so when a server crashes, a deploy replaces it, or a function reaches its time limit mid-reply, the next process continues the turn where it stopped. ```js import { createFxAgent } from 'libfx' const agent = createFxAgent({ model: 'anthropic/claude-haiku-5.5' }) const turn = agent.session().prompt('What is an agent loop?') for await (const event of turn) { if (event.type === 'text_delta') process.stdout.write(event.delta) } await agent.close() ``` ## How it fits together | Object | What it is | How long it lives | | --- | --- | --- | | Agent | Configuration: model, instructions, tools, provider, and where sessions live | As long as the server process | | Session | One conversation | As long as its store keeps it | | Turn | One prompt and everything the agent does to answer it | Until it ends | Create the agent once, with the same options on every server, and open a session for each conversation. Any process with that agent can run, continue, or stream any of its sessions. An app can have [several agents](https://fx.sh/docs/lib/durability.md#several-agents), each with its own name, model, and tools. For one conversation with no store, `createFxEngine()` runs the engine directly. See [Save and restore](https://fx.sh/docs/lib/checkpoints.md). ## What libfx can do - [Stream replies and tool activity](https://fx.sh/docs/lib/prompts.md) to a terminal or a browser, and reconnect from any server. - Call your [JavaScript functions](https://fx.sh/docs/lib/tools.md) to query data, update records, or run commands. - [Keep sessions running](https://fx.sh/docs/lib/durability.md) through crashes, deploys, and function timeouts. - Run on AI Gateway, a user's ChatGPT or Grok plan, or a server that speaks the OpenAI Chat Completions API. See [Providers](https://fx.sh/docs/lib/providers.md). - Send [images](https://fx.sh/docs/lib/images.md) to models with image input. - [Steer a running turn](https://fx.sh/docs/lib/steering.md) with new instructions. - Connect [MCP tools](https://fx.sh/docs/lib/mcp.md) and [skills](https://fx.sh/docs/lib/skills.md). - [Save a conversation and restore it](https://fx.sh/docs/lib/checkpoints.md) somewhere else. - Observe model requests, tool calls, and session storage with [instrumentation hooks](https://fx.sh/docs/lib/api.md#instrumentation). - Run the [fx terminal in a web page](https://fx.sh/docs/lib/terminal.md). <span id="install" /> <span id="connect-a-model" /> <span id="run-an-agent" /> ## Get started Follow the [Quick start](https://fx.sh/docs/lib/quick-start.md) to install libfx, connect a model, and send your first prompt. The [examples](https://fx.sh/docs/lib/examples.md) include Node.js, browser, Next.js, and Nuxt projects. <span id="choose-a-guide" /> <span id="embed-the-terminal" /> ## Runtimes - [Node.js](https://fx.sh/docs/lib/node.md): native addon, WebAssembly fallback, and server frameworks. - [WebAssembly](https://fx.sh/docs/lib/webassembly.md): run the agent or the fx terminal in the browser. ## Version compatibility These guides use libfx 0.0.16. To upgrade from 0.0.15, see [Migrating from 0.0.15](https://fx.sh/docs/lib/node.md#migrating-from-0015). For earlier versions, see [Migrating from 0.0.14](https://fx.sh/docs/lib/node.md#migrating-from-0014). In 0.0.13 and earlier, `createFxAgent()` created what is now `createFxEngine()`. See [Migrating from 0.0.13](https://fx.sh/docs/lib/node.md#migrating-from-0013). --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Quick start" description: "Install libfx and stream your first reply." canonical_url: https://fx.sh/docs/lib/quick-start markdown_url: https://fx.sh/docs/lib/quick-start.md --- # Quick start Run an agent from Node.js with an AI Gateway key. For browser setup, see [WebAssembly](https://fx.sh/docs/lib/webassembly.md). ## Install Use Node.js 20.19 or later in the 20.x line, or Node.js 22.12 or later (`^20.19.0 || >=22.12.0`): ```sh npm install libfx@0.0.16 ``` ## Connect a model libfx sends model requests through AI Gateway by default. Open the [API Keys page](https://vercel.com/d?title=AI+Gateway+API+Keys&to=%2F%5Bteam%5D%2F~%2Fai-gateway%2Fapi-keys), click **Create key**, name the key, and copy its value. In your terminal, replace `your-api-key` with the copied value: ```sh export AI_GATEWAY_API_KEY="your-api-key" ``` libfx reads this variable, so you don't pass the key in code. On Vercel, it uses the deployment's OIDC token instead. To run on a user's ChatGPT or Grok plan, or on another server, see [Providers](https://fx.sh/docs/lib/providers.md). ## Run an agent Save this as `agent.mjs`: ```js import { createFxAgent } from 'libfx' const agent = createFxAgent() const turn = agent.session().prompt('Explain closures in two sentences.') for await (const event of turn) { if (event.type === 'text_delta') process.stdout.write(event.delta) } const { sessionId } = await turn.accepted process.stdout.write(`\n\nsession ${sessionId}\n`) await agent.close() ``` Run it in the same terminal where you set the key: ```sh node agent.mjs ``` The reply streams to your terminal, followed by the session's id. libfx stored the session in your system's temporary directory, so another process can continue it with `agent.session(sessionId).prompt(...)`. ## Next steps - [Prompts and streaming](https://fx.sh/docs/lib/prompts.md): continue a conversation and stream it to a browser. - [Tools](https://fx.sh/docs/lib/tools.md): give the agent JavaScript functions to call. - [Durability](https://fx.sh/docs/lib/durability.md): run sessions on Vercel and survive crashes. - [Examples](https://fx.sh/docs/lib/examples.md): run a complete project. --- [Browse all fx documentation](https://fx.sh/llms.txt) --- --- title: "Examples" description: "Build with libfx in Node.js, the browser, Next.js, and Nuxt." canonical_url: https://fx.sh/docs/lib/examples markdown_url: https://fx.sh/docs/lib/examples.md --- # Examples Four small applications built with libfx. Each includes source, a live demo, and a prompt you can copy with the code and setup instructions. The source lives in the [fx examples](https://github.com/vercel-labs/fx/tree/5245be440704093309e79422e2e2d23b54f4f2c1/examples). These applications pin published libfx 0.0.16 and use Node.js 24. Each uses `createFxEngine()` for one conversation. Follow the dependency version included with each example. For local runs, configure the [SDK model connection](https://fx.sh/docs/lib/quick-start.md#connect-a-model) described in the setup instructions. ## Node.js readline chat A command-line chat built with Node.js and [libfx](https://fx.sh/docs/lib/node.md). It keeps the conversation open for follow-up questions and prints replies as they arrive. The live demo is a single-prompt browser version. > Build a Node.js readline chat with libfx. Keep one agent for the conversation, stream text to stdout, and close it on exit. Use the files below as a starting point. # Node.js readline chat [Source](https://github.com/vercel-labs/fx/tree/5245be440704093309e79422e2e2d23b54f4f2c1/examples/node-chat) · [Live demo](https://fx-demo-node-chat.vercel.app) Use Node.js 24. Save the files at the paths shown below, including examples/shared. Create examples/node-chat/.env.local with your server-side AI_GATEWAY_API_KEY. ```sh cd examples/node-chat npm install npm run chat ``` ### examples/node-chat/package.json ```json { "name": "fx-demo-node-chat", "private": true, "type": "module", "scripts": { "chat": "node --env-file-if-exists=.env.local chat.mjs", "dev": "node --env-file-if-exists=.env.local server.mjs" }, "dependencies": { "libfx": "0.0.16" }, "engines": { "node": "24.x" } } ``` ### examples/node-chat/chat.mjs ```js import { createInterface } from 'node:readline' import { stdin, stdout } from 'node:process' import { createFxEngine } from 'libfx' const agent = await createFxEngine({ apiKey: process.env.AI_GATEWAY_API_KEY, model: 'openai/gpt-4.1-nano', }) const input = createInterface({ input: stdin, output: stdout, prompt: 'You: ' }) try { input.prompt() for await (const prompt of input) { if (prompt.trim() === '/exit') break if (!prompt.trim()) { input.prompt(); continue } stdout.write('Agent: ') const turn = agent.prompt(prompt) for await (const event of turn) { if (event.type === 'text_delta') stdout.write(event.delta) } await turn.result stdout.write('\n\n') input.prompt() } } finally { input.close() await agent.close() } ``` ### examples/node-chat/handler.mjs ```js import { createFxEngine } from 'libfx' import { model } from '../shared/model.mjs' import { errorResponse, gatewayFetch, readPrompt } from '../shared/gateway.mjs' export async function POST(request) { try { const prompt = await readPrompt(request) const agent = await createFxEngine({ apiKey: process.env.AI_GATEWAY_API_KEY, model, fetch: gatewayFetch }) async function* reply() { try { const turn = agent.prompt(prompt, { signal: request.signal }) for await (const event of turn) { if (event.type === 'text_delta') yield event.delta } await turn.result } finally { await agent.close() } } return new Response(ReadableStream.from(reply()).pipeThrough(new TextEncoderStream()), { headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' }, }) } catch (error) { return errorResponse(error) } } ``` ### examples/node-chat/server.mjs ```js import { createServer } from 'node:http' import { readFile } from 'node:fs/promises' import { Readable } from 'node:stream' import { pipeline } from 'node:stream/promises' import { POST } from './handler.mjs' const html = await readFile(new URL('./index.html', import.meta.url)) const replyReader = await readFile(new URL('../shared/read-reply.mjs', import.meta.url)) createServer(async (incoming, outgoing) => { if (incoming.method === 'GET' && incoming.url === '/read-reply.mjs') { outgoing.writeHead(200, { 'content-type': 'text/javascript; charset=utf-8' }).end(replyReader) return } if (incoming.method === 'GET' && incoming.url === '/') { outgoing.writeHead(200, { 'content-type': 'text/html; charset=utf-8' }).end(html) return } if (incoming.method !== 'POST' || incoming.url !== '/api/chat') { outgoing.writeHead(404).end('Not found') return } const controller = new AbortController() outgoing.on('close', () => controller.abort()) try { const request = new Request('http://localhost/api/chat', { method: 'POST', headers: incoming.headers, body: Readable.toWeb(incoming), duplex: 'half', signal: controller.signal, }) const response = await POST(request) outgoing.writeHead(response.status, Object.fromEntries(response.headers)) await pipeline(Readable.fromWeb(response.body), outgoing) } catch { outgoing.destroy() } }).listen(Number(process.env.PORT ?? 3000)) ``` ### examples/node-chat/index.html ```html <!doctype html> <html lang="en"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Node.js agent · fx examples

Node.js agent

A native libfx agent. Each request starts a new conversation.




Code and setup

``` ### examples/shared/model.mjs ```js export const model = 'openai/gpt-4.1-nano' ``` ### examples/shared/gateway.mjs ```js import { model } from './model.mjs' function fail(status, message) { throw Object.assign(new Error(message), { status }) } export async function readJson(request) { const reader = request.body?.getReader() if (!reader) fail(400, 'Send a JSON request body.') const chunks = [] let size = 0 try { while (true) { const { value, done } = await reader.read() if (done) break size += value.byteLength if (size > 32768) { await reader.cancel() fail(413, 'This conversation is too long. Start a new one.') } chunks.push(value) } } finally { reader.releaseLock() } const bytes = new Uint8Array(size) let offset = 0 for (const chunk of chunks) { bytes.set(chunk, offset) offset += chunk.byteLength } try { return JSON.parse(new TextDecoder().decode(bytes)) } catch { fail(400, 'Send valid JSON.') } } export async function readPrompt(request) { const body = await readJson(request) const prompt = typeof body?.prompt === 'string' ? body.prompt.trim() : '' if (!prompt || prompt.length > 2000) fail(400, 'Enter a prompt of 1–2,000 characters.') return prompt } // All public examples share this transport policy; the agent code stays in each example. export async function gatewayFetch(input, init) { const request = new Request(input, init) const url = new URL(request.url) const catalog = url.pathname === '/coding-agent/v1/models' && request.method === 'GET' const generation = url.pathname === '/v4/ai/language-model' && request.method === 'POST' if (url.origin !== 'https://ai-gateway.vercel.sh' || url.search || (!catalog && !generation)) { fail(404, 'Unknown model endpoint.') } const key = process.env.AI_GATEWAY_API_KEY if (!key) fail(503, 'The demo is not configured yet.') let body if (generation) { const input = await readJson(request) const prompt = input?.prompt if (!Array.isArray(prompt) || !prompt.length || prompt.length > 40) fail(400, 'Invalid conversation.') for (const message of prompt) { if (!message || !['system', 'user', 'assistant'].includes(message.role)) fail(400, 'Only text messages are supported.') if (message.role === 'system' && typeof message.content === 'string') continue if (!Array.isArray(message.content) || !message.content.every( (part) => part?.type === 'text' && typeof part.text === 'string', )) fail(400, 'Only text messages are supported.') } body = JSON.stringify({ prompt, maxOutputTokens: 512 }) } const headers = new Headers({ authorization: `Bearer ${key}`, 'content-type': 'application/json' }) if (generation) { headers.set('ai-language-model-id', model) headers.set('ai-language-model-streaming', 'true') } for (const name of ['ai-gateway-protocol-version', 'ai-language-model-specification-version']) { const value = request.headers.get(name) if (value) headers.set(name, value) } return fetch(new Request(url, { method: request.method, headers, body, redirect: 'error', signal: AbortSignal.any([request.signal, AbortSignal.timeout(30000)]), })) } export function errorResponse(error) { const status = Number.isInteger(error?.status) ? error.status : 502 return new Response(status < 500 ? error.message : 'The demo could not respond. Try again shortly.', { status, headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' }, }) } ``` ### examples/shared/read-reply.mjs ```js export async function* readReply(response) { const reader = response.body.getReader() const decoder = new TextDecoder() let finished = false try { while (!finished) { const { value, done } = await reader.read() finished = done const text = decoder.decode(value, { stream: !done }) if (text) yield text } } finally { if (!finished) await reader.cancel().catch(() => {}) reader.releaseLock() } } ``` For public deployment, keep the shared demo key on the server and configure an API key budget and per-IP request limits. The shared transport bounds model requests; it does not implement your application’s authentication. ## Browser agent A browser chat built with libfx and [WebAssembly](https://fx.sh/docs/lib/webassembly.md), using plain HTML without CSS or a UI framework. Use the free demo tokens or enter your own AI Gateway key to connect directly. > Build a browser agent with libfx and WebAssembly using plain HTML without CSS. Use the free-token proxy by default. Let visitors enter an AI Gateway API key to connect directly, without sending their key to the proxy or saving it. Start a new conversation when the key changes. Use the files below as a starting point. # Browser agent [Source](https://github.com/vercel-labs/fx/tree/5245be440704093309e79422e2e2d23b54f4f2c1/examples/browser-agent) · [Live demo](https://fx-demo-browser-agent.vercel.app) Use Node.js 24. Save the files at the paths shown below, including examples/shared. Enter your AI Gateway API key in the page to connect directly. No server key is needed. To run the free-token proxy locally instead, set AI_GATEWAY_API_KEY in .env.local and use npx vercel dev. ```sh cd examples/browser-agent npm install npm run dev ``` ### examples/browser-agent/package.json ```json { "name": "fx-demo-browser-agent", "private": true, "type": "module", "scripts": { "dev": "vite", "build": "vite build" }, "dependencies": { "libfx": "0.0.16" }, "devDependencies": { "vite": "8.2.4" }, "engines": { "node": "24.x" } } ``` ### examples/browser-agent/index.html ```html Browser agent · fx examples

Browser agent

libfx runs in this browser through WebAssembly. Reload to start a new conversation.


Leave blank to use our proxy with some free tokens. Enter your own key to connect directly to AI Gateway using your balance. Your key is not saved. Changing it starts a new conversation.

Get an AI Gateway API key




Code and setup

``` ### examples/browser-agent/main.js ```js import { createFxEngine, supportsJspi } from 'libfx/browser' import { model } from '../shared/model.mjs' const form = document.querySelector('form') const button = document.querySelector('button') const reply = document.querySelector('#reply') const status = document.querySelector('#status') const keyInput = document.querySelector('#api-key') let agent let activeKey if (!supportsJspi()) { status.textContent = 'This browser does not support WebAssembly JSPI. Try desktop Chrome or Edge.' button.disabled = true } form.addEventListener('submit', async (event) => { event.preventDefault() const apiKey = keyInput.value.trim() button.disabled = true keyInput.disabled = true reply.value = '' status.textContent = 'Replying…' try { if (apiKey !== activeKey) { await agent?.close() agent = undefined } agent ??= await createFxEngine({ apiKey: apiKey || 'demo', model, fetch(url, init) { if (apiKey) return fetch(url, init) const path = new URL(url).pathname return fetch(`/api/gateway?path=${encodeURIComponent(path)}`, init) }, }) activeKey = apiKey const turn = agent.prompt(new FormData(form).get('prompt')) for await (const event of turn) { if (event.type === 'text_delta') reply.value += event.delta } const { stopReason } = await turn.result status.textContent = stopReason === 'refused' ? 'Request failed. See the reply for details.' : 'Reply complete.' } catch (error) { status.textContent = error.message === 'HostStreamFailed' ? 'Unable to connect to AI Gateway. Check your key and connection.' : error.message } finally { button.disabled = false keyInput.disabled = false } }) window.addEventListener('pagehide', () => { void agent?.close() }) button.disabled = !supportsJspi() ``` ### examples/browser-agent/api/gateway.js ```js import { errorResponse, gatewayFetch } from '../../shared/gateway.mjs' export default { async fetch(request) { try { const path = new URL(request.url).searchParams.get('path') const paths = ['/coding-agent/v1/models', '/v4/ai/language-model'] if (!paths.includes(path)) return new Response('Not found', { status: 404 }) const upstream = await gatewayFetch(new Request(`https://ai-gateway.vercel.sh${path}`, request)) return new Response(upstream.body, { status: upstream.status, headers: { 'content-type': upstream.headers.get('content-type') ?? 'text/plain', 'cache-control': 'no-store' }, }) } catch (error) { return errorResponse(error) } }, } ``` ### examples/shared/model.mjs ```js export const model = 'openai/gpt-4.1-nano' ``` ### examples/shared/gateway.mjs ```js import { model } from './model.mjs' function fail(status, message) { throw Object.assign(new Error(message), { status }) } export async function readJson(request) { const reader = request.body?.getReader() if (!reader) fail(400, 'Send a JSON request body.') const chunks = [] let size = 0 try { while (true) { const { value, done } = await reader.read() if (done) break size += value.byteLength if (size > 32768) { await reader.cancel() fail(413, 'This conversation is too long. Start a new one.') } chunks.push(value) } } finally { reader.releaseLock() } const bytes = new Uint8Array(size) let offset = 0 for (const chunk of chunks) { bytes.set(chunk, offset) offset += chunk.byteLength } try { return JSON.parse(new TextDecoder().decode(bytes)) } catch { fail(400, 'Send valid JSON.') } } export async function readPrompt(request) { const body = await readJson(request) const prompt = typeof body?.prompt === 'string' ? body.prompt.trim() : '' if (!prompt || prompt.length > 2000) fail(400, 'Enter a prompt of 1–2,000 characters.') return prompt } // All public examples share this transport policy; the agent code stays in each example. export async function gatewayFetch(input, init) { const request = new Request(input, init) const url = new URL(request.url) const catalog = url.pathname === '/coding-agent/v1/models' && request.method === 'GET' const generation = url.pathname === '/v4/ai/language-model' && request.method === 'POST' if (url.origin !== 'https://ai-gateway.vercel.sh' || url.search || (!catalog && !generation)) { fail(404, 'Unknown model endpoint.') } const key = process.env.AI_GATEWAY_API_KEY if (!key) fail(503, 'The demo is not configured yet.') let body if (generation) { const input = await readJson(request) const prompt = input?.prompt if (!Array.isArray(prompt) || !prompt.length || prompt.length > 40) fail(400, 'Invalid conversation.') for (const message of prompt) { if (!message || !['system', 'user', 'assistant'].includes(message.role)) fail(400, 'Only text messages are supported.') if (message.role === 'system' && typeof message.content === 'string') continue if (!Array.isArray(message.content) || !message.content.every( (part) => part?.type === 'text' && typeof part.text === 'string', )) fail(400, 'Only text messages are supported.') } body = JSON.stringify({ prompt, maxOutputTokens: 512 }) } const headers = new Headers({ authorization: `Bearer ${key}`, 'content-type': 'application/json' }) if (generation) { headers.set('ai-language-model-id', model) headers.set('ai-language-model-streaming', 'true') } for (const name of ['ai-gateway-protocol-version', 'ai-language-model-specification-version']) { const value = request.headers.get(name) if (value) headers.set(name, value) } return fetch(new Request(url, { method: request.method, headers, body, redirect: 'error', signal: AbortSignal.any([request.signal, AbortSignal.timeout(30000)]), })) } export function errorResponse(error) { const status = Number.isInteger(error?.status) ? error.status : 502 return new Response(status < 500 ? error.message : 'The demo could not respond. Try again shortly.', { status, headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' }, }) } ``` For public deployment, keep the shared demo key on the server and configure an API key budget and per-IP request limits. The shared transport bounds model requests; it does not implement your application’s authentication. ## Next.js App Router A small Next.js App Router app that streams replies from a libfx agent running on the server. A React form lets you send a prompt and read the response. > Build a Next.js App Router app with a plain prompt form and a libfx agent in a server route. Stream the reply to the form and close the agent after each request. Use the files below as a starting point. # Next.js App Router [Source](https://github.com/vercel-labs/fx/tree/5245be440704093309e79422e2e2d23b54f4f2c1/examples/nextjs-agent) · [Live demo](https://fx-demo-nextjs-agent.vercel.app) Use Node.js 24. Save the files at the paths shown below, including examples/shared. Create examples/nextjs-agent/.env.local with your server-side AI_GATEWAY_API_KEY. ```sh cd examples/nextjs-agent npm install npm run dev ``` ### examples/nextjs-agent/package.json ```json { "name": "fx-demo-nextjs-agent", "private": true, "type": "module", "scripts": { "dev": "next dev", "build": "next build", "start": "next start" }, "dependencies": { "libfx": "0.0.16", "next": "16.4.3", "react": "19.2.4", "react-dom": "19.2.4" }, "engines": { "node": "24.x" } } ``` ### examples/nextjs-agent/next.config.mjs ```js import { fileURLToPath } from 'node:url' const examplesRoot = fileURLToPath(new URL('..', import.meta.url)) export default { turbopack: { root: examplesRoot }, outputFileTracingRoot: examplesRoot, } ``` ### examples/nextjs-agent/app/layout.js ```js export const metadata = { title: 'Next.js agent · fx examples' } export default function Layout({ children }) { return {children} } ``` ### examples/nextjs-agent/app/page.js ```js 'use client' import { useEffect, useState } from 'react' import { readReply } from '../../shared/read-reply.mjs' export default function Page() { const [reply, setReply] = useState('') const [status, setStatus] = useState('') const [busy, setBusy] = useState(false) const [ready, setReady] = useState(false) useEffect(() => setReady(true), []) async function send(event) { event.preventDefault() const prompt = new FormData(event.currentTarget).get('prompt') setBusy(true) setReply('') setStatus('Replying…') try { const response = await fetch('/api/chat', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ prompt }), }) if (!response.ok) throw new Error(response.status === 429 ? 'Request limit reached. Try again later.' : await response.text()) for await (const text of readReply(response)) setReply((previous) => previous + text) setStatus('Reply complete.') } catch (error) { setStatus(error.message) } finally { setBusy(false) } } return

Next.js agent

A native libfx agent in an App Router route. Each request starts a new conversation.