[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-81401":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":14,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":15,"rankGlobal":10,"rankLanguage":10,"license":16,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":10,"pushedAt":10,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":14,"starSnapshotCount":14,"syncStatus":24,"lastSyncTime":25,"discoverSource":26},81401,"pi-lifeline","robzolkos\u002Fpi-lifeline","robzolkos","Have small autoresearch model phone-a-friend (larger model) for guidance","",null,"TypeScript",36,1,0,0.9,"MIT License",false,"master",true,[],"2026-06-12 02:04:14","# pi-lifeline\n\nA Pi extension that lets a smaller\u002Flocal model **ask a stronger advisor model** when an autonomous optimization loop gets stuck.\n\nInspired by Tobi Lütke's [observation](https:\u002F\u002Fx.com\u002Ftobi\u002Fstatus\u002F2056198717225464307) that local models can run `pi-autoresearch` effectively when they occasionally ask a stronger model for ideas.\n\n## What it does\n\n`pi-lifeline` adds:\n\n- **Tool:** `phone_a_friend` — ask a configured stronger model for strategy, critique, debugging help, or next experiment ideas.\n- **Command:** `\u002Flifeline` — inspect status, thresholds, and advisor config.\n- **Autoresearch trigger detection:** watches `log_experiment` results and detects repeated failures or plateaus.\n- **Rate limiting:** avoids calling the expensive model every iteration.\n\nThe larger model is a **strategy reset mechanism**, not the inner loop.\n\n```text\nsmall\u002Flocal model: edit → run_experiment → log_experiment → repeat\n                                  │\n                                  │ only when stuck\u002Fplateaued\n                                  ▼\n                     phone_a_friend → stronger advisor model\n```\n\n## Why not call every iteration?\n\nCalling the larger model every run defeats the point. The default policy only triggers after evidence that the local model is stuck:\n\n```json\n{\n  \"auto\": true,\n  \"action\": \"nudge\",\n  \"minRunsBetweenCalls\": 5,\n  \"triggerAfterConsecutiveFailures\": 3,\n  \"triggerAfterPlateauRuns\": 6,\n  \"maxCallsPerSession\": 10\n}\n```\n\nDefault behavior is **nudge**, not hidden spending: when stuck, the extension sends a steer message telling the agent to call `phone_a_friend`. If you want fully automatic advisor calls, set `\"action\": \"ask\"`.\n\n## Install\n\nInstall from npm with Pi:\n\n```bash\npi install npm:pi-lifeline\n```\n\nThen reload Pi:\n\n```text\n\u002Freload\n```\n\nVerify it loaded:\n\n```text\n\u002Flifeline\n```\n\nCreate a global starter config:\n\n```text\n\u002Flifeline init\n```\n\nThen edit `~\u002F.pi\u002Fagent\u002Fpi-lifeline.json` to adjust your advisor provider\u002Fmodel or thresholds.\n\n### Load locally for development\n\nFrom this repo:\n\n```bash\npi -e .\u002Fextensions\u002Fpi-lifeline\u002Findex.ts\n```\n\nAs a Pi package, `package.json` exposes:\n\n```json\n{\n  \"pi\": {\n    \"extensions\": [\".\u002Fextensions\u002Fpi-lifeline\"]\n  }\n}\n```\n\n## Configuration\n\nCreate `pi-lifeline.json` in your Pi agent config directory, usually `~\u002F.pi\u002Fagent\u002Fpi-lifeline.json`:\n\n```json\n{\n  \"auto\": true,\n  \"action\": \"nudge\",\n  \"minRunsBetweenCalls\": 5,\n  \"triggerAfterConsecutiveFailures\": 3,\n  \"triggerAfterPlateauRuns\": 6,\n  \"maxCallsPerSession\": 10,\n  \"advisor\": {\n    \"provider\": \"openai\",\n    \"model\": \"gpt-5.5\",\n    \"thinking\": \"high\",\n    \"maxTokens\": 4096,\n    \"temperature\": 0.7\n  },\n  \"includeAutoresearchContext\": true\n}\n```\n\nYou can also set:\n\n```bash\nexport PI_LIFELINE_ADVISOR_PROVIDER=openai\nexport PI_LIFELINE_ADVISOR_MODEL=gpt-5.5\nexport PI_LIFELINE_THINKING=high\nexport PI_LIFELINE_MAX_TOKENS=4096\nexport PI_LIFELINE_TEMPERATURE=0.7\n```\n\nFor tests\u002Fsmoke runs without spending tokens:\n\n```bash\nexport PI_LIFELINE_FAKE_RESPONSE=\"Try profiling phase timings and attack the largest non-noisy bucket.\"\n```\n\n## Tool: `phone_a_friend`\n\nInputs:\n\n- `question` — specific question for the advisor.\n- `context` — optional logs, metrics, code summary, failed ideas.\n- `mode` — one of:\n  - `ideas`\n  - `critique`\n  - `debug`\n  - `next_experiment`\n- `max_ideas` — default 5.\n- `provider` \u002F `model` — optional per-call override.\n\nExample use:\n\n```json\n{\n  \"question\": \"We have three discarded parser optimization attempts. What should we try next?\",\n  \"mode\": \"next_experiment\",\n  \"context\": \"Recent runs: #2 discard inline cache, #3 crash arena reuse, #4 discard branchless scan\",\n  \"max_ideas\": 4\n}\n```\n\nThe advisor prompt explicitly asks for strategic, testable advice — not full patches — and warns against benchmark cheating.\n\n## Command: `\u002Flifeline`\n\n```text\n\u002Flifeline\n```\n\nShows:\n\n- active config source\n- advisor provider\u002Fmodel\n- thresholds\n- calls this session\n- autoresearch run count\n- current trigger decision\n\n```text\n\u002Flifeline init\n```\n\nOpens a small setup wizard, asks for the advisor model, thinking\u002Freasoning level, and auto-action policy, then creates global `~\u002F.pi\u002Fagent\u002Fpi-lifeline.json` without overwriting an existing file.\n\n```text\n\u002Flifeline sample-config\n```\n\nPrints the starter config without writing a file.\n\n## Autoresearch integration\n\nWhen `pi-autoresearch` is active, `pi-lifeline` reads `autoresearch.jsonl` and watches `log_experiment` results.\n\nIt triggers when either:\n\n1. trailing failures reach `triggerAfterConsecutiveFailures`\n   - statuses: `discard`, `crash`, `checks_failed`\n2. no kept improvement has happened for `triggerAfterPlateauRuns`\n\nIt respects:\n\n- `minRunsBetweenCalls`\n- `maxCallsPerSession`\n- `auto: false`\n\nWith `includeAutoresearchContext: true`, the tool includes recent `autoresearch.jsonl` runs in the advisor prompt.\n\n## Validation plan\n\n### 1. Static validation\n\n```bash\nnpm run check\n```\n\nThis verifies the extension and policy modules parse under Node's TypeScript stripping.\n\n### 2. Policy unit tests\n\n```bash\nnpm test\n```\n\nTests cover:\n\n- default config normalization\n- consecutive failure detection\n- keep resetting failure streak\n- plateau detection\n- `higher` and `lower` metric directions\n- `minRunsBetweenCalls`\n- `maxCallsPerSession`\n- `auto: false`\n\n### 3. Fake advisor smoke test\n\n```bash\nexport PI_LIFELINE_FAKE_RESPONSE=\"Try measuring phase timings before further code changes.\"\npi -e .\u002Fextensions\u002Fpi-lifeline\u002Findex.ts\n```\n\nThen ask the agent to call `phone_a_friend`. Expected: the tool returns the fake response and records a session call without requiring real model auth.\n\n### 4. Autoresearch fixture smoke test\n\nCreate `autoresearch.jsonl`:\n\n```jsonl\n{\"type\":\"config\",\"name\":\"test\",\"metricName\":\"score\",\"metricUnit\":\"\",\"bestDirection\":\"lower\"}\n{\"run\":1,\"metric\":100,\"status\":\"keep\",\"description\":\"baseline\",\"timestamp\":1}\n{\"run\":2,\"metric\":101,\"status\":\"discard\",\"description\":\"bad 1\",\"timestamp\":2}\n{\"run\":3,\"metric\":102,\"status\":\"discard\",\"description\":\"bad 2\",\"timestamp\":3}\n{\"run\":4,\"metric\":103,\"status\":\"discard\",\"description\":\"bad 3\",\"timestamp\":4}\n```\n\nStart Pi with the extension and run `\u002Flifeline`. Expected: current decision says trigger due to 3 consecutive failures.\n\n### 5. Real advisor smoke test\n\nConfigure a cheap available model first:\n\n```json\n{\n  \"auto\": true,\n  \"action\": \"ask\",\n  \"minRunsBetweenCalls\": 0,\n  \"triggerAfterConsecutiveFailures\": 1,\n  \"triggerAfterPlateauRuns\": 99,\n  \"maxCallsPerSession\": 1,\n  \"advisor\": {\n    \"provider\": \"google\",\n    \"model\": \"gemini-2.5-flash\",\n    \"maxTokens\": 1024,\n    \"temperature\": 0.3\n  }\n}\n```\n\nExpected:\n\n- advisor auth resolves via Pi model registry\n- main model is not changed\n- advisor returns a concise strategy message\n- no code is modified by the advisor directly\n\n## Design notes\n\n- The small model remains responsible for edits and experiments.\n- The strong model is used only for strategic advice.\n- Defaults are intentionally conservative to avoid token waste.\n- `action: \"nudge\"` makes cost explicit; `action: \"ask\"` is available for trusted unattended runs.\n","pi-lifeline 是一个扩展工具，允许小型或本地模型在自主优化循环受阻时向更强的顾问模型求助。其核心功能包括通过 `phone_a_friend` 工具请求策略建议、调试帮助或实验想法，并具备自动检测停滞情况和限制调用频率的能力。项目使用 TypeScript 编写，具有灵活的配置选项以调整触发条件及顾问模型参数。适用于需要高效利用资源进行自动化研究或优化任务的场景，如机器学习实验中的超参数调优，能够显著提高小规模计算资源下的工作效能。",2,"2026-06-11 04:04:54","CREATED_QUERY"]