[PR #7135] [MERGED] fix(agents): send the connection's saved generation parameters on agent calls (#7131) #7493

Closed
opened 2026-10-23 04:20:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7135
Author: @SpicyMarinara
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/agent-connection-params-7131


📝 Commits (2)

  • 7747a75 fix(agents): send the connection's saved generation parameters on agent calls
  • f90ef00 Merge branch 'staging' into fix/agent-connection-params-7131

📊 Changes

20 files changed (+1243 additions, -171 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/agents/agents-overview.md (+1 -1)
📝 docs/agents/custom-agents.md (+1 -1)
📝 docs/connections/subscription-clis.md (+1 -1)
📝 docs/prompts/generation-parameters.md (+13 -1)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+1 -3)
📝 packages/client/src/localization/locales/en.json (+1 -1)
📝 packages/server/src/routes/generate.routes.ts (+9 -20)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+32 -6)
📝 packages/server/src/services/agents/agent-executor.ts (+98 -54)
📝 packages/server/src/services/capability-packages/capability-language-model.service.ts (+35 -6)
➕ packages/server/src/services/generation/agent-generation-parameters.ts (+232 -0)
📝 packages/server/src/services/generation/agent-resolution.ts (+46 -6)
📝 packages/server/src/services/generation/illustrator-background-generation.ts (+12 -7)
📝 packages/server/src/services/generation/illustrator-manual-prompt-generation.ts (+8 -5)
📝 packages/server/src/services/generation/output-token-limits.ts (+18 -0)
📝 packages/server/src/services/generation/provider-generation-runtime.ts (+68 -41)
📝 packages/server/src/services/llm/providers/anthropic.provider.ts (+8 -17)
📝 packages/shared/src/constants/generation-parameter-relevance.ts (+2 -1)
➕ scripts/regressions/agent-connection-parameters.regression.ts (+655 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7131

Why this change

  • Agent calls ignored most of what users save under Use custom defaults for this connection. Only temperature, custom parameters, headers and the Send switches reached agents. Reasoning Effort, Top P, Top K, the penalties, Verbosity and extra parameters such as Top A were never sent.
  • Agents that answer in JSON always asked for reasoning "none", overriding a level the user picked. Some models do agent work much worse without reasoning.
  • Installed agent packages calling the model through the capability host didn't even get the connection's custom headers or custom parameters.
  • Expected: an agent call uses the parameters saved on its connection, mapped to what the model supports, and still has room to finish its answer.

What changed

  • One resolver for chat and agents. The main chat's parameter rules are split out into resolveGenerationParameters, and every agent path reuses them with the connection's settings only: single agents, JSON retries, tool rounds, Beholder lanes, batches, retries, knowledge retrieval and router, character activity, the Illustrator prompt writers, and agents on the chat's own connection.
  • Batches only share a request when all their resolved parameters match.
  • Capability host sends the connection's headers, custom parameters and extra parameters, and merges saved values over the package's request.
  • Thinking room is added for providers that count reasoning inside max tokens. It only uses context the prompt leaves free and stays within the connection's cap and the model's limit.
  • Claude:
    • thinking requests drop Top K, which Claude rejects;
    • the older thinking mode stays within the model's output limit, with the thinking budget shrinking first;
    • tool rounds send their signed thinking blocks back, so thinking stays on across tool calls;
    • the catalog's Claude Sonnet 4 output limit is corrected to 64000.

What wins over what

Setting Agents run by Marinara Installed packages (capability host)
Top P, Top K, Min P, penalties, Verbosity, Service Tier The connection's saved value, only while its Send switch is on Same. Packages can only set Verbosity themselves, and a saved, switched-on Verbosity replaces theirs
Top A, seed and other extra parameters (Settings > Advanced) From the connection From the connection
Custom parameters and headers From the connection (unchanged) Now sent. The package's own custom parameters win on clashing keys
Temperature Connection's, else 0.7. Beholder 0; Illustrator writers 0.55 / 0.35. Not sent if switched off or the model rejects sampling. During a chat reply, agents on the chat's connection keep the chat's temperature and Send switches, as before Connection's if saved and switched on, else the package's
Reasoning Effort A level or Off saved on the connection, switched on, for a model that shows Reasoning Effort, wins. Otherwise JSON agents ask for "none" and other agents send nothing, as before. Codex on Default keeps Codex's own level The connection's level wins when chosen. Switched off, nothing is sent even if the package asks. Unset, the package's own level is sent
Max output tokens The agent's own budget, plus thinking room when a level applies The package's own budget, plus thinking room when the connection raised the level. Switched off, not sent
Stop sequences, prefills, thinking tags, role formatting Never sent Never sent

Retries use the connection's saved values and Send switches, not the chat's.

Cost note: custom defaults start Reasoning Effort at Maximum (Default on Codex). Agents on such a connection now reason at the model's highest level, which is slower and costs more. The docs and changelog say how to lower it.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

What the agent ran (to be confirmed by a human):

  • pnpm check passed after merging current staging.
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/agent-connection-parameters.regression.ts passes. It records real request bodies from a local stub server, with no real provider calls, and covers:
    • Custom endpoint: samplers, Top A, custom headers, no stop sequences, no forced "none" over a chosen level, <think> stripping on text agents.
    • OpenAI / OpenRouter / Gemini / Codex: o4-mini and OpenRouter levels with room; Gemini 3 thinking level; Codex level vs Default.
    • GPT-5 verbosity: agents and packages.
    • Send switches: switched off, and unset reasoning.
    • Claude:
      • thinking with Top K dropped;
      • an Opus 4.1 batch stays within 32000;
      • a Sonnet 4 agent keeps its full budget;
      • tool rounds replay the signed thinking.
    • Other agent paths:
      • tool rounds;
      • Beholder lanes;
      • the Illustrator writer, including a small context window;
      • batches split by parameters;
      • the retry route through a real request.
    • Packages (capability host):
      • headers;
      • custom and extra parameters;
      • precedence;
      • switched-off Reasoning Effort and Max Tokens;
      • the cap at the model limit.
    • Real /api/generate call: the chat-connection agent, knowledge retrieval, knowledge router and character-activity agents send the same Top P, penalties, reasoning, Top A and custom parameter as the main reply. A value switched off on the connection stays unsent from agents even when the chat switches it on.
  • The new regression fails on the pre-change staging at its first check (Top P missing). Breaking each fix on purpose (23 in all) makes it fail every time.
  • Full regression suite: 516/516 (two load-sensitive multiplayer/shutdown tests passed when rerun alone).

Manual verification notes

  • Manually verify in the browser that an agent on a connection with custom defaults (e.g. OpenRouter, Top P on, Reasoning Effort High) sends those values: check the DEBUG_AGENTS prompt log.
  • Manually verify a JSON tracker agent on an OpenAI reasoning model with a saved level sends that level, not "none", and returns complete JSON.
  • Manually verify a batch of four or more agents on Claude Opus 4.1 or Haiku 4.5 with Reasoning Effort set completes without a 400.
  • Manually verify a tool-using agent (Spotify DJ or a custom tool agent) on a Claude connection with thinking on completes a tool round.
  • Manually verify an installed package (e.g. Long-Term Memory) on a connection with Reasoning Effort switched off doesn't send reasoning, and that custom headers reach the provider.
  • Manually verify the manual Illustrator on a small-context local endpoint with custom defaults on.
  • Manually verify the connection editor's Default Chat Parameters help text mentions chats and agents.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Notes:

  • Updated docs/prompts/generation-parameters.md, docs/agents/custom-agents.md, docs/agents/agents-overview.md, docs/connections/subscription-clis.md and CHANGELOG.md (#7131).
  • A [docs-i18n] follow-up issue for those four docs still needs to be opened.
  • en.json: ui.connections.connectioneditor.defaultGenerationSettingsForChatsThatUseThisConnection is renamed to ui.connections.connectioneditor.defaultGenerationSettingsForChatsAndAgents.

UI evidence (if applicable)

The only UI change is the connection editor help text (en.json).

Worktree: /Users/marysia/Developer/Marinara-Engine-worktrees/fix-agent-params-7131. The files changed this round:

  • packages/server/src/services/llm/providers/anthropic.provider.ts
  • packages/server/src/services/generation/agent-generation-parameters.ts
  • packages/server/src/services/agents/agent-executor.ts
  • packages/server/src/services/generation/illustrator-manual-prompt-generation.ts
  • packages/server/src/services/generation/illustrator-background-generation.ts
  • packages/server/src/services/llm/base-provider.ts
  • packages/server/src/routes/generate/retry-agents-route.ts
  • packages/shared/src/constants/model-lists.ts
  • scripts/regressions/agent-connection-parameters.regression.ts
  • docs/prompts/generation-parameters.md
  • CHANGELOG.md

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7135 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/agent-connection-params-7131` --- ### 📝 Commits (2) - [`7747a75`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7747a7510d8f4dcb22dffc508f8bcef3b98d5c22) fix(agents): send the connection's saved generation parameters on agent calls - [`f90ef00`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f90ef002f38eb01b8a0d61113cf1b5ea531cf84d) Merge branch 'staging' into fix/agent-connection-params-7131 ### 📊 Changes **20 files changed** (+1243 additions, -171 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/agents/agents-overview.md` (+1 -1) 📝 `docs/agents/custom-agents.md` (+1 -1) 📝 `docs/connections/subscription-clis.md` (+1 -1) 📝 `docs/prompts/generation-parameters.md` (+13 -1) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+1 -3) 📝 `packages/client/src/localization/locales/en.json` (+1 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+9 -20) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+32 -6) 📝 `packages/server/src/services/agents/agent-executor.ts` (+98 -54) 📝 `packages/server/src/services/capability-packages/capability-language-model.service.ts` (+35 -6) ➕ `packages/server/src/services/generation/agent-generation-parameters.ts` (+232 -0) 📝 `packages/server/src/services/generation/agent-resolution.ts` (+46 -6) 📝 `packages/server/src/services/generation/illustrator-background-generation.ts` (+12 -7) 📝 `packages/server/src/services/generation/illustrator-manual-prompt-generation.ts` (+8 -5) 📝 `packages/server/src/services/generation/output-token-limits.ts` (+18 -0) 📝 `packages/server/src/services/generation/provider-generation-runtime.ts` (+68 -41) 📝 `packages/server/src/services/llm/providers/anthropic.provider.ts` (+8 -17) 📝 `packages/shared/src/constants/generation-parameter-relevance.ts` (+2 -1) ➕ `scripts/regressions/agent-connection-parameters.regression.ts` (+655 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #7131 ## Why this change - Agent calls ignored most of what users save under **Use custom defaults for this connection**. Only temperature, custom parameters, headers and the Send switches reached agents. Reasoning Effort, Top P, Top K, the penalties, Verbosity and extra parameters such as Top A were never sent. - Agents that answer in JSON always asked for reasoning "none", overriding a level the user picked. Some models do agent work much worse without reasoning. - Installed agent packages calling the model through the capability host didn't even get the connection's custom headers or custom parameters. - Expected: an agent call uses the parameters saved on its connection, mapped to what the model supports, and still has room to finish its answer. ## What changed - **One resolver for chat and agents.** The main chat's parameter rules are split out into `resolveGenerationParameters`, and every agent path reuses them with the connection's settings only: single agents, JSON retries, tool rounds, Beholder lanes, batches, retries, knowledge retrieval and router, character activity, the Illustrator prompt writers, and agents on the chat's own connection. - **Batches** only share a request when all their resolved parameters match. - **Capability host** sends the connection's headers, custom parameters and extra parameters, and merges saved values over the package's request. - **Thinking room** is added for providers that count reasoning inside max tokens. It only uses context the prompt leaves free and stays within the connection's cap and the model's limit. - **Claude:** - thinking requests drop Top K, which Claude rejects; - the older thinking mode stays within the model's output limit, with the thinking budget shrinking first; - tool rounds send their signed thinking blocks back, so thinking stays on across tool calls; - the catalog's Claude Sonnet 4 output limit is corrected to 64000. **What wins over what** | Setting | Agents run by Marinara | Installed packages (capability host) | |---|---|---| | Top P, Top K, Min P, penalties, Verbosity, Service Tier | The connection's saved value, only while its Send switch is on | Same. Packages can only set Verbosity themselves, and a saved, switched-on Verbosity replaces theirs | | Top A, seed and other extra parameters (Settings > Advanced) | From the connection | From the connection | | Custom parameters and headers | From the connection (unchanged) | Now sent. The package's own custom parameters win on clashing keys | | Temperature | Connection's, else 0.7. Beholder 0; Illustrator writers 0.55 / 0.35. Not sent if switched off or the model rejects sampling. During a chat reply, agents on the chat's connection keep the chat's temperature and Send switches, as before | Connection's if saved and switched on, else the package's | | Reasoning Effort | A level or Off saved on the connection, switched on, for a model that shows Reasoning Effort, wins. Otherwise JSON agents ask for "none" and other agents send nothing, as before. Codex on Default keeps Codex's own level | The connection's level wins when chosen. Switched off, nothing is sent even if the package asks. Unset, the package's own level is sent | | Max output tokens | The agent's own budget, plus thinking room when a level applies | The package's own budget, plus thinking room when the connection raised the level. Switched off, not sent | | Stop sequences, prefills, thinking tags, role formatting | Never sent | Never sent | Retries use the connection's saved values and Send switches, not the chat's. **Cost note:** custom defaults start Reasoning Effort at **Maximum** (Default on Codex). Agents on such a connection now reason at the model's highest level, which is slower and costs more. The docs and changelog say how to lower it. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` What the agent ran (to be confirmed by a human): - `pnpm check` passed after merging current `staging`. - `node ./scripts/run-regressions.mjs --filter scripts/regressions/agent-connection-parameters.regression.ts` passes. It records real request bodies from a local stub server, with no real provider calls, and covers: - **Custom endpoint:** samplers, Top A, custom headers, no stop sequences, no forced "none" over a chosen level, `<think>` stripping on text agents. - **OpenAI / OpenRouter / Gemini / Codex:** o4-mini and OpenRouter levels with room; Gemini 3 thinking level; Codex level vs Default. - **GPT-5 verbosity:** agents and packages. - **Send switches:** switched off, and unset reasoning. - **Claude:** - thinking with Top K dropped; - an Opus 4.1 batch stays within 32000; - a Sonnet 4 agent keeps its full budget; - tool rounds replay the signed thinking. - **Other agent paths:** - tool rounds; - Beholder lanes; - the Illustrator writer, including a small context window; - batches split by parameters; - the retry route through a real request. - **Packages (capability host):** - headers; - custom and extra parameters; - precedence; - switched-off Reasoning Effort and Max Tokens; - the cap at the model limit. - **Real `/api/generate` call:** the chat-connection agent, knowledge retrieval, knowledge router and character-activity agents send the same Top P, penalties, reasoning, Top A and custom parameter as the main reply. A value switched off on the connection stays unsent from agents even when the chat switches it on. - The new regression fails on the pre-change `staging` at its first check (Top P missing). Breaking each fix on purpose (23 in all) makes it fail every time. - Full regression suite: 516/516 (two load-sensitive multiplayer/shutdown tests passed when rerun alone). ### Manual verification notes - [ ] Manually verify in the browser that an agent on a connection with custom defaults (e.g. OpenRouter, Top P on, Reasoning Effort High) sends those values: check the `DEBUG_AGENTS` prompt log. - [ ] Manually verify a JSON tracker agent on an OpenAI reasoning model with a saved level sends that level, not "none", and returns complete JSON. - [ ] Manually verify a batch of four or more agents on Claude Opus 4.1 or Haiku 4.5 with Reasoning Effort set completes without a 400. - [ ] Manually verify a tool-using agent (Spotify DJ or a custom tool agent) on a Claude connection with thinking on completes a tool round. - [ ] Manually verify an installed package (e.g. Long-Term Memory) on a connection with Reasoning Effort switched off doesn't send reasoning, and that custom headers reach the provider. - [ ] Manually verify the manual Illustrator on a small-context local endpoint with custom defaults on. - [ ] Manually verify the connection editor's Default Chat Parameters help text mentions chats and agents. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Notes: - Updated `docs/prompts/generation-parameters.md`, `docs/agents/custom-agents.md`, `docs/agents/agents-overview.md`, `docs/connections/subscription-clis.md` and `CHANGELOG.md` (#7131). - A `[docs-i18n]` follow-up issue for those four docs still needs to be opened. - en.json: `ui.connections.connectioneditor.defaultGenerationSettingsForChatsThatUseThisConnection` is renamed to `ui.connections.connectioneditor.defaultGenerationSettingsForChatsAndAgents`. ## UI evidence (if applicable) The only UI change is the connection editor help text (en.json). Worktree: `/Users/marysia/Developer/Marinara-Engine-worktrees/fix-agent-params-7131`. The files changed this round: - `packages/server/src/services/llm/providers/anthropic.provider.ts` - `packages/server/src/services/generation/agent-generation-parameters.ts` - `packages/server/src/services/agents/agent-executor.ts` - `packages/server/src/services/generation/illustrator-manual-prompt-generation.ts` - `packages/server/src/services/generation/illustrator-background-generation.ts` - `packages/server/src/services/llm/base-provider.ts` - `packages/server/src/routes/generate/retry-agents-route.ts` - `packages/shared/src/constants/model-lists.ts` - `scripts/regressions/agent-connection-parameters.regression.ts` - `docs/prompts/generation-parameters.md` - `CHANGELOG.md` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:20:20 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7493
No description provided.