Done — I created a dedicated worktree for this fix.
/Users/tarunsachdeva/code/traces-worktrees/fix-ai-summary-post-processingfix/ai-summary-post-processingmain at 1ff42c4If you want, I can now jump into this worktree and trace why summary generation is frequently hitting fallback and why titles are truncating to the first message.
I traced this in the new worktree and found a few concrete causes behind the behavior you described, then patched them in API.
user messages, not assistant, so outputs were often shallow and title-like rewrites of the initial ask (api/convex/lib/config.ts:5).trace.title first, which is often already a clipped first-message preview (api/convex/internal/scheduled/traceSummary.ts:107).ai_summary/ai_title (api/convex/internal/scheduled/traceSummary.ts:363).api/convex/utils/ai.ts:83).I implemented fixes:
highlightRoles now includes both user and assistant for better context (api/convex/lib/config.ts:5).missing_api_key, http_error, timeout, etc.) (api/convex/utils/ai.ts:11, api/convex/utils/ai.ts:83).api/convex/internal/scheduled/traceSummary.ts:136).trace.title (api/convex/internal/scheduled/traceSummary.ts:127).api/convex/internal/scheduled/traceSummary.ts:364).fallbackReason to make debugging actionable (api/convex/internal/scheduled/traceSummary.ts:327).I also added regression coverage for:
api/tests/v1/post-process.test.ts:229).I couldn’t run tests here because bun isn’t installed in this environment (bun: command not found).
bun test --env-file .env.local tests/v1/post-process.test.ts from api.Found it — bun is at:
/Users/tarunsachdeva/.bun/bin/bunI used that exact binary to continue:
api successfully."/Users/tarunsachdeva/.bun/bin/bun" test --env-file .env.local tests/v1/post-process.test.ts.The tests now run, but fail because Convex admin env vars are missing (from api/tests/v1/post-process.test.ts:27), not because of bun.
CONVEX_ADMIN_KEY (or CONVEX_SELF_HOSTED_ADMIN_KEY) and URL vars.api/.env.example.If you point me to your real env file (or set those vars), I’ll rerun immediately.
I’m in:
/Users/tarunsachdeva/code/traces-worktrees/fix-ai-summary-post-processingfix/ai-summary-post-processingYep — that’s exactly what happened.
.env.local is gitignored, so it does not get copied into a new worktree.frontend/.env.local, api/.env.local, cli/.env.local; your worktree has only .env.example files.Use this once to sync env files:
Then restart dev servers; the NEXT_PUBLIC_CONVEX_URL error should be gone.