> For the complete documentation index, see [llms.txt](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_40/session_04_chat_overrides_and_runtime.md).

# Session 04: Chat Overrides And Runtime

**Session ID**: `phase40-session04-chat-overrides-and-runtime` **Status**: Not Started **Estimated Tasks**: \~12-25 **Estimated Duration**: 2-4 hours

***

## Objective

Add safe per-chat model/provider overrides and upstream-inspired streaming safeguards to the admin chat bridge and hooks.

***

## Scope

### In Scope (MVP)

* Add `model?: string` and `provider?: string` to Hermes chat send options and hook payload construction.
* Update `chatPayloadOptions` so selected models and providers are not dropped.
* Validate client and server model/provider values with bounded allowlist regex rules, including provider `moa` for preset sends.
* Pass model and provider overrides as argv entries while preserving session resume, graph, yolo, image upload, and toolset behavior.
* Port runtime safeguards where they fit AI OS: unbuffered output, terminal env, heartbeat comments, pre-output timeout, post-output idle success after output, browser disconnect cleanup, and timer cleanup.
* Implement sanitized browser `info` SSE events with parser coverage while keeping them out of normal assistant message text.

### Out of Scope

* Building the visual model selector.
* Command endpoint or command menu behavior.
* Renaming Intelligence or changing voice secrets.

***

## Prerequisites

* [ ] Session 01 decisions and invariants are recorded.
* [ ] Session 03 shared redaction helper is available for browser-visible diagnostics.
* [ ] Session 02 provider IDs and MoA preset behavior are available or their accepted values are documented.

***

## Deliverables

1. Updated chat request types, hook payload behavior, admin bridge parsing, and spawn argv construction.
2. Tests for valid override args, injection rejection, arg ordering, graph/yolo compatibility, timeout behavior, disconnect cleanup, and `info` parsing.

***

## Success Criteria

* [ ] A selected ordinary model can be sent for one chat request without mutating `~/.hermes/config.yaml`.
* [ ] A selected MoA preset sends provider `moa` and the preset name as model.
* [ ] Invalid values return controlled errors and cannot affect shell parsing.
* [ ] A pre-output hang fails, while a post-answer cleanup hang after output is treated as a successful turn.

***

## Folded Source Session Split

The section below preserves the original Phase 40 session split detail for this session, including dependencies, decisions, outputs, and acceptance checks.

### Session 04: Chat Overrides And Runtime

**Objective**: Add safe per-chat model/provider overrides and upstream-inspired streaming safeguards to the admin chat bridge and hooks.

**Scope**:

* Add `model?: string` and `provider?: string` to Hermes chat send options and hook payload construction.
* Update `chatPayloadOptions` so selected models/providers are not dropped.
* Validate client and server model/provider values with bounded allowlist regex rules, including provider `moa` for preset sends.
* Pass model and provider overrides as argv entries, preserving session resume, graph, yolo, image upload, and toolset behavior.
* Port runtime safeguards where they fit AI OS: unbuffered output, terminal env, heartbeat comments, pre-output timeout, post-output idle success after output, browser disconnect cleanup, and timer cleanup.
* Implement sanitized browser `info` SSE events with parser coverage, map them as diagnostics, and keep them out of normal assistant bubble text.
* Recheck empty-toolset behavior against current graph grounding behavior.

**Outputs**:

* Updated chat request types, hook payload behavior, admin bridge parsing, and spawn argv construction.
* Tests for valid override args, injection-shaped rejection, arg ordering, graph/yolo/toolset compatibility, timeout behavior, disconnect cleanup, and sanitized `info` event parsing.

**Dependencies / Notes**:

* Depends on Sessions 01 and 03.
* Coordinate with Session 02 so provider IDs accepted by chat match the expanded model body and MoA preset rows.

**Acceptance Checks**:

* A selected ordinary model can be sent for one chat request without changing `~/.hermes/config.yaml`.
* A selected MoA preset sends provider `moa` and the preset name as the model.
* Invalid values return controlled errors and cannot affect shell parsing.
* A pre-output hang fails, while a post-answer cleanup hang after output is treated as a successful turn.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/phases/phase_40/session_04_chat_overrides_and_runtime.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
