feat(runtime): sync experience bus and learner stack into main
This commit is contained in:
61
docs/ops/experience_bus_phase1.md
Normal file
61
docs/ops/experience_bus_phase1.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# 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=true`
|
||||
- `EXPERIENCE_ENABLE_NATS=true`
|
||||
- `EXPERIENCE_ENABLE_DB=true`
|
||||
- `EXPERIENCE_DATABASE_URL=postgresql://<user>:<pass>@<host>:5432/daarion_memory`
|
||||
- `EXPERIENCE_OK_SAMPLE_PCT=10`
|
||||
- `EXPERIENCE_LATENCY_SPIKE_MS=5000`
|
||||
- `EXPERIENCE_DEDUP_WINDOW_SECONDS=900`
|
||||
- `EXPERIENCE_QUEUE_MAX=2000`
|
||||
|
||||
## Deploy
|
||||
1. Apply migration `migrations/054_agent_experience_events.sql`.
|
||||
2. Deploy router with updated `main.py`, `experience_bus.py`, `agent_metrics.py`.
|
||||
3. Restart router service.
|
||||
|
||||
## Smoke (30 calls)
|
||||
```bash
|
||||
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
|
||||
```bash
|
||||
# example (inside nats container with nats CLI)
|
||||
nats stream info EXPERIENCE
|
||||
nats stream view EXPERIENCE --count 5
|
||||
```
|
||||
|
||||
## Verify DB
|
||||
```sql
|
||||
SELECT count(*)
|
||||
FROM agent_experience_events
|
||||
WHERE ts > now() - interval '10 minutes';
|
||||
```
|
||||
|
||||
## Verify lifecycle guard unchanged
|
||||
```bash
|
||||
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
|
||||
```
|
||||
Reference in New Issue
Block a user