@blockrun/franklin 3.15.93 → 3.15.94

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.
Files changed (2) hide show
  1. package/dist/agent/loop.js +18 -2
  2. package/package.json +1 -1
@@ -1011,10 +1011,26 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
1011
1011
  // where input-replay tax has clearly started biting; the
1012
1012
  // fire-once-per-turn flag still bounds the worst case at one
1013
1013
  // extra summary call (~$0.005).
1014
+ //
1015
+ // 2026-05-11: added a high-cost early-exit. The original
1016
+ // (>15 calls AND >$0.03) gate works well for cheap models
1017
+ // where 15 calls clears the $0.03 floor trivially. For Opus-
1018
+ // class models, cost climbs much faster than call count —
1019
+ // verified in production from a real session:
1020
+ // `Research-bloat compacted at 16 calls / $9.4552: ~3129
1021
+ // tokens`. By the time the 16-call gate fired, $9.45 was
1022
+ // already spent on input-replay. With an early-exit at
1023
+ // $1.00 turn-cost, the compact would have fired around
1024
+ // call 4-5, saving ~$8 on that turn. The cost cap is
1025
+ // intentionally conservative — even extended-thinking Opus
1026
+ // shouldn't legitimately need >$1 of context-replay before
1027
+ // compacting (the compact itself runs on a cheaper model
1028
+ // and costs <$0.05).
1029
+ const TURN_COST_CAP_FOR_EARLY_COMPACT = 1.00;
1014
1030
  if (!bloatCompactedThisTurn &&
1015
1031
  compactFailures < 3 &&
1016
- turnToolCalls > 15 &&
1017
- turnCostUsd > 0.03) {
1032
+ ((turnToolCalls > 15 && turnCostUsd > 0.03) ||
1033
+ turnCostUsd > TURN_COST_CAP_FOR_EARLY_COMPACT)) {
1018
1034
  try {
1019
1035
  const beforeTokens = estimateHistoryTokens(history);
1020
1036
  const { history: compacted, compacted: didCompact } = await forceCompact(history, config.model, client, config.debug);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.15.93",
3
+ "version": "3.15.94",
4
4
  "description": "Franklin — The AI agent with a wallet. Spends USDC autonomously to get real work done. Pay per action, no subscriptions.",
5
5
  "type": "module",
6
6
  "exports": {