memcode / neuron-ai
Durable long-term memory tools for Neuron AI agents, powered by Memcode.
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.0 || ^8.0
- neuron-core/neuron-ai: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Durable long-term memory tools for Neuron AI, powered by Memcode.
The package follows Neuron's toolkit extension pattern. It keeps Neuron's current chat history intact while giving agents explicit tools to save, inspect, search, and retrieve durable memory across conversations.
Install
composer require memcode/neuron-ai
Requires PHP 8.1+ and Neuron AI 3.x.
Configure
Create an API key in Memcode and expose it to your application:
MEMCODE_API_KEY=mc_live_...
The constructor accepts any valid Memcode bearer credential, including a server-issued OAuth access token.
Add durable memory to an agent
<?php declare(strict_types=1); namespace App\Neuron; use Memcode\NeuronAI\MemcodeMemoryToolkit; use NeuronAI\Agent; use NeuronAI\Providers\AIProviderInterface; use NeuronAI\Providers\Anthropic\Anthropic; final class PersonalAssistant extends Agent { protected function provider(): AIProviderInterface { return new Anthropic( key: getenv('ANTHROPIC_API_KEY'), model: 'claude-sonnet-4-6', ); } protected function tools(): array { return [ MemcodeMemoryToolkit::make( token: getenv('MEMCODE_API_KEY'), ), ]; } }
Neuron automatically registers the toolkit guidelines and these tools:
| Tool | Purpose |
|---|---|
save_memory |
Start a durable asynchronous memory ingest job |
get_memory_ingest_status |
Check the status of an ingest job |
list_memories |
Page through stored memories |
search_memories |
Search extracted memories and original chunks |
retrieve_answer |
Answer a question from memory with ranked sources |
Select tools
Neuron toolkits support only() and exclude():
use Memcode\NeuronAI\MemcodeMemoryToolkit; use Memcode\NeuronAI\Tools\ListMemoriesTool; $memory = MemcodeMemoryToolkit::make(getenv('MEMCODE_API_KEY')) ->exclude([ListMemoriesTool::class]);
Self-hosted API
Pass a different API base URL as the second argument:
$memory = MemcodeMemoryToolkit::make( token: getenv('MEMCODE_API_KEY'), baseUri: 'https://memory.example.com', );
Authentication and attribution
Identity and integration attribution are derived by the Memcode authorization server from the bearer credential. This package intentionally does not accept or send caller-controlled user_id, integration_id, channel, or verification fields.
- API-key requests are attributed as direct API usage.
- OAuth access tokens retain the server-issued integration attribution associated with the authorization flow.
Never put credentials in prompts or tool arguments. Configure the token only when constructing the toolkit.
Development
composer install composer check
The tests use Guzzle's mock handler and do not call the live Memcode service.
License
MIT