feat(plugins): move fresh context out of core with provider.cache and composer hooks #52
Closed
gabrielvidal
wants to merge 0 commits from
fresh-context-plugin into main
pull from: fresh-context-plugin
merge into: gabrielvidal:main
gabrielvidal:main
gabrielvidal:remove-hooks-page
gabrielvidal:palette-plugins
gabrielvidal:linear-projects
gabrielvidal:agent-messaging
gabrielvidal:model-router
gabrielvidal:conv-card-layout
gabrielvidal:ask-more-options
gabrielvidal:agent-limits
gabrielvidal:generic-ui-strings
gabrielvidal:android-push-bridge
gabrielvidal:auto-translate
gabrielvidal:filter-chips
gabrielvidal:plugin-catalog
gabrielvidal:file-viewers
gabrielvidal:plugins-page-rework
gabrielvidal:hub-mcp-plugin
gabrielvidal:translation-plugin
gabrielvidal:scheduled-doors
gabrielvidal:cron-jobs-plugin
gabrielvidal:context-skills-plugin
gabrielvidal:files-plugins
gabrielvidal:worker-names
gabrielvidal:details-panel-perf
gabrielvidal:services-plugin-only
gabrielvidal:fix-test-env-leaks
gabrielvidal:bg-shells-plugin
gabrielvidal:feat-commits-plugins
gabrielvidal:fix-branch-line-tag-rows
gabrielvidal:retire-dead-leftovers
gabrielvidal:runner-into-harness-pi
gabrielvidal:retire-tool-proxy
gabrielvidal:new-project-policy-plugin-only
gabrielvidal:guest-jobs-sonnet
gabrielvidal:push-buttons-everywhere
gabrielvidal:mail-send-plugin
gabrielvidal:ui-polish-batch
gabrielvidal:command-palette-plugin
gabrielvidal:keyboard-shortcuts-plugin
gabrielvidal:prompt-shortcuts-plugin
gabrielvidal:matomo-site-grants
gabrielvidal:lab-chrome-plugin
gabrielvidal:performance-plugin
gabrielvidal:whats-new-plugin
gabrielvidal:skills-agents-plugin
gabrielvidal:goals-plugin-only
gabrielvidal:storage-server-side
gabrielvidal:plugin-scheduled-conversations
gabrielvidal:plugin-fences
gabrielvidal:handoff-plugin
gabrielvidal:plugin-commands
gabrielvidal:plugin-speed
gabrielvidal:cleanup-provider-harness
gabrielvidal:plugin-conversation-labels
gabrielvidal:plugin-plan-usage
gabrielvidal:fix-worker-harness-sync
gabrielvidal:plugin-gcloud-reauth
gabrielvidal:feat/plugin-cards-in-thread
gabrielvidal:feat/plugin-proxy-wake
gabrielvidal:unify-subagents-children
gabrielvidal:wave3d-frontend-typed-plugins
gabrielvidal:wave3c-sidecar-strict-plugins
gabrielvidal:wave3a-catalog-accounts-profiles
gabrielvidal:wave3b-pricing-usage-cutover
gabrielvidal:wave1a-typed-plugins
gabrielvidal:wave1b-sidecar-runtime
gabrielvidal:fix-ios-overlay-scroll
gabrielvidal:batch2-work-resources-core
gabrielvidal:batch2-apikeys
gabrielvidal:plugin-blue-green-deploy
gabrielvidal:plugin-ship
gabrielvidal:plugin-project-env
gabrielvidal:plugin-memories
gabrielvidal:plugin-activity
gabrielvidal:plugin-templates
gabrielvidal:plugin-desk-phone
gabrielvidal:batch1-platform
gabrielvidal:plugins-list-view
gabrielvidal:dash-plugins
gabrielvidal:pets-plugin
gabrielvidal:ha-push-channel
gabrielvidal:mail-agents
gabrielvidal:graph-fix
gabrielvidal:graph-plugin
gabrielvidal:services-plugin
gabrielvidal:left-to-do-plugin
gabrielvidal:plugins-gallery
gabrielvidal:home-conv-menu
gabrielvidal:meta-business
gabrielvidal:agy-rdrand
gabrielvidal:bg-lag
gabrielvidal:conv-load-perf
gabrielvidal:askform-instant
gabrielvidal:fix/drawer-menu-done-chip
gabrielvidal:pi-midrun-compaction
gabrielvidal:interrupt-menu-btn
gabrielvidal:authz
gabrielvidal:inkling
gabrielvidal:repo-plugins
gabrielvidal:work-sync
gabrielvidal:leftovers
gabrielvidal:fix/agy-guest-guard
gabrielvidal:feat/model-presets
gabrielvidal:scroll-back
gabrielvidal:feedback-bell
gabrielvidal:feat/movies-tool
gabrielvidal:feat/running-thread-padding
gabrielvidal:feat/drawer-filter-button-card-chat
gabrielvidal:burn-rate
gabrielvidal:guest-install
gabrielvidal:guest-usage
gabrielvidal:guest-palette
gabrielvidal:guest-form-links
gabrielvidal:form-open-buttons
gabrielvidal:clarifier-lean
gabrielvidal:auto-archive
gabrielvidal:guests-profile
gabrielvidal:conv-motion
gabrielvidal:share-target
gabrielvidal:terminal-sync
gabrielvidal:work-context-past
gabrielvidal:work-context-brief
gabrielvidal:enroll-codes
gabrielvidal:open-image-file
gabrielvidal:worker-uploads
gabrielvidal:conv-drawer-search
gabrielvidal:stack-motion-v3
gabrielvidal:notif-stack-fixes
gabrielvidal:home-motion
gabrielvidal:i18n-fr
gabrielvidal:local-electricity-cost
gabrielvidal:cache-pill-thread
gabrielvidal:cache-scenarios
gabrielvidal:fresh-start
gabrielvidal:msg-select
gabrielvidal:shortcuts-setup
gabrielvidal:ui-0-40-3
gabrielvidal:outbox-landing
gabrielvidal:resume-scope
gabrielvidal:conv-filter-range
gabrielvidal:fix-subagent-form-session
gabrielvidal:ask-form-integration
gabrielvidal:form-visual-options
gabrielvidal:watcher-perf
gabrielvidal:last-msg-summary
gabrielvidal:secret-fields
gabrielvidal:commit-review
gabrielvidal:summary-mode-fixes
gabrielvidal:service-tag-parser
gabrielvidal:clarifier
gabrielvidal:fetch-diet-2
gabrielvidal:fetch-diet
gabrielvidal:conv-look
gabrielvidal:pwa-links
gabrielvidal:tool-widgets
gabrielvidal:worker-autoupdate
gabrielvidal:usage-rings
gabrielvidal:opencode-harness
gabrielvidal:notif-diet
gabrielvidal:conv-resources
gabrielvidal:scheduled-tasks
gabrielvidal:profiles
gabrielvidal:notify-exact-cost
gabrielvidal:usage-measuring
gabrielvidal:guest-projects
gabrielvidal:usage-calibration
gabrielvidal:account-switch
gabrielvidal:multiuser-improve
gabrielvidal:form-groups
gabrielvidal:multiuser
gabrielvidal:motion-reel
gabrielvidal:dashboards-fixes
gabrielvidal:split-big-files
gabrielvidal:held-regex
gabrielvidal:subagent-interrupts
gabrielvidal:form-html
gabrielvidal:tokunia-video
gabrielvidal:settings-uniform
gabrielvidal:worker-ask-fix
gabrielvidal:worker-generic-mac
gabrielvidal:runner-shortcuts
gabrielvidal:notify-unify
gabrielvidal:perf-list-cache
gabrielvidal:mac-worker
gabrielvidal:model-switch
gabrielvidal:pipeline-paths
gabrielvidal:multi-account
gabrielvidal:feature-flags
gabrielvidal:qwen38-support
gabrielvidal:url-prompt
gabrielvidal:running-pages
gabrielvidal:homelab-tag
gabrielvidal:root-project
gabrielvidal:or-models
gabrielvidal:deploying-loader
gabrielvidal:worktree-diff
gabrielvidal:conv-tags
gabrielvidal:tags-page
gabrielvidal:agents-page
gabrielvidal:icon-picker-shortcuts
gabrielvidal:conv-cta
gabrielvidal:stamp-refine
gabrielvidal:post-task-cache
gabrielvidal:post-tidy-completed
gabrielvidal:form-badge
gabrielvidal:hooks-delay-seconds
gabrielvidal:cost-dashboard
gabrielvidal:plan-forms
gabrielvidal:form-mobile
gabrielvidal:guidelines-dag
gabrielvidal:skills-view
gabrielvidal:navbar-hold
gabrielvidal:spawnbox-status
gabrielvidal:hold-editable-expand
gabrielvidal:drawer-transparent
gabrielvidal:hold-fix
gabrielvidal:hold-editable
gabrielvidal:charroll-bump
No Reviewers
Labels
No items
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
gabrielvidal (Gabriel Vidal)
Clear assignees
No Assignees
gabrielvidal
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: gabrielvidal/ai-agent#52
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Moves the "fresh context" feature out of
ai-agentcore into generic plugin extension points so the newfresh-contextlive plugin (in the companionai-agent-pluginsPR) owns all cache-expiry estimation, nudges, confirmation sheets, compaction instructions, settings, and per-user Auto fresh state. Model provider plugins now declare their own prompt-cache parameters (provider.cache), and thread/composer plugins can read recent conversation feed timestamps and intercept idle resumes generically.Key changes
backend/plugins/typed_manifest.py,backend/plugins/providers.py,backend/fixtures/typed_plugins/provider-*/plugin.json):provider.cache(defaultTtlSeconds,tierswithttlSeconds/writeMult,expiryMarginSeconds,warmPrefixTokens), omitted from normalized manifests when undeclared so existing provider approval fingerprints stay unchanged.vendors[].cacheonGET /api/providers, addedProviderRegistry.cache_for(model_id), and addedGET /proxy/tools/plugins/{pid}/hub/providers(capabilitymodels.read, owner & managed guests).provider-anthropic,provider-openai, andprovider-googletest fixtures (and frontend mocks) with their declared cache specs.backend/plugins/proxyroutes.py,frontend/src/business/plugins/components/ConversationPluginPlaces.tsx):GET /proxy/tools/plugins/{pid}/hub/conversations/{sid}/feed?tail=20(conversations.read, owner & guest-scoped) returning recent message roles, kinds, timestamps, models, context tokens, and optionalcacheTtlhint (never message text).update.feed(includingechoesPendingand last 10{role, kind, ts, model}items) toconversation.threadHeader,conversation.threadEnd, andconversation.threadFooterslots.backend/plugins/manifest.py,backend/plugins/composer_bridge.py,backend/plugins/routes.py,backend/runs/routes.py,backend/runs/service.py,frontend/src/business/conversations/components/ResumeBox.tsx,SendMenuButton.tsx,useSendSlots.ts):composer.beforeSendandruns.compactprovideskeys andPOST /api/plugins/composer/before-send(supportingproceed,modifywithresume.compact, ormodalon anapp.modalslot; failing open toproceed).composer.sendslots with optionalcontexts,guestAllowed,requiresHarnessCap, anddirectAction(nohtmlrequired whendirectActionis set)./api/resumeto accept genericcompact: {model, instructions}alongsidefresh: true(delegated to the activeruns.compactprovider; gated on the harness'sfresh_contextcapability).onSendFreshfromResumeBox/SendMenuButton.backend/runs/fresh.py,GET/PUT /api/fresh-context,frontend/src/lib/freshContext.ts,FreshContext.tsx,business/settings/pages/FreshContext.tsx, coreusers.autoFresh,Extrasauto-fresh rows, andfreshStrip/cacheCountdownvisibility keys.CompactDivider.tsxfor transcriptcompact_boundaryitems and droppedcompact.saved(gain_prompt/gain_call) frombackend/conversations/parse/usage.pyso the core parser has zero cache-expiry math.carryover.fresh_contextto migrate legacy/data/fresh-context.json→ plugin sharedsettings.jsonand guestusers.jsonautoFresh→ managed plugin grants./settings/fresh-contextand#fresh-contextto/plugins/fresh-context/settings; regenerated OpenAPI, orval types, authz matrix, telemetry features, i18n keys, and docs.Key decisions
fresh-context-as-a-plugin_rqk199:provider.cachedescriptor on providers (includingexpiryMarginSecondsandwarmPrefixTokens) rather than keeping provider-specific constants in the plugin.cacheTtltier hint (5mvs1h), so cache age comes from the conversation feed while respecting Anthropic's explicit cache-write tier.conversation.threadFooterandconversation.threadEndslots rather than introducing a new message-card slot.CompactDividerparsing/rendering in core (since Claude Code emitscompact_boundaryon auto-compact and terminal/compactwithout the plugin) and droppedcompact.savedmath from core.managed.grantFields) with a one-time carryover migration.carryover.fresh_contextwrites migrated owner settings tostore.shared_data_dir("fresh-context") / "settings.json"(AIA_PLUGIN_SHARED_DIR/settings.json) so both owner and guest handlers evaluate sends against the migrated thresholds.Changelog
provider.cache, conversation feed timestamps,composer.beforeSend,runs.compact, andcomposer.senddirect actions) backed by thefresh-contextlive plugin./settings/fresh-contextredirects to thefresh-contextplugin's Settings page, and guest Auto fresh is managed through plugin grants.saved ≈ $X) from the thread's compaction divider (keeping token reduction, cost, duration, and foldable summary).Test notes
provider-anthropic,provider-openai,provider-google,provider-openrouter,provider-evox2, andfresh-contextfrom the companionai-agent-pluginsworktree against the updated corevalidate_manifest()— all passed, with 100% provider fixture cache parity.uv run --with-requirements requirements.txt --with pytest python -m pytest test_fresh_context_migration.py→ 43 passed (coversprovider.cache,hub/providers,hub/conversations/{sid}/feed,composer.beforeSend,runs.compact,composer.sendextensions,carryover.fresh_context, and parser cache clock/compaction divider).npx tsc --noEmit(0 errors) andnpx vitest run→ 181 test files passed, 1,179 tests passed.ai-agent-pluginsPR and deploy from the Homelab (ai-agent/deploy.sh).Screenshots
Merged into
mainas94f808d3by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/45784aea-fc45-4907-a993-d39db4db6c40Resolved against main's removal of the Claude Code hooks page (both removals kept); fix-up
8417dfbdfor the settings-search test and i18n keys. Deployed 8417dfbd..Pull request closed