Skip to content

TypeScript templates: no per-session short-term memory (Strands leaks history across sessions; VercelAI is stateless) #1665

Description

@aidandaly24

The TypeScript agent templates do not provide correct per-session short-term memory (in-process, turn-to-turn conversation recall — distinct from the AgentCore Memory service).

Strands (memory: none)

src/assets/typescript/http/strands/base/main.ts caches a single global Agent:

let cachedAgent: Agent | null = null;
async function getOrCreateAgent(): Promise<Agent> {
  if (!cachedAgent) { cachedAgent = new Agent({ ... }); }
  return cachedAgent;
}

Because the agent retains agent.messages, a process that serves more than one session shares one history across all of them. On AgentCore Runtime this is masked by the 1:1 session→microVM model, but in agentcore dev (one Node process, many sessions) it causes cross-session history bleed and unbounded growth.

Reproduced: session A says "my favorite color is teal"; a different session B then asks "what is my favorite color?" and the agent answers "teal".

VercelAI

src/assets/typescript/http/vercelai/base/main.ts calls streamText({ prompt }) with no history, so it cannot recall earlier turns even within a single session.

Expected

Both templates should keep per-session in-process history keyed by sessionId and bounded (LRU), matching the Python templates. This is free, best-effort short-term memory (resets on cold start) and should not require provisioning the AgentCore Memory service.

Context

A prior change disabled TypeScript memory because the Strands TS SDK lacked the AgentCore Memory session manager; that correctly removed the durable service integration but also removed the free in-process continuity, which never needed the session manager.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions