Repository navigation
Conversation
β¦ew-only Design proposal to trim the life agent per-turn system prompt for Havaya app users: phased plan covering prompt caching (gated on Venice cache support), per-app-session trimming (lean AGENTS via the agent:bootstrap hook, a new app PromptMode, scoped skills catalog), file-structure cleanup (prune empty bootstrap files; slim SOUL by moving exercise scripts into the personal-vision-exercise skill), bootstrap memoization, sequencing/rollback, and verification via the cache-trace harness. Review surface for Codex; not implemented; do not merge to deploy. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cryptolir
left a comment
There was a problem hiding this comment.
Findings for Claude before coding starts:
[P1] Phase 1 contradicts the non-app byte-identical gate
Lines 30-34 propose host edits to SOUL.md, deleting bootstrap files, and dropping IDENTITY.md. Those host files are shared by Telegram/owner sessions too, so this cannot satisfy lines 22 and 65, which require Telegram/owner prompts to stay byte-identical. Either make Phase 1 app-only through the same bootstrap hook/filtering path, or explicitly relax the non-app byte-identical requirement.
[P1] App skill scoping must be life-only/config-driven, not in the shared app path
Line 40 points at limitAppSkills / buildAppSkillsPrompt / attempt.ts to scope app skills to summaryskill and personal-vision-exercise. Those are shared app-session mechanisms; hardcoding or globally filtering there would break other app agents that need different skills. The plan should require an agent-specific/config-driven allowlist and tests showing non-life app sessions retain their own catalog.
[P2] APP_PROFILE repositioning needs a concrete render split
Lines 41-42 say move APP_PROFILE just before ## Runtime and keep it outside memoized shared bootstrap. Today it is appended inside resolveBootstrapFilesForRun after hooks, then rendered as part of # Project Context. A hook reorder alone wonβt put it near Runtime or keep the shared context memo clean. The plan should call for a separate app-profile context/render slot, plus tests that APP_PROFILE.md is absent from the shared Project Context and appears exactly once after the shared prefix.
[P2] Phase 2 should include a compaction parity gate
PR #74 just had to mirror app skill prompt behavior in compaction. This plan changes promptMode, bootstrap selection, app profile placement, and skill scoping, but verification only names the normal fresh-session path. Add explicit compaction/manual-overflow verification so app sessions do not regress back to full bootstrap or path-leaking skill/profile placement during compaction.
Overall: good direction, but Iβd tighten these before coding. The biggest fix is making βonly app/life changesβ mechanically true, not just aspirational.
Fixes: (P1) all app trimming now app-only via the agent:bootstrap hook + additive SOUL.app.md/AGENTS.app.md variants β shared SOUL.md/AGENTS.md untouched so Telegram/owner stay byte-identical; (P1) app-skill scoping is a per-agent config allowlist read by the shared path, not hardcoded, so other app agents keep their catalog; (P2) APP_PROFILE gets a dedicated render slot after Project Context, removed from the bootstrap-file list; (P2) added compaction/manual-overflow parity to verification. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Pushed rev2 (
Still review-only β not implemented; do not merge to deploy. |
cryptolir
left a comment
There was a problem hiding this comment.
Rechecked rev2 (2dd364248) for Claude.
The earlier four review blockers from 4533385398 look addressed at the plan level. Remaining guardrails before coding:
[P1] Skill allowlist is still ambiguous enough to become global
Line 43 says to add skills.appAllowlist in lifeβs openclaw.json and have shared limitAppSkills / buildAppSkillsPrompt read it. Current config has top-level skills plus agents.list[].skills; the shared helpers only receive config, not clearly the resolved sessionAgentId. If this lands as top-level skills.appAllowlist in a multi-agent config, it can accidentally scope every app agentβs catalog. The plan should name the exact per-agent schema path and require attempt.ts + compact.ts to resolve it using the current agent id before filtering.
[P2] compact.ts should be a first-class implementation target, not just verification
The plan adds compaction verification at line 69, which is good, but the implementation bullets and critical files still mainly point to attempt.ts for prompt mode/app skills. Since compaction independently builds promptMode, bootstrap context, skills, and system prompt, the plan should explicitly list src/agents/pi-embedded-runner/compact.ts under Critical files and require shared helper usage or mirrored wiring there.
[P2] Bootstrap memoization needs invalidation/rollback semantics
Lines 39, 44, and 57 rely on additive host files (AGENTS.app.md, SOUL.app.md) while memoizing shared bootstrap per session. Without a cache key based on file mtimes/content hash/config version, edits or rollback of app variants may not affect existing sessions. Add either explicit invalidation/TTL/new-session-only semantics, or include the app variant files + relevant config in the memo cache key.
This is much closer than rev1; Iβd tighten these implementation guardrails before coding.
Per-agent appSkills allowlist resolved by sessionAgentId (never global); compact.ts as a first-class target via a shared resolveAppPromptContext helper so the run + compaction paths cannot drift; bootstrap-memo invalidation keyed on app-variant mtime/hash + config version. All three re-verified against live source. Still review-only β do NOT merge to deploy. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Rev3 ( [P1] Allowlist must be per-agent, never global. Confirmed [P2] [P2] Memoization invalidation/rollback. The per-session bootstrap memo is a new optimization, so the staleness risk is self-inflicted. β Memo cache key = Still review-only β no code implemented; do not merge to deploy. π€ Generated with Claude Code |
cryptolir
left a comment
There was a problem hiding this comment.
Rechecked rev3 (769da7611) for Claude.
Most of the rev2 guardrails are now addressed: compact.ts is first-class, the shared helper is specified, memo invalidation is named, and the APP_PROFILE / skill-scoping guardrails are much tighter.
Remaining finding:
[P1] agents.defaults.appSkills wonβt work with the current config model as written
Rev3 says life can set appSkills under agents.defaults and multi-agent configs can set it under agents.list[] (lines 22, 54, 69, 71). But current AgentDefaultsSchema is strict and has no skill fields, while resolveAgentConfig() only reads agents.list[] entries and does not merge agents.defaults into per-agent resolved config. So if Claude implements only AgentConfig.appSkills, the documented life config path under agents.defaults will either be rejected by schema validation or silently unavailable to the resolver. The plan should explicitly require adding appSkills?: string[] to both AgentDefaultsConfig/AgentDefaultsSchema and AgentConfig/AgentEntrySchema, plus a resolver that merges defaults with the matching agent entry.
β¦ma + resolver) resolveAgentConfig reads only agents.list[] entries and never merges agents.defaults; life is defaults-only (no agents.list[]), so an appSkills under agents.defaults would be silently undefined and rejected by the strict schema. Require appSkills on BOTH the agent-defaults and agent-entry types+schemas, plus a resolveAppSkillsAllowlist(cfg,agentId) = entry.appSkills ?? agents.defaults.appSkills (model/workspace fallback precedent). Re-verified against live source. Still review-only. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Rev4 (
Fix landed in the plan:
Updated: Critical files ( π€ Generated with Claude Code |
β¦ scoping (#80) Reduce per-turn latency + tokens for Havaya app-user sessions while keeping Telegram/owner prompts byte-identical (all changes flow through app-only code paths): - New "app" PromptMode: drops CLI quick-ref / self-update / model-aliases / docs / silent-replies / heartbeats / owner-identity (privacy) but KEEPS Reply-Tags/ Messaging/Voice (unlike "minimal"). Telegram/owner stay on "full". - App-only bootstrap shaping (resolveBootstrapFilesForRun β applyAppBootstrapVariants): excludes boilerplate (TOOLS/MEMORY/HEARTBEAT/IDENTITY/USER) and prefers lean <name>.app.md variants when present (AGENTS.app.md/SOUL.app.md). Originals untouched. - Per-agent appSkills allowlist: new field on BOTH agent-defaults and agent-entry schemas + resolveAppSkillsAllowlist(cfg, agentId) = entry.appSkills ?? agents.defaults.appSkills (defaults-fallback precedent; works for life's defaults-only config). limitAppSkills takes the caller-resolved allowlist β never global. - Shared resolveAppPromptContext helper consumed by BOTH attempt.ts and compact.ts so the run + compaction paths can't drift (app user id, "app" mode, scoped skills); agent id resolved up front, before skill filtering. Implements PR #77 plan (rev4). APP_PROFILE render-slot + bootstrap memoization deferred to the caching increment (no token/latency payoff until Venice caching lands). Tests: app PromptMode drop/keep + full byte-identical control; resolveAppSkillsAllowlist defaults-only + per-agent isolation; applyAppBootstrapVariants exclude/swap; limitAppSkills allowlist. tsgo + oxlint clean. Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
|
Increment A of this plan shipped to prod as #80 (squash β main Implemented (all gated to
β 8 KB/turn (~2K tokens) lighter on app sessions. tsgo + oxlint + 22 vitest green (incl. the full byte-identical control). Deferred (this plan's "Increment B"): the APP_PROFILE dedicated render-slot + per-session bootstrap memoization β pure cache-prefix-stability work with no token/latency payoff until Venice caching exists (Phase 3). They'll land with the caching decision. APP_PROFILE left in place β #71 first-turn greeting untouched. |
Review-only design proposal β do NOT merge to deploy. Adds a design doc at
docs/experiments/plans/life-system-prompt-optimization.mdfor Codex review; no code changes.Goal
Cut per-turn latency + token cost for the
lifeagent on Havaya app-user sessions while preserving output quality; leave Telegram/owner behavior unchanged. Today the full ~30β34 KB system prompt is rebuilt and re-sent every turn with no caching.Proposal (phased)
liferunsvenice/claude-opus-4-6β Venice is an OpenAI-completions provider, so the AnthropiccacheRetentionpath is inert and pi-ai's openai-completionscache_controlinjector is OpenRouter-gated β zero cache breakpoints today. Phase 0 measures whether Venice caches implicitly (usage.cachedTokens); if not, Option A = generalize the injector for Venice, Option B = route Claude via an Anthropic endpoint (owner call on cost/data-routing). Reorder so the stable prefix precedes per-turn dynamic content; 2 breakpoints."app"PromptMode (drop CLI-ref/self-update/heartbeats/model-aliases/docs; keep Reply-Tags/Messaging/Voice); lean app-AGENTS.mdvia theagent:bootstraphook; scope the<available_skills>catalog to life-relevant skills.TOOLS.md/MEMORY.md/HEARTBEAT.md, dropIDENTITY.md(dup of auto-genBOOTSTRAP.md), split AGENTS app/telegram, and slimSOUL.mdby moving its exercise scripts into the existingpersonal-vision-exerciseskill (biggest single shrink).APP_PROFILE.mdoutside the memoized span so name-on-message-1 (feat(bootstrap): inject per-user app_profile into agent context (profile Phase 3)Β #68/fix(bootstrap): inject app_profile on the first turn of a new app sessionΒ #71) still works.Expected: app-session static prompt ~30β34 KB β ~12β16 KB; with caching, the stable prefix re-billed ~10% after turn 1.
Review asks
cache_controlinjector behind a per-model flag) or Option B (route via Anthropic API)?agent:bootstraphook vs extendingfilterBootstrapFilesForSession?life-access-scopejail, APP_PROFILE injection (feat(bootstrap): inject per-user app_profile into agent context (profile Phase 3)Β #68/fix(bootstrap): inject app_profile on the first turn of a new app sessionΒ #71),save_user_section/Graphiti,summaryskill/personal-vision-exerciseloading, the TAL Hebrew persona?File:line references are inline in the doc. Verification (cache-trace harness + behavior parity + telegram byte-diff) is in the doc's Verification section.
π€ Generated with Claude Code