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

# Agent Chat

> Use the chat surface for page edits and workflow authoring requests.

The agent chat lives at `/chats/new`. It is the place to ask for workspace page edits, review the
changed-line diff, and continue authoring workflow pages.

When Supabase and WorkOS are configured, the first message creates a saved AI chat thread. Saved
threads appear under Chats in the sidebar, can be reopened at `/chats/{chatId}`, and can be archived
from the hover action in the sidebar.

## What to include

Write the request like a short operations brief. Include the details a human workflow coordinator
would need.

* Person name.
* Worker type, role, or SuccessFactors position title when the workflow asks for it.
* Team or business area when relevant to the request.
* Start date.
* Leader or manager.
* Location, site, or work mode.
* Special access, training, equipment, or documents.

## Example request

```text theme={null}
I need a laptop replacement for Riley Brooks.
```

## What happens without keys

If `OPENAI_API_KEY` is missing, the chat uses a local fallback message. The fallback is useful for
checking the UI and local route, but it does not call the model.

## Runtime controls

Use the plus button in the chat box to add runtime tools before sending a request. Selected tools
appear as chips in the composer and are sent to the server-side Agents SDK route for that run.

Use the model profile menu beside the send button to choose the reasoning profile for the next run.
The server validates the selected model profile and tool IDs before it creates the agent.

## What happens with OpenAI configured

With `OPENAI_API_KEY`, the chat can stream a real model response through the server-side agent route.
Add the web search runtime tool when the request needs current public context, news, external
articles, or link-backed answers.

Workspace pages also have a top-right Preview button. Preview opens a side-panel chat attached to
the current page, sends the current MDX as hidden context, and keeps the user on the page while they
ask questions or describe edits. When chat persistence is configured, Preview-created threads also
appear under Chats in the sidebar and can be reopened from the main chat surface.

Workflow chats opened from page Run use the workflow page title in the main chat details panel.
Their Progress section lists each workflow node by title and shows whether the node is complete,
running, not started, or failed.

## What happens with Supabase configured

The `/tables` section shows read-only Supabase foundation and workflow tables while you are testing
chat.

Click a table row to open the row detail panel. Tool rows include the saved Agents SDK tool JSON,
including the input schema and handler metadata stored for that tool.

The chat and Preview routes write active threads to `ai_chats` and user/assistant turns to
`ai_messages`. Archiving a chat updates `ai_chats.status` to `archived`, which removes it from the
sidebar without deleting its messages.

The main chat does not auto-start durable Procedure runs right now. Use page Run or Preview when you
want to execute a workflow page. The live agent route can still use the narrow `create_person` and
`create_position_sf` runtime tools when they are selected for a model run.

Workflow run rows in `/tables/workflow-runs` open a run detail page with step status, Inngest
references, inline `@` procedure mentions, and the visible event log for that run.
