1.9 KiB
1.9 KiB
Experience Bus Phase-1 (Router First)
Scope
- Source: router
/v1/agents/{id}/infer - Event subject:
agent.experience.v1.<agent_id> - JetStream stream:
EXPERIENCE(agent.experience.v1.>) - DB table:
agent_experience_events(append-only) - Controls: dedup + sampling
Env knobs
EXPERIENCE_BUS_ENABLED=trueEXPERIENCE_ENABLE_NATS=trueEXPERIENCE_ENABLE_DB=trueEXPERIENCE_DATABASE_URL=postgresql://<user>:<pass>@<host>:5432/daarion_memoryEXPERIENCE_OK_SAMPLE_PCT=10EXPERIENCE_LATENCY_SPIKE_MS=5000EXPERIENCE_DEDUP_WINDOW_SECONDS=900EXPERIENCE_QUEUE_MAX=2000
Deploy
- Apply migration
migrations/054_agent_experience_events.sql. - Deploy router with updated
main.py,experience_bus.py,agent_metrics.py. - Restart router service.
Smoke (30 calls)
for i in $(seq 1 15); do
curl -sS -X POST http://127.0.0.1:9102/v1/agents/agromatrix/infer \
-H 'content-type: application/json' \
-d "{\"prompt\":\"experience smoke agromatrix $i $(date +%s%N)\"}" >/dev/null
done
for i in $(seq 1 15); do
curl -sS -X POST http://127.0.0.1:9102/v1/agents/stepan/infer \
-H 'content-type: application/json' \
-d "{\"prompt\":\"experience smoke stepan $i $(date +%s%N)\"}" >/dev/null
done
Verify JetStream
# example (inside nats container with nats CLI)
nats stream info EXPERIENCE
nats stream view EXPERIENCE --count 5
Verify DB
SELECT count(*)
FROM agent_experience_events
WHERE ts > now() - interval '10 minutes';
Verify lifecycle guard unchanged
curl -sS -o /dev/null -w '%{http_code}\n' -X POST http://127.0.0.1:9102/v1/agents/aistalk/infer -H 'content-type: application/json' -d '{"prompt":"ping"}'
# expected: 410
curl -sS -o /dev/null -w '%{http_code}\n' -X POST http://127.0.0.1:9102/v1/agents/devtools/infer -H 'content-type: application/json' -d '{"prompt":"ping"}'
# expected: 404