Skip to content

Run Brain synthesis on the helper model; make Memory a settings toggle - #1771

Merged
mrubens merged 3 commits into
developfrom
feat/brain-helper-model
Aug 28, 2026
Merged

Run Brain synthesis on the helper model; make Memory a settings toggle#1771
mrubens merged 3 commits into
developfrom
feat/brain-helper-model

Conversation

@mrubens

@mrubens mrubens commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Two coupled changes that remove the Brain's provider-key requirement and make Memory self-serve.

Synthesis via the deployment helper model

gbrain's gateway-mode chat now defaults to a roomote/helper sentinel model. The Brain inference gateway answers it before provider resolution: OpenAI-style messages are converted and run through generateTrackedNonTaskText with modelRole: 'small' (new brain_synthesis usage surface), so synthesis works with whatever providers the deployment already has — including Anthropic-only and trial inference — with usage tracked like every other non-task call. Details:

  • stream: true → 400 (gbrain's gateway chat is non-streaming by design); response_format json_object/json_schema honored via a strict-JSON instruction (schema inlined).
  • An operator's R_BRAIN_MODEL still wins: the sentinel body is rewritten to it and forwarded through the ordinary provider path.
  • Auth unchanged and enforced first: closed 404 with no gateway token, 401 before any body parsing, path allowlist before the sentinel branch.
  • Entrypoint: the sentinel default applies only in gateway mode; direct-provider defaults untouched. The chat model is re-derived from env every boot, so existing gateway brains converge on next boot without touching an explicit operator choice.

Memory becomes a settings toggle

New nullable deployment_settings.brain_enabled (migration 0063). isBrainEnabled() is the Brain gate now: an explicit choice wins; null falls back to the legacy provider-key signal, so existing Brains stay enabled with zero backfill. All former isBrainProviderConfigured() gate sites (brain connection resolution — which covers collectors/outbox/MCP proxy — MCP delivery, fast-agent saveMemory tool, saveTaskMemory, web commands) now flow through it; the provider-key check survives only where it genuinely means "which key serves this request" and in the run-completion outbox insert (deliberately env-only, no DB read in that transaction).

Settings → Memory gains an admin-gated enable toggle (with a note when the enabled state comes from the legacy key); disabled state collapses the page to the toggle + explanation. The Settings nav shows Memory when either the wiring or the flag is present, so a wired-but-disabled Brain can be turned on.

Known limitations (called out on purpose)

  • The Configuration section still displays the static synthesis-model default; making it gateway-aware is a follow-up.
  • /v1/responses does not answer the sentinel (gbrain's gateway chat uses chat-completions).
  • Helper responses report zero token usage to gbrain; real usage is recorded deployment-side under brain_synthesis.

Testing

brain-inference 20/20, db model-runtime-config 56/56, sdk mcp-connections 36/36, cloud-agents fast-agent 79/79, web server 21/21 + client 23/23; typecheck clean across all touched packages; entrypoint bash -n clean.

@roomote-community

roomote-community Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

No code issues found. See task

  • Default gateway helper model is not recognized (apps/api/src/handlers/brain-inference/index.ts:328). — dismissed: gbrain strips the provider prefix before calling the OpenAI-compatible gateway.

Reviewed 49eae3b

Synthesis no longer needs a Brain provider key: gbrain's gateway-mode
chat defaults to the roomote/helper sentinel, which the inference
gateway answers with the deployment's helper (small) model through the
tracked non-task path — any configured provider works, usage lands
under the brain_synthesis surface. An operator's R_BRAIN_MODEL still
wins: the sentinel is rewritten to it and forwarded normally.

Memory on/off becomes a database-backed deployment setting with an
admin toggle on the Memory settings page. A null flag falls back to the
legacy provider-key signal so existing Brains stay enabled untouched;
collectors, outbox drain, MCP exposure, and agent tools all flow
through the same gate they always did.
@mrubens
mrubens force-pushed the feat/brain-helper-model branch from bbf9514 to 645ea97 Compare August 28, 2026 06:32
// Not JSON we understand; the provider path forwards it untouched.
}

if (parsedBody?.model === BRAIN_HELPER_MODEL_ID) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entrypoint configures gateway chat with a provider-qualified sentinel (${BRAIN_PROVIDER}:roomote/helper), but this only recognizes the bare roomote/helper. When gbrain sends its configured model, the request falls through to provider resolution and forwards the nonexistent helper model instead of calling the deployment helper. Normalize or accept the qualified sentinel here, and cover the gateway-configured value in this test suite.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dismissed: gbrain parses the configured provider:model value and sends the bare model ID to its OpenAI-compatible client, so this gateway receives roomote/helper as expected.

The synthesis model is the deployment helper model now and the
embedding pair is create-time infrastructure; neither is a per-page
setting worth displaying, and the section's static model text was
already wrong for gateway-mode brains.
@mrubens
mrubens merged commit 76c1102 into develop Aug 28, 2026
18 checks passed
@mrubens
mrubens deleted the feat/brain-helper-model branch August 28, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant