new features
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
# Agents in AI Studio
|
||||
|
||||
Agents are reusable roles with separate instructions. In an agent run, AI Studio sends the task and the preceding agents’ work to each role in turn. The reviewer delivers the final response in the chat. Every role uses the model routing already selected for the chat, so you can run a team with one model.
|
||||
|
||||
## Run your first task
|
||||
|
||||
1. Open **Settings → Models** and choose your model and backend. For Ollama, refresh the server's installed models and select a tag. For MLX, select a local model folder or use **Load Model** in **Settings → Model Library**.
|
||||
2. Open **Settings → Agents**. Leave **Planner** and **Specialist** enabled for a first run.
|
||||
3. In the chat composer, turn on **Agents** and enter a task with a clear deliverable. For example, attach two design proposals and ask, “Compare both proposals against the requirements, cite the relevant sections, and draft a recommendation.”
|
||||
4. Send the message. The composer shows the current role. **Settings → Agents → Latest Run** lists the completed stages and the backend each stage reports.
|
||||
5. Read the reviewer's response in the chat. Use **Stop** to cancel an in-progress run. If the reviewer has already started streaming, the chat can retain the interrupted response.
|
||||
|
||||
Turn off **Agents** in the composer to send a regular chat message. The toggle and enabled roles are remembered across launches.
|
||||
|
||||
## Create a custom agent
|
||||
|
||||
1. Open **Settings → Agents → Custom Agents → New Agent**.
|
||||
2. Give the profile a descriptive name, up to 60 characters.
|
||||
3. Write the role instructions, up to 4,000 characters. Describe the task it owns, what evidence to use, and what the next agent should receive.
|
||||
4. Choose **Save Agent** and leave its toggle enabled.
|
||||
5. Turn on **Agents** in chat and send a task that gives the role something concrete to do.
|
||||
|
||||
AI Studio supports up to five saved custom profiles. Enabled profiles run in the order shown, after the optional built-in roles and before the reviewer. Use **Edit** to revise a role, its toggle to temporarily skip it, and **Remove** to delete it. Changes apply to future sends. The same profile can be reused across conversations.
|
||||
|
||||
Here is a profile you can enter in the editor.
|
||||
|
||||
**Name**
|
||||
Technical Editor
|
||||
|
||||
**Instructions**
|
||||
Compare the draft to the user's source material. Preserve public API names and code examples unless the prompt asks to change them. Check terminology for consistency. Hand off an edited draft and a short list of factual claims the reviewer should double-check. Flag any claim for which the source material is missing.
|
||||
|
||||
Other roles can use the same pattern. A **Requirements Analyst** might turn reference material into acceptance criteria. An **Evidence Checker** might review a draft against attached documents and list unsupported claims. A **Release Note Editor** might write a user-facing summary from notes you provide and mark missing version or date information.
|
||||
|
||||
### Built-in roles
|
||||
|
||||
| Role | Work |
|
||||
| --- | --- |
|
||||
| Planner | Breaks down the request and identifies constraints, evidence, and an approach. |
|
||||
| Specialist | Develops the draft and flags gaps. It can request a connected MCP tool when enabled. |
|
||||
| Reviewer | Checks the handoffs against the request and writes the final reply. |
|
||||
|
||||
For a shorter run, disable the planner or specialist, or enable only the custom profiles the task needs. The reviewer always runs when Agents is on. All three built-in profiles have an **Edit** button for their name and instructions. **Restore Default** resets the built-in profile. The specialist keeps its MCP approval role when renamed, and the reviewer still delivers the final reply.
|
||||
|
||||
## Give a run evidence and tools
|
||||
|
||||
Attach documents or select reference material using the regular chat controls. The stages receive the chat context and any enabled recall, excerpts, or tool attachments prepared for the request. If the run uses a remote inference server, that context and the intermediate handoffs are sent to that server.
|
||||
|
||||
For a supervised tool request in the main chat:
|
||||
|
||||
1. Connect the MCP server in **Toolbox** and check that the expected tool is listed.
|
||||
2. In **Settings → Agents**, enable the specialist and **Let the specialist request an MCP tool**.
|
||||
3. Start an agent run and describe the information you need, such as “Search the connected knowledge index for our Laravel authorization guidelines and summarize the relevant sources.”
|
||||
4. If the specialist requests a tool, inspect the server, tool name, and complete JSON arguments. Use **Allow Once** to execute that exact request or **Decline** to continue without it.
|
||||
5. The specialist gets the result or the denial, updates its draft, and passes that draft to subsequent roles.
|
||||
|
||||
The specialist may request one MCP call in each main-chat run. An approval applies to one invocation. Custom roles contribute reasoning and drafts. The side-by-side comparison composer supports agent reasoning and handoffs. For tool results there, run the tool in Toolbox and use its output as reference material. See [MCP setup](MCP.md) for connection details.
|
||||
|
||||
## Models, state, and run limits
|
||||
|
||||
- Each role makes one generation request, with one additional specialist request when it processes a tool outcome. Requests run sequentially within an agent run. More roles mean more latency and context. A small model or context window may work best with short reference material and fewer roles.
|
||||
- Ollama is the preferred default. With failover enabled and an MLX folder set, a stage can switch to MLX if the primary fails before committing output. An MLX-only selection runs on the Mac. Remote Ollama and the existing compatible API also work through the chat router.
|
||||
- In **Settings → Model Library**, installed Ollama sizes come from the selected server. Installed MLX sizes come from local safetensors files. MLX catalog sizes come from file metadata for the pinned Hugging Face revision, and Ollama catalog sizes come from the registry manifest for the latest tag. A row shows **Size unknown** when the source does not report the required bytes or cannot be reached. Use **Preview** for the available architecture, quantization, context length, source, and other model details. **Active** marks the configured model. **In use** identifies the reporting backend during main-chat inference, including MLX failover.
|
||||
- Agent profiles and toggles live in the app's settings. The user prompt and final reply are stored in the existing SQLite chat history. Intermediate handoffs and the latest run status are kept in memory for the session.
|
||||
- Runs are interactive while AI Studio is open. Support in this version covers sequential handoffs, cancellation, and supervised MCP. Scheduled jobs, background workers, remote agent workers, and persistent run checkpoints are outside this version's scope.
|
||||
|
||||
## If a run stalls or produces a weak draft
|
||||
|
||||
- Check the current role beside the composer. Several roles can take longer than a single reply because each stage waits for the previous one.
|
||||
- Check **Settings → Models** for the active route and selected tag or folder. Use **Refresh Installed Models** when an Ollama server has changed.
|
||||
- If an approval appears, choose **Allow Once** or **Decline** to resume the run. If a required tool is absent, confirm it is connected in Toolbox and available to the specialist.
|
||||
- Use a smaller set of enabled roles and shorten large attachments if the backend runs out of context. Give each role a distinct responsibility and require a concrete output.
|
||||
- When a stage fails, check the chat status for the backend error and **Latest Run** for the last completed stage. After correcting the issue, send the task again.
|
||||
|
||||
## How execution is wired
|
||||
|
||||
The SwiftUI composer takes a snapshot of the enabled roles when you send. The chat model builds the existing inference context, then starts the workflow inside the chat's cancellable generation task. The same inference adapter constructs each stage's request, so the backend selection, credentials, model tag or MLX path, thinking options, and generation parameters follow the regular chat path.
|
||||
|
||||
The workflow gives each role a system instruction and adds bounded handoffs to the current request as reference material. This keeps ordinary chat history separate from intermediate work and keeps the turn format usable by Ollama and MLX chat templates. Each stage forwards its backend status to the UI. The reviewer streams into the ordinary chat transcript and uses the existing SQLite save and performance reporting paths.
|
||||
|
||||
The specialist sees numbered offers drawn from connected MCP tools, capped at 20 per run. The model may return a JSON object containing an offered tool number and an arguments object. AI Studio validates the shape and checks the offer, then waits for the user decision. The approved invocation goes through the existing MCP client. The next specialist generation receives a bounded response or a denial or failure message. The tool result is treated as reference material. The specialist's MCP access comes from the connected tool servers, so the capabilities depend on those servers.
|
||||
|
||||
Profile storage is independent of the backend and uses the same persistent settings mechanism as the built-in role toggles. This lets you change inference providers without recreating profiles. For implementation and regression tests, see `AgentWorkflow` in `Sources/Inference.swift`, the chat integration in `Sources/StudioModel.swift`, and `AgentWorkflowTests` in `Tests/StudioTests.swift`. Run `Scripts/test.sh` to start the fixture servers and exercise the Xcode scheme.
|
||||
Reference in New Issue
Block a user