troxy-cli 1.29.38 → 1.29.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "troxy-cli",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.39",
|
|
4
4
|
"description": "A secure control layer for AI agents: policies across payments, messages, logins, destructive actions, model usage, and secrets, all enforceable from the CLI",
|
|
5
5
|
"homepage": "https://troxy.io",
|
|
6
6
|
"bugs": {
|
|
@@ -50,7 +50,7 @@ async function failClosed($, e, next, err) {
|
|
|
50
50
|
//
|
|
51
51
|
// Ported from the proxy's scorer (troxy-tf-live model-proxy/app.py; bands match
|
|
52
52
|
// the production ROUTE_SCORER_BANDS=0.2:haiku,0.6:sonnet,0.8:opus,
|
|
53
|
-
// never-upward rule
|
|
53
|
+
// never-upward rule; the 50k context floor here covers every downward route, not just Haiku). The mod scores each human
|
|
54
54
|
// prompt once with the user's own session via $.model.complete, so there is no
|
|
55
55
|
// Troxy round trip and no credential to carry. One decision per prompt, applied
|
|
56
56
|
// to every step of its turn, so the cache prefix stays stable within a turn.
|
|
@@ -62,7 +62,7 @@ const MODELS = {
|
|
|
62
62
|
};
|
|
63
63
|
const RANK = { haiku: 0, sonnet: 1, opus: 2 };
|
|
64
64
|
const BANDS = [[0.2, 'haiku'], [0.6, 'sonnet'], [0.8, 'opus']];
|
|
65
|
-
const
|
|
65
|
+
const ROUTE_CONTEXT_FLOOR_TOKENS = 50000;
|
|
66
66
|
const SCORE_TIMEOUT_MS = 3000;
|
|
67
67
|
const SCORER_PROMPT_CHARS = 4000;
|
|
68
68
|
const SCORER_SYSTEM = 'You are a routing classifier for a coding-assistant proxy. Read the request below '
|
|
@@ -98,9 +98,9 @@ function pickModel(score, requested, contextTokens) {
|
|
|
98
98
|
for (const [limit, name] of BANDS) {
|
|
99
99
|
if (score <= limit) { if (RANK[name] < RANK[rq]) tier = name; break; }
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
// The cache is per model: the first prompt on a new model re-writes the whole
|
|
102
|
+
// conversation, so past the floor a switch costs more than one cheap turn saves.
|
|
103
|
+
if (tier !== rq && contextTokens > ROUTE_CONTEXT_FLOOR_TOKENS) tier = rq;
|
|
104
104
|
return tier === rq ? requested : MODELS[tier];
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -31,10 +31,12 @@ test('pickModel: never routes upward', () => {
|
|
|
31
31
|
assert.equal(pickModel(0.4, MODELS.haiku, 1000), MODELS.haiku);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
test('pickModel:
|
|
35
|
-
assert.equal(pickModel(0.05, MODELS.opus, 60000), MODELS.
|
|
34
|
+
test('pickModel: past the 50k floor nothing routes down, a cold cache would cost more than it saves', () => {
|
|
35
|
+
assert.equal(pickModel(0.05, MODELS.opus, 60000), MODELS.opus);
|
|
36
|
+
assert.equal(pickModel(0.4, MODELS.opus, 60000), MODELS.opus);
|
|
36
37
|
assert.equal(pickModel(0.05, MODELS.sonnet, 60000), MODELS.sonnet);
|
|
37
38
|
assert.equal(pickModel(0.05, MODELS.haiku, 60000), MODELS.haiku);
|
|
39
|
+
assert.equal(pickModel(0.4, MODELS.opus, 50000), MODELS.sonnet);
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
test('pickModel: a model it does not recognise is left alone', () => {
|
|
@@ -71,6 +73,6 @@ test('estimateTokens: counts the prompt being submitted, not just the context so
|
|
|
71
73
|
assert.equal(estimateTokens(30000, 'x'.repeat(40000)), 40000);
|
|
72
74
|
assert.equal(estimateTokens(undefined, 'hi'), 1);
|
|
73
75
|
assert.equal(estimateTokens(5, ''), 5);
|
|
74
|
-
// a first-prompt of ~60k tokens must trip the
|
|
75
|
-
assert.equal(pickModel(0.05, MODELS.opus, estimateTokens(0, 'x'.repeat(240000))), MODELS.
|
|
76
|
+
// a first-prompt of ~60k tokens must trip the floor
|
|
77
|
+
assert.equal(pickModel(0.05, MODELS.opus, estimateTokens(0, 'x'.repeat(240000))), MODELS.opus);
|
|
76
78
|
});
|