Skip to content

fix(unit-only): Primarily a DX/discoverability fix (stateless behavior is... (#1591)#68

Draft
aidandaly24 wants to merge 1 commit into
mainfrom
fix/1591
Draft

fix(unit-only): Primarily a DX/discoverability fix (stateless behavior is... (#1591)#68
aidandaly24 wants to merge 1 commit into
mainfrom
fix/1591

Conversation

@aidandaly24

Copy link
Copy Markdown
Owner

Refs aws#1591

Issues

  • bug: default agent has no session context aws/agentcore-cli#1591 — An agent created with the default memory option ('none') has no session continuity: every invoke behaves like a fresh conversation. The agent never gets a session_manager, so nothing is loaded from or written to a durable store, and the no-memory template uses a single process-global agent that is not keyed by session_id, so --session-id has no effect at all in that path. Meanwhile the CLI tells the user the opposite: --session-id is labeled "Use specific session ID for conversation continuity" and both the CLI stream output and the interactive TUI print "To resume this session, run: agentcore invoke --session-id ..." even for memory-less agents. New customers reasonably expect continuity and are confused when there is none.

Root cause

Reproduces exactly at HEAD (v0.20.2) and is by-design: session continuity is gated entirely on memory being configured. In src/assets/python/http/strands/base/main.py, the default (memory='none', no truncation, no config-bundle, no payment) renders the branch at lines 441-468: a single module-global _agent created once via get_or_create_agent() with conversation_manager=NullConversationManager() and NO session_manager. Two consequences: (1) with no session_manager, nothing is loaded/persisted to a durable store, so history is lost on container cold-start; (2) the global _agent is NOT keyed by session_id, so the runtime session_id (set as x-amz-bedrock-agentcore-session-id at src/cli/commands/invoke/action.ts:175) is functionally inert in this path — --session-id changes nothing. The session_id is only consumed by src/assets/python/http/strands/capabilities/memory/session.py get_memory_session_manager, which returns None when MEMORY_ID is unset; that manager (SDK AgentCoreMemorySessionManager extending Strands RepositorySessionManager, bedrock-agentcore-sdk-python v1.9.1, src/bedrock_agentcore/memory/integrations/strands/session_manager.py) is the sole mechanism that restores cross-invoke history, and it only exists when hasMemory is true. Memory defaults to 'none' (src/cli/commands/create/command.tsx:285,343,588,608; validate.ts:90; --defaults => "no memory" at command.tsx:394). The 'none' option description is just "No memory" (src/cli/tui/screens/generate/types.ts:253), --session-id is mislabeled "Use specific session ID for conversation continuity" (src/cli/commands/invoke/command.tsx:146), and the unconditional "To resume" notice fires for memory-less agents in both the CLI stream path (command.tsx:105-120) and the TUI (src/cli/tui/screens/invoke/InvokeScreen.tsx:216).

The fix

Primarily a DX/discoverability fix (stateless behavior is correct without a session store), plus tightening of actively misleading copy. (1) Reword MEMORY_OPTIONS so the tradeoff is explicit: 'none' = "No memory - each turn is a fresh, stateless session", 'shortTerm' = "Remembers prior turns within a session" (src/cli/tui/screens/generate/types.ts:252-256). (2) Make the continuity messaging memory-aware: soften the --session-id help text (command.tsx:146) away from "conversation continuity", and suppress or reword the "To resume --session-id" notice (command.tsx:105-120) and the TUI exit hint (InvokeScreen.tsx:216) when the resolved agent has no memory configured — in the no-memory path --session-id is genuinely inert, so promising resume is wrong, not just vague. (3) Add a post-create/first-invoke hint for memory-less agents pointing to agentcore add memory; AddFlow.tsx already renders a memory-aware success note (AddFlow.tsx:370-394, 411-417) so reuse that copy. Product decision required: document/warn (low effort, recommended) vs change the default to short-term memory (larger; provisioning/cost impact). Do NOT change the NullConversationManager branch itself. Optional follow-up: address the latent cross-session-bleed smell of the single non-keyed global _agent in the no-memory path.

Files touched: src/cli/tui/screens/generate/types.ts:252-256 (MEMORY_OPTIONS descriptions); src/cli/commands/invoke/command.tsx:146 (--session-id help) and 105-120 ("To resume" notice, make memory-conditional); src/cli/tui/screens/invoke/InvokeScreen.tsx:216 (TUI resume hint, make memory-conditional); optional post-create hint reusing src/cli/tui/screens/add/AddFlow.tsx:370-394. Template src/assets/python/http/strands/base/main.py NullConversationManager branch (lines 441-468) is correct and should NOT change.

Validation evidence

The fix was verified by reproducing the original symptom and re-running after the change:

BEFORE (base/HEAD): command.tsx:144 help text = 'Use specific session ID for conversation continuity'; printInvokeResult unconditionally emitted 'To resume: agentcore invoke --session-id ' in both stream (HEAD:105) and non-stream (HEAD:118) branches regardless of memory; InvokeScreen.tsx:213 unconditionally set 'To resume this session, run: ...' exit hint; MEMORY_OPTIONS descriptions = 'No memory' / 'Context within a session' (never named the stateless tradeoff). AFTER (fix/1591): printInvokeResult only prints the 'To resume:' line when result.hasMemory is true (Session: still always prints); hasMemory derived once in handleInvoke (action.ts:54 = (project.memories?.length ?? 0) > 0) and threaded through all 4 InvokeResult return paths; InvokeScreen exit hint gated on config?.hasMemory (InvokeScreen.tsx:213) with useInvokeFlow populating hasMemory on InvokeConfig; help text reworded to '...continuity requires memory — see agentcore add memory'; MEMORY_OPTIONS 'none' -> 'No memory - each turn is a fresh, stateless session', 'shortTerm' -> 'Remembers prior turns within a session'. ADVERSARIAL PROOF: temporarily reverted printInvokeResult to unconditional 'To resume' -> the new no-memory test FAILED (expected '\nSession: abc\nTo resume...' not to contain 'To resume'), confirming the test guards the symptom; restored fix and it passes. REGRESSION GUARD: 'shows the To resume hint when target has memory' test passes. EXPLICITLY-NOT-CHANGED verified: base/main.py untouched, cre

Test suite: green.


Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.

Suppress the 'To resume --session-id' hint and reword the --session-id
help text and MEMORY_OPTIONS descriptions for memory-less agents, where
session continuity is genuinely inert. Threads hasMemory through the
invoke action and TUI flow so the resume hint only renders when the
resolved agent has memory configured.

Refs aws#1591
@github-actions github-actions Bot added the size/s PR size: S label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 37.19% 13604 / 36579
🔵 Statements 36.45% 14463 / 39670
🔵 Functions 31.81% 2334 / 7337
🔵 Branches 31.14% 9011 / 28937
Generated in workflow #122 for commit 459af3d by the Vitest Coverage Report Action

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant