Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

perf(server): warm first-turn session resources at thread creation

3 months ago

b055fe1
Authored
mweinbach7/2/2026, 1:42:49 PM
Fire-and-forget warm-up of the system prompt (skills scan, workspace
context, memory), the workspace MCP tool cache, and lazily imported turn
modules when a thread session is created or cold-loaded, so the first
user message no longer pays that setup cost before streaming. Guard the
system prompt load against clobbering a concurrent config refresh, and
add agent.turn.first_output telemetry measuring time from turn start to
the first visible text/reasoning delta.

Co-authored-by: Cursor <cursoragent@cursor.com>

Parent4a768a7

11 files changed
  • src/server/runtime/SessionRegistry.ts+6−0
  • src/server/session/AgentSession.ts+23−1
  • src/server/session/AgentSessionLazyImports.ts+9−0
  • src/server/session/AgentSessionSystemPrompt.ts+11−4
  • src/server/session/SessionContext.ts+2−0
  • src/server/session/turnExecution/runTurnInvocation.ts+24−0
  • src/server/session/turnExecution/runUserMessageTurn.ts+3−0
  • test/server/runtime/sessionRegistry.warmResources.test.ts+64
−0
  • test/session/agentSession.harness.ts+6−0
  • test/session/agentSession.warmResources.test.ts+167−0
  • test/session/runTurnInvocation.test.ts+90−0