Shared Memory¶
This page describes the shared-memory capability as it exists in the current source tree.
Current Status¶
Shared memory support is partially implemented.
What exists today:
- a thread-safe memory manager
- a persisted
memory.mdfile - helper methods for prompt injection
- tool metadata definitions for memory read/write tools
What does not happen automatically in normal goflow run today:
- no shared-memory manager is created from
config.shared_memory - no memory tools are automatically registered into step sessions
- no automatic prompt injection is performed during step execution
So shared memory is present as a building block in the code, but not yet fully wired into the user-facing CLI flow.
Schema¶
The workflow config schema defines:
config:
shared_memory:
enabled: true
inject_into_prompt: true
initial_content: "seed text"
initial_file: "./memory.md"
Field status¶
| Field | Parsed | Active in current CLI path |
|---|---|---|
enabled |
Yes | No |
inject_into_prompt |
Yes | No |
initial_content |
Yes | No |
initial_file |
Yes | No |
Implemented Package Behavior¶
The memory manager in pkg/memory/manager.go supports:
NewManager(dir, initialContent)¶
Creates memory.md inside the provided directory and writes the initial content if present.
Read()¶
Returns the full in-memory content string.
Write(agentName, entry)¶
Appends a timestamped line in this format:
InjectIntoPrompt(prompt)¶
Prepends a clearly delimited shared-memory block before the original prompt.
Tool Definitions Present In Code¶
The helper package defines tool metadata for:
read_memorywrite_memory
These names matter because they do not match older docs that referred to shared_memory_read and shared_memory_write.
In the current source tree, the defined tool spec names are:
Why Shared Memory Exists¶
The intended use case is cross-step coordination when multiple agents are running in the same workflow level.
Typical examples:
- a security reviewer records a critical issue for other reviewers to consider
- an analyzer writes context that later reviewers can consult
- a coordinating agent publishes shared state across a wide fan-out
That design makes the most sense when the parallel orchestrator is active.
Important Runtime Caveat¶
The normal CLI runs parallel DAG levels, but shared memory is still not fully wired into automatic runtime integration. Even with parallel execution active, users will not get automatic memory manager setup, tool registration, or prompt injection from config.shared_memory yet.