Skip to content

Fix agent runtime: true parallel mesh, Neon adapter, quote cache poisoning#1

Merged
piyushxpc7 merged 1 commit into
mainfrom
fix/agent-runtime-parallel-mesh
May 30, 2026
Merged

Fix agent runtime: true parallel mesh, Neon adapter, quote cache poisoning#1
piyushxpc7 merged 1 commit into
mainfrom
fix/agent-runtime-parallel-mesh

Conversation

@piyushxpc7

Copy link
Copy Markdown
Owner

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. Used require() in an ESM context (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 against client ^5.22.0 — the major mismatch produced Cannot read properties of undefined (reading 'bind')).
  • lib/ai/fireworks.ts — LLM calls forced serial. enqueueLlm was 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 by withRateLimitRetry.
  • lib/agents/runtime/graph.v2.ts — "parallel" mesh ran sequentially. parallelAgentMeshNode looped specialists with await (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. getYahooQuote cached quotes even when price was null, serving a broken price to /api/quote and 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 in company/[ticker]/page.tsx are unrelated).
  • Agent e2e completed with a persisted WATCH recommendation; Neon adapter no longer logs the fallback warning.

🤖 Generated with Claude Code

…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>
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blackledger Error Error May 29, 2026 7:37pm

@piyushxpc7 piyushxpc7 merged commit a628fdf into main May 30, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant