TypeScript routing scorer choking on /api/v2/routing/queues/{id}/agents shape in Electron main process

I’m spinning up a TypeScript module to override the default queue routing behavior inside the Electron main process, but the scoring pipeline keeps choking on the /api/v2/routing/queues/{queueId}/agents response shape. The endpoint returns a flat array of routingQueueAgent objects, yet my calculateAgentScore(agent, interactionContext) function expects nested skill proficiency maps. I’m mapping the raw payload with agents.map(a => ({ id: a.id, skills: a.skills.map(s => ({ name: s.name, proficiency: s.proficiency })) })) and feeding it into a weighted sum algorithm that multiplies proficiency by a dynamic contextWeight pulled from the interaction metadata. When I push the computed scores back to the internal config store via POST /internal/routing/config, the payload hits a 400 Bad Request because the score field refuses values above 100.0, even though the docs say it accepts floats. The tie-breaking logic using Math.random() on equal scores works in isolation, but the main process hangs when I try to batch the results for the simulation runner.

Switching to a least-busy fallback with agents.filter(a => a.currentlyWrappedCalls === 0).sort((x, y) => x.totalCalls - y.totalCalls) fixes the hang, yet the routing efficiency report generator spits out NaN for the throughputDelta metric. I’ve been tracing the getUserMedia stream state to ensure the softphone isn’t blocking the routing thread, but the event loop just keeps queuing microtasks. The dynamic config API endpoint I’m exposing at localhost:3000/api/route/update accepts the new thresholds, but the WebSocket subscription for real-time agent state changes drops frames when the scoring function runs longer than 150ms. The GC routing API seems to be silently truncating the weighted payload shape anyway.

The routingQueueAgent payload stays flat by design. You’ll need to map the skill proficiencies manually.

  1. Extract the routing_queue_skill IDs.
  2. Cross-reference them against your local cache.
  3. Rebuild the nested structure inside the callback.

Skip extra API calls during peak hours or the scorer will timeout. Just reshape the data locally. Missing the cache lookup causes memory spikes.

const nestedSkills = agents.map(a => ({
 id: a.id,
 SKILL_PROFICIENCY: a.routing_queue_skill.reduce((acc, s) => ({ ...acc, [s.skill_id]: s.level }), {})
}));

The suggestion above nails the cache lookup, but you’ll want to bind that QUEUE_AGENT_MAPPING directly to the local state before the ROUTING_SCORE calculation kicks off. Architect Flows handle this payload reshaping natively anyway, so pushing custom logic into the Electron main process just adds unnecessary latency. Honestly just leave the SKILL_PROFICIENCY map flat until the final evaluation step.