Fix agent runtime: true parallel mesh, Neon adapter, quote cache poisoning#1
Merged
Merged
Conversation
…oning Agent runtime end-to-end run surfaced real defects; fixes: - lib/db.ts: Neon adapter crashed under ESM (`require is not defined`), silently falling back to non-pooled Prisma. Switched to static imports and aligned @prisma/adapter-neon to the 5.x line (was ^7.8.0 vs client ^5.22.0 — the major mismatch caused `reading 'bind'`). - lib/ai/fireworks.ts: enqueueLlm was a strict serial chain, forcing every LLM call through one at a time — so the "parallel agent mesh" could never run in parallel. Replaced with a bounded counting semaphore (LLM_MAX_CONCURRENCY, default 3) so concurrent agents overlap their tool-call round-trips. - lib/agents/runtime/graph.v2.ts: parallelAgentMeshNode ran specialists in a sequential for-loop (latency = sum of agent times, pushing runs to the 480s budget edge). Now launches all planned specialists concurrently with staggered starts; bounded concurrency lives in the LLM semaphore. - lib/yahoo.ts: getYahooQuote cached quotes even when price was null, poisoning /api/quote and the price-update cron for the full TTL on any transient Yahoo gap. Now only caches quotes that carry a price, so it self-heals. Also bundles the in-progress WorkOS/NextAuth auth migration and related UI/data changes that were pending in the working tree. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Ran the forensics agent end-to-end (
npm run agent:e2e, HFCL) and logged everything. The run completed, but the logs exposed concrete defects. Fixed each.Fixes
lib/db.ts— Neon adapter crash. Usedrequire()in an ESM context (require is not defined), silently falling back to non-pooled Prisma. Switched to static imports and aligned@prisma/adapter-neonto the 5.x line (was^7.8.0against client^5.22.0— the major mismatch producedCannot read properties of undefined (reading 'bind')).lib/ai/fireworks.ts— LLM calls forced serial.enqueueLlmwas a single promise chain, so every LLM request ran one-at-a-time regardless of caller concurrency. Replaced with a bounded counting semaphore (LLM_MAX_CONCURRENCY, default 3). 429 bursts are already covered bywithRateLimitRetry.lib/agents/runtime/graph.v2.ts— "parallel" mesh ran sequentially.parallelAgentMeshNodelooped specialists withawait(latency = sum of agent times, e.g. 116s + 180s ≈ 298s, near the 480s budget cap). Now launches all planned specialists concurrently with staggered starts; bounded concurrency lives in the LLM semaphore. Specialists read the same pre-mesh state, so there was no ordering dependency to preserve.lib/yahoo.ts— poisoned quote cache.getYahooQuotecached quotes even whenpricewas null, serving a broken price to/api/quoteand the price-update cron for the full TTL after any transient Yahoo gap. Now only caches quotes that carry a price, so it self-heals (verified: clearing the key returned the correct price).Also bundles the in-progress WorkOS/NextAuth auth migration and related UI/data changes that were already pending in the working tree.
Verification
npx tsc --noEmit— no new errors in changed files (pre-existing errors incompany/[ticker]/page.tsxare unrelated).🤖 Generated with Claude Code