mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #413] [MERGED] feat(agents): add per-turn cost readout to agents picker #4612
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4612
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/413
Author: @cha1latte
Created: 5/4/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @SpicyMarinara
Base:
main← Head:feat/agent-cost-readout📝 Commits (3)
2f925d8feat(agents): add per-turn cost readout to agents picker4dcad1bfix(agents): treat empty promptTemplate as no overridea81032efix(agents): show ~0 token badges instead of hiding them📊 Changes
3 files changed (+202 additions, -38 deletions)
View changed files
📝
packages/client/src/components/chat/ChatSettingsDrawer.tsx(+114 -38)📝
packages/shared/src/index.ts(+1 -0)➕
packages/shared/src/utils/agent-cost.ts(+87 -0)📄 Description
Summary
Adds a small informational readout to the agents picker in the chat settings drawer (roleplay mode) so users can see the rough overhead of their enabled agent loadout before they hit context-window or latency problems.
~N tokens of agent instructions · ~M extra calls/turn. Flips to amber with a warning icon when the loadout crosses 4 extra calls or 4000 instruction tokens.~Ntoken badge next to each active agent row.estimateAgentLoadCostlives in@marinara-engine/shared.Why
Right now there's no in-UI signal for the cumulative cost of an enabled agent set. Users only find out the loadout is too heavy when things fail — context overflows on small local models, latency spikes from too many extra calls, errors in the logs. By that point they're toggling agents off one-by-one to find a working set.
This gives a soft self-correcting signal before any of that happens. Informational only, no toggles are blocked.
Approach
chars/4heuristic that's already scattered across the client (PeekPromptModal, LorebookFormFields, etc.). Marked clearly as approximate. There's aTODOat the heuristic site for swapping in a real tokenizer when one is added.packages/server/src/services/agents/agent-pipeline.ts— agents that share(phase, connection)batch into one call. v1 ignores the tool-extraction nuance (tool-using agents technically run alone) — fine for a soft signal.instructionTokens. The hover tooltip on the readout calls this out explicitly.Scope
Files changed
packages/shared/src/utils/agent-cost.ts(new) — pure cost function + threshold constants.packages/shared/src/index.ts— re-export.packages/client/src/components/chat/ChatSettingsDrawer.tsx— imports,agentLoadCostmemo, cumulative pill, two per-row badges,activeAgentIdswrapped inuseMemoto keep the new memo stable. Also a small fix: empty-stringpromptTemplatein custom configs now falls through to the built-in default (was??, needed||).Known limitations
~. Real per-turn usage will be higher because chat context is not counted.Test plan
~N tokens · ~M extra calls/turntext in standard chat~Nbadges render with hover tooltip on active agent rowsAlertTriangleiconpnpm --filter @marinara-engine/shared run lintpasses locallypnpm --filter @marinara-engine/client run lintpasses locallypnpm checkcurrently fails onmaindue to a pre-existingOutputType.HwPositionWithDurationrename inpackages/server/src/services/haptic/buttplug-service.ts. Not introduced by this PR.Screenshots
Summary by CodeRabbit
Release Notes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.