2.4 KiB
2.4 KiB
Token Optimization Implementation Report
Implemented the token-optimization plan across heartbeat orchestration, issue context APIs, adapter prompt construction, skill exposure, and agent configuration UX.
The main behavior changes are:
- Heartbeat telemetry now normalizes sessioned local adapter usage as per-run deltas instead of blindly trusting cumulative session totals.
- Timer and manual wakes now preserve task sessions by default; fresh sessions are forced only for explicit
forceFreshSessionwakes or new issue assignment wakes. - Heartbeat session rotation is now policy-driven in the control plane, with a handoff note injected when a session is compacted and restarted.
- Paperclip issue context now has incremental APIs:
GET /api/agents/me/inbox-lite,GET /api/issues/:id/heartbeat-context, and comment delta queries viaGET /api/issues/:id/comments?after=...&order=asc. - The
paperclipskill now teaches agents to use those compact/incremental APIs first, while keeping full-thread fetches as a cold-start fallback. - All local adapters now separate first-session bootstrap prompts from per-heartbeat prompt templates, and emit prompt size metrics in invocation metadata.
- Adapter create flows now persist
bootstrapPromptTemplatecorrectly. - The agent config UI now explains the difference between bootstrap prompts and heartbeat prompts and warns about prompt churn.
- Runtime skill defaults now include
paperclip,para-memory-files, andpaperclip-create-agent.create-agent-adapterwas moved to.agents/skills/create-agent-adapter.
Files with the most important implementation work:
server/src/services/heartbeat.tsserver/src/services/issues.tsserver/src/routes/issues.tsserver/src/routes/agents.tsserver/src/routes/access.tsskills/paperclip/SKILL.mdpackages/adapters/*/src/server/execute.tspackages/adapters/*/src/ui/build-config.tsui/src/components/AgentConfigForm.tsx
Verification completed successfully:
pnpm -r typecheckpnpm test:runpnpm build
While verifying, I also fixed two existing embedded-postgres typing mismatches so repo-wide typecheck and build pass again:
packages/db/src/migration-runtime.tscli/src/commands/worktree.ts
Next useful follow-up is measuring the before/after effect in real runs now that telemetry is less misleading and prompt/session reuse behavior is consistent across adapters.