Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
mcpproxy-go/bench/breakeven.go at main · smart-mcp-proxy/mcpproxy-go · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
smart-mcp-proxy
mcpproxy-go
Repository navigation
Code
Issues
20
(20)
Pull requests
15
(15)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
mcpproxy-go
/
bench
/
breakeven.go
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
41 lines (39 loc) · 1.84 KB
main
Breadcrumbs
mcpproxy-go
/
bench
/
breakeven.go
Copy path
Top
File metadata and controls
Code
Blame
41 lines (39 loc) · 1.84 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// breakeven.go — break-even analysis for proxy-mediated tool discovery
// (Spec 083 US1, FR-003/FR-004, research D8).
package
bench
import
"fmt"
// ComputeBreakEven computes the number of retrieve_tools calls at which the
// proxy's cumulative context cost (proxy menu + N discovery responses) equals
// the naive full-menu cost:
//
// break_even_calls = (naive_full_menu_tokens − proxy_menu_tokens) / mean_response_tokens
//
// Below break_even_calls discovery calls the proxy is strictly cheaper; each
// call beyond it spends part of the menu savings. All three inputs are echoed
// in the result (FR-004) so a reader can recompute the number from the row
// alone. Both menu inputs MUST come from the same canonical full-definition
// renderer (research D7b) or the numerator compares different token shapes.
//
// When the numerator is ≤ 0 the proxy menu is already at least as expensive
// as the naive menu — there are no savings to amortize — and the result is a
// NoBreakEven row (BreakEvenCalls stays 0), whatever the response cost.
// Otherwise meanResponseTokens must be positive: a zero mean means no
// responses were measured, and dividing by it is undefined, so that is an
// error rather than a fabricated verdict.
func
ComputeBreakEven
(
naiveFullMenuTokens
,
proxyMenuTokens
int
,
meanResponseTokens
float64
) (
*
BreakEvenAnalysis
,
error
) {
b
:=
&
BreakEvenAnalysis
{
NaiveFullMenuTokens
:
naiveFullMenuTokens
,
ProxyMenuTokens
:
proxyMenuTokens
,
MeanResponseTokens
:
meanResponseTokens
,
}
numerator
:=
naiveFullMenuTokens
-
proxyMenuTokens
if
numerator
<=
0
{
b
.
NoBreakEven
=
true
return
b
,
nil
}
if
meanResponseTokens
<=
0
{
return
nil
,
fmt
.
Errorf
(
"break-even undefined: mean response tokens must be > 0, got %v (no measured responses?)"
,
meanResponseTokens
)
}
b
.
BreakEvenCalls
=
float64
(
numerator
)
/
meanResponseTokens
return
b
,
nil
}
You can’t perform that action at this time.