Tutorial: Create and Run a Memory-Enabled Goal Agent¶
This tutorial shows the current generated-agent memory path.
By the end, you will have:
- generated a memory-enabled goal agent package
- installed its dependencies
- run the package locally
- inspected the files that
--enable-memoryadds
Before You Start¶
Make sure amplihack is installed and the amplihack CLI is on your path.
Step 1: Write a Goal Prompt¶
Create a prompt file:
printf '%s\n' \
'Build an agent that investigates deployment failures, remembers repeated causes, and suggests the next debugging step.' \
> goal.md
Step 2: Generate the Agent Package¶
This creates a package in goal_agents/incident-memory-agent/.
Step 3: Inspect the Generated Files¶
For a memory-enabled package, the important additions are:
main.pymemory_config.yamlmemory/.gitignorerequirements.txt
Open main.py and search for these helper functions:
store_successstore_failurestore_patternstore_insightrecall_relevantcleanup_memory
Those helpers are what --enable-memory injects into the generated package.
Step 4: Install the Generated Package Dependencies¶
The generated requirements.txt includes:
amplihackamplihack-memory-lib
Step 5: Run the Generated Agent¶
The generated package runs through AutoMode, using the SDK you selected when you called amplihack new.
Step 6: Understand Where the Memory Lives¶
The generated package creates and owns a local ./memory/ directory.
That is separate from the top-level CLI graph shown by amplihack memory tree and from the agent-local transfer commands amplihack memory export / amplihack memory import.
Step 7: Add a Simple Memory Hook¶
--enable-memory gives you helper functions, but you still need to decide where to call them in your generated package.
A simple first step is to record whether the run succeeded. In main.py, after exit_code = auto_mode.run(), add:
if exit_code == 0:
store_success(
context="Goal execution completed",
outcome=initial_prompt,
confidence=0.95,
)
else:
store_failure(
context="Goal execution failed",
outcome="Exit code {}".format(exit_code),
confidence=0.95,
)
You can also recall previous experiences before starting the run:
recent = recall_relevant(initial_prompt, limit=3)
for item in recent:
print("Previous experience: {} -> {}".format(item.context, item.outcome))
Step 8: Inspect the CLI Memory Graph Separately¶
The top-level CLI memory graph is a different surface, but it is still useful when you are working on the in-repo session graph.
If you want to move a generated agent's hierarchical memory instead of inspecting the top-level graph, use amplihack memory export / amplihack memory import.