[BUG] stopWhen/processInputStep receives empty content/toolResults when observationalMemory is enabled (multi-turn, multi-tool last step)
Describe the Bug
StepResult.content and StepResult.toolResults are empty inside the stopWhen callback when observationalMemory is enabled on the Memory instance. With observationalMemory disabled, the same agent and prompts work correctly. This makes it impossible to inspect tool results (e.g., endTurn returning stopped) to decide whether to stop the loop.
This bug is 100% reproducible when observationalMemory is enabled.
Version: @mastra/core 1.67
memory: new Memory({
options: {
observationalMemory: {
enabled: true,
}
},
}),Confirmed this still reproduces with:
@mastra/core 1.68.0-alpha.2
@mastra/memory 1.31.0-alpha.1
Same reproduction steps and same output (lastStep.content.length:0) with observationalMemory enabled. Disabling it still works. So whatever fix landed between 1.67 and these alpha versions does not cover the observationalMemory + multi-turn + multi-tool scenario.
Steps To Reproduce
- bun run src/mastra/index.ts
- Input hello, press Enter
- Input ok, press Enter
- Press Enter directly (empty input)
output(Last turn, when observationalMemory enabled):
======= stopWhen =======
lastStep.content.length:0Link to Minimal Reproducible Example
https://github.com/zengyun261/bug-reproduction
Expected Behavior
======= stopWhen =======
lastStep.content.length:5
tool-result:sendMessage,{"type":"text","value":"ok"}
tool-result:endTurn,{"type":"json","value":{"status":"stopped"}}Environment Information
System:
OS: macOS 26.6.2
CPU: (18) arm64 Apple M5 Max
Memory: 2.53 GB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.16.0 - /Users/zcloud/.nvm/versions/node/v24.16.0/bin/node
npm: 11.13.0 - /Users/zcloud/.nvm/versions/node/v24.16.0/bin/npm
pnpm: 12.3.4 - /Users/zcloud/Library/pnpm/bin/pnpm
bun: 1.3.14 - /Users/zcloud/.bun/bin/bun
Deno: 2.8.2 - /opt/homebrew/bin/deno
Browsers:
Chrome: 152.0.7977.83
Safari: 26.6.2
npmPackages:
@mastra/core: 1.67.0 => 1.67.0
@mastra/duckdb: 1.9.0 => 1.9.0
@mastra/libsql: 1.23.0 => 1.23.0
@mastra/memory: 1.30.0 => 1.30.0
@mastra/observability: 1.17.8 => 1.17.8
@types/node: latest => 22.20.3
ai: ^7.0.103 => 7.0.103
mastra: 1.30.0 => 1.30.0
typescript: ^6.0.3 => 6.0.3
zod: ^4.4.3 => 4.6.5
npmGlobalPackages:
@colbymchenry/codegraph: 1.4.0
@mem0/cli: 0.2.8
corepack: 0.35.0
http-server: 14.1.1
npm: 11.13.0Verification
- I have searched the existing issues to make sure this is not a duplicate
- I have included sufficient information for the team to reproduce and understand the issue
Source: mastra-ai/mastra