# Chat settings and web search

Agent authority, approval rules and network policy stay unchanged.

## State and request ownership

| Stage | Holds |
| --- | --- |
| Composer scope | Selected branch settings and callbacks |
| Persisted draft | Search intent |
| Accepted message | `SessionRunConfig` and permissions |
| Execution | Available tools and provider results |

| Boundary | Behaviour | Acceptance |
| --- | --- | --- |
| Branch controls | Search and thinking changes persist on the selected branch before the next send. A new branch inherits once. | Switch A, B, A, including within one conversation; reload restores each branch independently |
| Sandbox | Reads and writes correlate by request ID. Superseded replies are ignored, listeners abort on scope change, failed writes report without optimistic drift. | Two opposite writes, stale reads, disconnect and provisional session reads cannot overwrite the selection |
| Search intent | Off removes `web_search`. On adds it within Agent policy; mode `none` wins. A message that omits it, as the CLI and TUI do, keeps the branch's stored intent; with none stored it follows the Agent. | Resolve tools for on, off, omitted, and Agent `none`; an omitted field on a later turn keeps a stored on |
| Provider configuration | A default shows only after a confirmed save. Jina needs a key. An unavailable saved default falls to another available provider. Registration uses stable names and availability is checked per call, so a newly configured provider needs no restart. | HTTP failure keeps the old default; no-key and hot-key tests |
| Aggregation | Race returns the first non-empty success. RRF keeps timely partial results. All failures, or deadlines with no success, are errors. Running sync requests finish under their transport deadlines; queued work is cancelled. | Event-controlled providers verify early return, partial timeout, empty success, total failure, cleanup |
| Connection test | Synchronous provider work runs off the server event loop | An async response progresses while the probe is blocked |
| Provider schema | Explicit search ships its schema in the provider request, including search-only chats. Promotion copies the selected tool and keeps the shared deferred registry and Agent exclusions. | Cold-session and frozen-turn regression checks |

The composer has no Tools switch or per-chat tool profile: [Tool toggles](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/agent-configuration/tool-toggle-management.html).

**Why these mechanisms**

| Reference | Consequence |
| --- | --- |
| [React callback dependencies](https://react.dev/reference/react/useCallback) | Reactive setters are dependencies. Reuse the session stores; never remount the composer to hide stale callbacks. |
| [Python executor lifecycle](https://docs.python.org/3/library/concurrent.futures.html) | Context-manager shutdown waits. Non-waiting shutdown allows early return but cannot cancel running sync requests, so transport deadlines stay and no async provider API is added. |
| [Jina search](https://jina.ai/reader/) | Needs authenticated access, so availability follows credentials |

Regression checks use the production hooks, socket request helper, tool executor and resolver.

## Implementation status

Search execution and branch-scoped settings persistence are implemented. Regression tests cover switching, restoration and stale writes.

[Tool toggles and toolset management](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/agent-configuration/tool-toggle-management.html)
