Repository navigation
Расход на пользователя ниже порога окупаемости: сжатие, дешёвый браузер, финмодель #713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
aba60dc
6c45e86
24505e3
cb49641
4d6f0b1
267554f
33c5d19
6a5613a
5d9c337
421c8e7
cdf30b1
e73a915
7ca9343
f7dea61
a6ba766
c17325d
ded027d
65facd4
79c9262
2f94a70
64e27ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,13 +82,11 @@ describe("whether a step may compact the conversation", () => { | |
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("never compacts the task agent's report, a retry or a context message last", () => { | ||
| it("never compacts the task agent's report, a retry or the checkpoint last", () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Removing Prompt for AI agents |
||
| for (const kind of [ | ||
| "execution.background_task", | ||
| "execution.retry", | ||
| "execution.continuation", | ||
| "context.state", | ||
| "context.instruction", | ||
| "context.compaction", | ||
| ]) { | ||
| expect(compactsAtTurnStart([...earlier, opener, tagged("x", kind)])).toBe( | ||
|
|
@@ -97,6 +95,25 @@ describe("whether a step may compact the conversation", () => { | |
| } | ||
| }); | ||
|
|
||
| it("looks past a few short context lines after the opener, not past many", () => { | ||
| const line = (n: number) => | ||
| tagged(`Геопозиция ${String(n)}`, "context.location"); | ||
| expect(compactsAtTurnStart([...earlier, opener, line(1), line(2)])).toBe( | ||
| true | ||
| ); | ||
| expect( | ||
| compactsAtTurnStart([ | ||
| ...earlier, | ||
| opener, | ||
| line(1), | ||
| line(2), | ||
| line(3), | ||
| line(4), | ||
| line(5), | ||
| ]) | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("never compacts after a step or an approval's answer", () => { | ||
| const step: ModelMessage = { | ||
| content: [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,10 +43,24 @@ function userMessageKind(message: ModelMessage) { | |
| * the opener do not count. | ||
| */ | ||
| export function compactsAtTurnStart(messages: readonly ModelMessage[]) { | ||
| const last = messages.findLast( | ||
| (message) => | ||
| message.role !== "user" || !userMessageKind(message).startsWith("memory.") | ||
| ); | ||
| // Up to a few short `context.*` lines (location, tips, a recap) may follow | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The doc block above Prompt for AI agents |
||
| // the opener on a channel such as Telegram: eve keeps its last ten messages | ||
| // whole, so the opener stays beside them after the summary. | ||
| let contextLines = 0; | ||
| const last = messages.findLast((message) => { | ||
| if (message.role !== "user") return true; | ||
| const kind = userMessageKind(message); | ||
| if (kind.startsWith("memory.")) return false; | ||
| if ( | ||
| kind.startsWith("context.") && | ||
| kind !== "context.compaction" && | ||
| contextLines < 4 | ||
| ) { | ||
| contextLines += 1; | ||
| return false; | ||
| } | ||
| return true; | ||
| }); | ||
| return ( | ||
| last?.role === "user" && | ||
| userMessageKind(last) === "user" && | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ export async function historyTrimPilot( | |
| turn?: Parameters<typeof pilotVerdictOfTurn>[1] | ||
| ) { | ||
| const list = env.HISTORY_TRIM_WORKSPACES ?? []; | ||
| if (env.HISTORY_TRIM_MODE !== "pilot") return false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The JSDoc above Prompt for AI agents |
||
| if (!directModelActive() || list.length === 0) return false; | ||
| if (list.includes("*")) return true; | ||
| return pilotVerdictOfTurn("history-trim", turn, async () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -524,6 +524,20 @@ postgres:17-alpine`, Docker в облачной сессии есть; Google | |
| через ostrovok.ru/affiliate; тестовый ключ ищет по всем отелям, а бронирует лишь тестовый (hid 8526976), боевой — | ||
| после сертификации (14–30 дней, видео «поиск → бронь → отмена»). Ключ `KEY_ID:API_KEY` ждём в `OSTROVOK_API_KEY`. | ||
|
|
||
| - Цена долгой Telegram-сессии (02.11, финмодель — `docs/finmodel/`): сессия владельца сидела на 360–390 тыс. токенов на шаг | ||
| (Orca, кэш 98%: тёплый шаг ≈ 0,1 ₽, холодный ≈ 4,6 ₽; среднее по каналу 0,67 ₽ против 0,14 ₽ в вебе) — сжатие не срабатывало: | ||
| `compactsAtTurnStart` отвергал ход, если после сообщения шла строка `context.*`. С 02.11 (выкат 20261102-185821) строки | ||
| `context.*` (до 4, кроме чекпоинта) не мешают, `COMPACTION_WORKSPACES` без значения — все (`off` — никому), порог 100 тыс. | ||
| Проверка эффекта: `usage-stats.sh` — `input_p50` по «Interactive steps by their place» у `channel:telegram`. Консоль VM | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This adds an internal VM hostname and a root-console access incident to the notes. AGENTS.md asks that notes skip internal hostnames and task history. Drop the hostname here, or refer to the host by role. Prompt for AI agents |
||
| `bro-app-sel-2` 02.11 root-пароль из состояния не принимала (`vnc.py run`): env правился только кодом и выкатом. | ||
| `host.py deploy` из облачной сессии: `NODE_OPTIONS=--max-old-space-size=8192` (иначе куча на `next build`), Node 24, `zstd`. | ||
| Проверено вживую 02.11 (веб-чат владельца, 5 сообщений по ~33k токенов): сжатие срабатывает с 2-го хода, шаг держится ~111k; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: These notes expose the owner's session details and a specific search query (also line 2470); remove individual activity data and keep only non-user-specific operational results. Prompt for AI agents |
||
| вызов сжатия ≈ 0,5 ₽ и +3 с. Расход на человека — `host.py ops NAME cost-per-user.sh [SINCE]`. | ||
| Обрезка старых результатов (`HISTORY_TRIM_WORKSPACES`) с 02.11 выключена `HISTORY_TRIM_MODE=off` (по умолчанию): её сдвиг границы | ||
| раз в 8 ходов рвёт кэш с места правки (живой шаг Telegram: 72k из 82k токенов без кэша ≈ 0,9 ₽), а выигрыш в токенах при кэше | ||
| $0,003/M ничтожен; рост истории держит сжатие. Кэш Orca живёт ≥ 36 мин (живой ход Telegram 02.11: 50% префикса попало, остальное — следствие выключенной обрезки; замеры 30/60/120 мин не получены: фоновый python умирает вместе с контейнером сессии, ставьте замер через `send_later`-цепочку); прогрев `warm.ts` пингует только RunInfra, | ||
| а чат идёт через Orca. Карточки с 02.11 выключены `CARDS_MODE=off` (по умолчанию; владелец): `send_card`/`update_card` падали с «non-serializable capture»; список `CARDS_WORKSPACES=*` на проде остаётся, вернуть — `CARDS_MODE=pilot` после починки. | ||
|
|
||
| ## Процесс | ||
|
|
||
| - Дизайн (15.10): все страницы, кроме лендинга, — на одной системе: тёплая | ||
|
|
@@ -2451,6 +2465,9 @@ subscriptions WHERE template = 'flight')`, строки уйдут каскад | |
| быстрее deepinfra (вызов browser-use — медиана 2,2 с против 5,6 с), но | ||
| дороже вдвое; без `require_parameters` его вызовы шли без ошибок | ||
| (`docs/browser-speed.md`). | ||
| - С 02.11 пилот ниже **выключен** `BROWSER_FAST_MODE=off` (по умолчанию; владелец: поручения могут быть медленнее, если дешевле): список | ||
| `BROWSER_FAST_WORKSPACES` на проде остаётся `*`, но ничего не включает; вернуть — `BROWSER_FAST_MODE=pilot` в `/etc/bro/env`. | ||
| Проверено вживую 02.11: поиск чайников на dns-shop — DeepInfra, 18 шагов, 118 с, 0,77 ₽ модели. | ||
| - Пилот `BROWSER_FAST_WORKSPACES` (05.10; с 19.10 в проде `*`, владелец — сразу всем): | ||
| DeepSeek worker на Together без `requireParameters`, `llmTimeoutSeconds` 25 (worker | ||
| ≥ 2026-10-05.6), flash для поиска — `FLASH_SEARCH` с ним не нужен | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Финмодель Bro | ||
|
|
||
| `bro-finmodel.xlsx` — живые формулы; жёлтые ячейки — вводные (курс, цена, N, ₽/день токенов, цены единиц). | ||
|
|
||
| Выводы при цене 1 999 ₽, постоянных 69,7 тыс. ₽/мес (курс 84,41), номере на каждого: | ||
|
|
||
| - Токены 75–100 ₽/день (2 250–3 000 ₽/мес) больше самой выручки: при них 1 999 ₽ не окупается ни при каком N. Цена для нуля при N=200 — 3,1–3,9 тыс. ₽. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The headline conclusion here (75–100 ₽/день makes 1 999 ₽ unprofitable at any N) is superseded by the 03.11 update below (tokens 25 ₽/день, ≈500 ₽ profit at N=200). Rewrite the 'Выводы' block for the current inputs, or mark it explicitly as the 26.10–02.11 snapshot so the two results don't read as contradictory. Prompt for AI agents |
||
| - Нуль при 1 999 ₽: ≈42 ₽/день токенов при N=200, ≈30 при N=100, ≈50 при N=500. Маржа 30% при N=200 — ≈22 ₽/день. | ||
| - Цена единиц в листе «Профили и лимиты» (голос, звонки, браузер) — допущения; сверять по `usage_costs` (`host.py ops <VM> usage-stats.sh`). | ||
|
|
||
| ## Факт прода (`usage-stats.sh`, 26.10–02.11) | ||
|
|
||
| - Самое дорогое — длинная Telegram-сессия: контекст шага 100–390 тыс. токенов, 0,67 ₽/шаг против 0,14 ₽ в вебе. Это и есть «75–100 ₽/день» (один аккаунт ≈ 70 ₽/день). | ||
| - Поручение браузеру — в среднем 2,4 ₽ (p90 4,6), а не 15. | ||
| - Голос и звонки в `usage_costs` не пишутся: их цена остаётся допущением. | ||
|
|
||
| ## Расход на человека (прод, `host.py ops <VM> cost-per-user.sh 2026-10-19`, 02.11) | ||
|
|
||
| 14 воркспейсов с расходом, большинство — тестовые и бенчмарки, поэтому цифры завышены и шумят: | ||
|
|
||
| - ₽ за активный день без самого дорогого: p50 24 ₽, среднее 31 ₽, p90 62 ₽; у «постоянных» (3+ дня) p50 51 ₽. | ||
| - Структура (₽ на человеко-день): chat 18, browser-run 15, background 6,4, browser-report 5, proxy 0,9, task 0,6. | ||
| - Голос и звонки в `usage_costs` не пишутся: в эти цифры не входят. | ||
| - Выводы: чат (длинный контекст Telegram) и модель браузера — две главные статьи; браузер идёт на `BROWSER_FAST_WORKSPACES` (Together, +3,7 ₽ за поручение ради скорости) — решение о скорости/цене за владельцем. | ||
|
|
||
| ## Звонки (`phone-minutes.sh`, 05.10–02.11) | ||
|
|
||
| 74 дозвона (>5 с), 113 минут, 5 человек со звонками: медиана 0,7 мин на звонок, в среднем ≈ 25 мин на человека за 4 недели (≈ 0,8 мин в день; один человек — 95 мин). ElevenLabs — $6,6 за 71 звонок ≈ 5 ₽/мин плюс оператор ≈ 1,76 ₽/мин; GPT-Live (с 18.10 основной путь) в этой цене не виден, `carrier_rub` в таблице не заполняется. | ||
|
|
||
| ## Кредиты OpenAI (владелец 02.11: $200 в месяц, позже возможно $500) | ||
|
|
||
| Фиксированная сумма: покрывает всё, что платится OpenAI (голос `/talk`, звонки GPT-Live), но не растёт с числом людей. Лист «Профили и лимиты» считает долю OpenAI в каждой статье (колонка G, допущение) и покрытие: при N=200 и среднем профиле $200 ≈ 16,9 тыс. ₽ дают +84 ₽ на человека в месяц (≈ 1 700 минут голоса и звонков на всех), $500 — около +210 ₽. Чем меньше людей, тем сильнее эффект: при N=50 кредиты закрывают весь OpenAI-расход. | ||
|
|
||
| ## Обновление 03.11 (данные прода после сжатия контекста) | ||
|
|
||
| - Токены в «Вводных» — 25 ₽/день (было 75): среднее 17,7, медиана 12,7, «постоянный» тяжёлый пользователь 44,7 (один человек). | ||
| - Лист «Факты прода 03.11» — что измерено; лист «Профили и лимиты» пересчитан на ход чата 0,50 ₽ (шаг 0,17 ₽ × 3). | ||
| - Базовый результат: прибыль ≈ 500 ₽/пользователь/мес при N=200, безубыточное N ≈ 83, токены для нуля — до 41 ₽/день. | ||
| - Выборка 10 человек, ~2,5 активных дня на каждого: цифры предварительные. Лимиты на пользователя — после роста выборки (решение владельца). | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Unset
COMPACTION_WORKSPACESnow compacts for everyone, but theenv.tscomment on this variable still says unset means "as before" near the model window. Update that comment and this function's JSDoc to state that unset means all andoffmeans none.Prompt for AI agents