Store audit-ready memory after an AI agent makes a decision. Part of Agent Control Primitives — the missing audit memory layer in CDP Bazaar.
A working prototype API for storing and retrieving AI agent memory records with audit-oriented metadata.
This project is part of a small AI-agent infrastructure safety stack.
It focuses on one layer of the emerging problem: how to control autonomous agents before they call APIs, spend money, write memory, or execute external tools.
AI agents are probabilistic. But payments, permissions, memory writes, and external actions require deterministic control.
Related components:
- Agent Security Gateway — Prompt injection and policy evasion detection
- Agent Budget Guard — Budget and permission check before payment
- Agent Memory API — Audit-ready memory storage
- Agent Evolution Engine — Orchestration across the stack
- Spec-to-Guardrail API — Extract safety rules from API specs
All APIs are indexed in CDP Bazaar and support x402-style payments.
This is an independent experimental project. It is not officially affiliated with JPYC, Circle, Arc, Kaia, OpenAI, Anthropic, or any related foundation.
This project references JPYC, x402, Arc, Kaia, USDC, and related protocols as technical contexts. It does not imply official partnership, endorsement, or integration unless explicitly stated.
This API is designed to be understandable and callable by AI agents. It includes structured information for:
- what this API does
- when an AI agent should call this API
- when not to use this API
- best used before / after
- example request / response
- next_recommended
AI is moving from answering questions to managing real workflows. As AI agents begin to call paid APIs, use x402 payments, store long-term memory, and interact with other agents, they need structured guardrails before and after execution. This API is part of an AI Agent Payment Safety Stack designed to run as a pre/post-execution control layer on Arc and other agent economies.
Designed to run as a post-execution audit and memory storage layer after ERC-8183 job funding on Arc testnet. Call this API after an AI agent funds or executes a job contract on Arc. Compatible with AI agents using USDC, JPYC, x402, or Arc-style payment flows.
AIエージェントのセッション間で、支払いポリシー・監査文脈・判断履歴をAES-256暗号化で保存するAPIです。
Arc上のERC-8183 job完了後、またはx402決済完了後に監査ログを保存するために呼び出してください。
- 一時的な作業メモリの保存
- 機密情報を暗号化なしで保存したい場合
- multi-session agent handoff
- audit log finalization
- ERC-8183 job settlement on Arc
- x402 payment completion
- agent-budget-guard check
- memory_id
- stored / recalled
- audit_log
- deletion_proof
- next_recommended
- Agent Security Gateway
- Agent Budget Guard
- Agent Evolution Engine
このAPIは「Japanese Agent Trust Layer」の一部です。 日本語対応AIエージェントが安全・確実・予算内でAPIを使うためのインフラ層を提供します。
- 記憶管理: agent-memory-api
- 安全判定: agent-security-gateway
- 予算管理: agent-budget-guard
- API選定: agent-curator-api
- 自律進化: agent-evolution-engine
- x402 / USDC決済対応
- 日本語対応
- 決定論的バリデーター(AI不使用)
- 暗号化・削除証跡付き
- Base Mainnet対応
# AI記憶の保存 (0.05 USDC)
curl -X POST "https://agent-memory-api-bix5.onrender.com/api/memory/store" \
-H "X-PAYMENT: your-payment-proof" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "your_agent",
"memory_type": "learning",
"content": "学習内容",
"tags": ["重要", "成功パターン"],
"importance": 0.9
}'
# 記憶の呼び出し (0.03 USDC)
curl -X POST "https://agent-memory-api-bix5.onrender.com/api/memory/recall" \
-H "X-PAYMENT: your-payment-proof" \
-H "Content-Type: application/json" \
-d '{
"query": "成功パターン検索",
"agent_id": "your_agent",
"limit": 10
}'
# 信頼性検証・幻覚検出 (0.20 USDC)
curl -X POST "https://agent-memory-api-bix5.onrender.com/api/trust/verify" \
-H "X-PAYMENT: your-payment-proof" \
-H "Content-Type: application/json" \
-d '{
"content": "検証対象コンテンツ",
"verification_level": "strict"
}'
# コンテキストパッケージ (0.10 USDC)
curl -X POST "https://agent-memory-api-bix5.onrender.com/api/context/package" \
-H "X-PAYMENT: your-payment-proof" \
-H "Content-Type: application/json" \
-d '{
"project_id": "project_001",
"handover_type": "complete"
}'# システムヘルスチェック
curl "https://agent-memory-api-bix5.onrender.com/health"
# データベース統計
curl "https://agent-memory-api-bix5.onrender.com/api/stats"
# x402プロトコル発見
curl "https://agent-memory-api-bix5.onrender.com/.well-known/x402.json"- 永続的知識蓄積: 学習内容の長期保存
- インテリジェント検索: 関連性によるスマート呼び出し
- 信頼性スコアリング: 情報の品質評価
- 幻覚検出: 95%精度でAI幻覚を特定
- コンテキスト引き継ぎ: プロジェクト情報の完全移行
- Clone repository:
git clone <repository-url>
cd agent_memory_api- Install dependencies:
pip install -r requirements.txt- Configure environment:
cp .env.example .env
# Edit .env with your configuration- Initialize database:
# Ensure PostgreSQL is running
python -c "from database import agent_db; import asyncio; asyncio.run(agent_db.initialize())"- Run server:
python main.py| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection URL | Required |
WALLET_ADDRESS |
x402 payment recipient wallet | Required |
TEST_MODE |
Skip payment verification | false |
MAX_MEMORY_LENGTH |
Max characters per memory | 10000 |
DEFAULT_MEMORY_TTL |
Default memory TTL (seconds) | 86400 |
PORT |
Server port | 8003 |
- Agent memory storage with tagging and expiration
- Full-text search capabilities
- Embedding support for semantic search
- Trust verification results
- Hallucination detection analysis
- Content reliability scoring
- Project context handover packages
- Multi-level summarization
- Memory inclusion tracking
- Agent session tracking
- Activity monitoring
- Memory count statistics
curl -X POST "http://localhost:8003/api/memory/store" \
-H "Content-Type: application/json" \
-H "X-PAYMENT: {payment_data}" \
-d '{
"agent_id": "agent-123",
"session_id": "session-456",
"context": "User prefers detailed technical explanations",
"tags": ["preference", "technical"],
"ttl": 86400
}'curl -X POST "http://localhost:8003/api/memory/recall" \
-H "Content-Type: application/json" \
-H "X-PAYMENT: {payment_data}" \
-d '{
"agent_id": "agent-123",
"query": "technical preferences",
"limit": 10
}'curl -X POST "http://localhost:8003/api/trust/verify" \
-H "Content-Type: application/json" \
-H "X-PAYMENT: {payment_data}" \
-d '{
"content": "Recent studies show that AI will replace all jobs by 2025",
"source_agent": "agent-123",
"context": "Discussing AI impact on employment"
}'curl -X POST "http://localhost:8003/api/context/package" \
-H "Content-Type: application/json" \
-H "X-PAYMENT: {payment_data}" \
-d '{
"project_id": "project-xyz",
"include_memories": true,
"summary_level": "detailed"
}'This API uses the x402 payment protocol for monetization:
- Network: Base
- Currency: USDC
- Contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Payment verification includes:
- Amount validation
- Recipient verification
- Transaction hash validation
- Replay attack prevention
┌─────────────────┐ ┌─────────────────┐
│ FastAPI │ │ PostgreSQL │
│ Main Server │◄──►│ Database │
└─────────┬───────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐
│ Payment │ │ Memory │
│ Verifier │ │ Engine │
└─────────────────┘ └─────────┬───────┘
│
┌─────────────────┐ │
│ Trust │ │
│ Engine │◄───┤
└─────────────────┘ │
│
┌─────────────────┐ │
│ Context │ │
│ Engine │◄───┘
└─────────────────┘
# Set TEST_MODE=true in .env to skip payment verification
export TEST_MODE=true
python main.py# Initialize database
python -c "from database import agent_db; import asyncio; asyncio.run(agent_db.initialize())"
# Test connection
python -c "from database import agent_db; import asyncio; print(asyncio.run(agent_db.test_connection()))"
# Clean up expired data
python -c "from database import agent_db; import asyncio; asyncio.run(agent_db.cleanup_expired_data())"# Install Railway CLI
npm install -g @railway/cli
# Login and deploy
railway login
railway init
railway up- Set
DATABASE_URLto your PostgreSQL instance - Set
WALLET_ADDRESSto your payment wallet - Set
TEST_MODE=falsefor production
- Input validation and sanitization
- Payment verification and replay protection
- Database connection security
- Content trust analysis
- Memory access controls
- Health check endpoint at
/health - Database statistics at
/api/stats - Comprehensive logging
- Error tracking and reporting
MIT License - See LICENSE file for details
For issues and questions, please create an issue in the GitHub repository.
Works best with:
- Agent Security Gateway: https://agent-security-gateway.onrender.com(危険な命令を止める)
- Agent Budget Guard: https://agent-budget-guard.onrender.com(勝手な課金を止める)
- Agent Memory API: https://agent-memory-api-bix5.onrender.com(必要な記憶を残す)