Inspiration
AI agents are increasingly capable, but their work is still fragile across sessions. A transcript is not a reliable memory system. Important constraints disappear in noise, decisions lose provenance, outdated plans return as if they were current, and the next agent cannot tell which action was actually approved. We built Relay to make the handoff itself a trustworthy system boundary.
What it does
Relay records attributable project memory as typed records: objectives, constraints, decisions, failed approaches, evidence, open questions, and authorized next actions. Each record carries authority, provenance, a content hash, and an embedding. Superseded memory remains auditable but is excluded from active guidance.
When another agent requests continuation, Relay performs project-scoped semantic retrieval, applies deterministic authority rules, and creates a compact packet with ordered citations to the exact source memories. It persists the request, packet, citations, acknowledgment, and audit trail. Repeating the same completed request returns the existing handoff rather than duplicating records or paying for another embedding workflow.
The browser judge workflow is deliberately fixed and sanitized. Judges choose a bounded slot, while the server supplies the project and scenario. They cannot submit arbitrary project IDs or arbitrary application data.
How we built it
The domain core is TypeScript with ports for persistence and embeddings. The production adapter uses the PostgreSQL wire protocol to connect AWS Lambda to CockroachDB Cloud and retries serializable transactions on CockroachDB SQLSTATE 40001. The complete handoff is persisted transactionally.
Amazon Bedrock Titan Embeddings G1, model amazon.titan-embed-text-v1, creates exactly 1,536-dimensional vectors. CockroachDB stores those vectors and runs project-scoped cosine retrieval against a schema containing a project-prefixed Distributed Vector Index. API Gateway exposes an IAM-authorized production route and a separate bounded judge-demo surface backed by the same Lambda.
Local tests use dependency injection and explicitly labeled mocks. Production claims come from the controlled live proof, not from those mocks.
How CockroachDB is materially used
CockroachDB is Relay's source of truth, transaction coordinator, audit store, and vector retrieval engine. Thirteen tables and one state view represent project identity, actors, sessions, evidence, append-only memory and supersession, embeddings, continuation requests, packets, citations, acknowledgments, and audit events.
The verified memory_embeddings_project_cosine_idx Distributed Vector Index uses project_id as a prefix and cosine distance over VECTOR(1536). Retrieval is constrained to the same project on both memory and embedding rows. A supersession view prevents obsolete records from entering active guidance.
The live seven-row demonstration confirmed the index definition. Its sanitized EXPLAIN selected ordinary indexes rather than the Distributed Vector Index, so optimizer selection is not claimed for this small dataset.
The controlled production workflow returned HTTP 201 on first use and HTTP 200 with replayed:true on the exact replay. A read-only CockroachDB verification confirmed all 13 expected deterministic counts and no duplicate workflow records.
CockroachDB Cloud Managed MCP provided the receiving agent's independent verification channel. Through a single-cluster OAuth connection with mcp:read access only, it reverified the packet, acknowledgment, six active citations, superseded-memory exclusion, four audit events, deterministic identifiers, and all 13 expected counts without a database mutation.
Challenges encountered
The most difficult work was not the happy path. It was making the boundary safe under real infrastructure constraints. We had to handle CockroachDB serializable retries, INSERT ... ON CONFLICT privilege requirements, append-only supersession, project-prefixed vector retrieval, native ESM bundling for Node.js 22, secret-safe diagnostics, Lambda concurrency containment, and idempotency across a workflow that includes paid embeddings.
A deployed ESM bundle initially failed during module initialization because a bundled dependency attempted a dynamic Node.js require. We added a minimal createRequire shim and a clean-process import regression test. The first database attempt then exposed missing SELECT privileges required by CockroachDB conflict handling. We repaired only the five missing table grants, verified the least-privilege contract, and reran the controlled proof.
Accomplishments
- A real Lambda-to-Bedrock-to-CockroachDB first-use workflow completed successfully.
- The exact replay returned the same deterministic handoff with
replayed:true. - All 13 expected CockroachDB counts matched after replay.
- Project isolation, supersession exclusion, packet citations, acknowledgment, and audit evidence were verified.
- The Distributed Vector Index is live with a mandatory
project_idprefix; the seven-row planner result honestly remains unproven. - CockroachDB Managed MCP independently reverified the fixed project through read-only access.
- The runtime identity and AWS policies are narrow, reviewed, and separated from operator authority.
- The public judge workflow accepts no arbitrary project or content input and has explicit rate, quota, and shutdown controls.
What we learned
Agent memory needs more than retrieval quality. It needs authority, provenance, lifecycle state, isolation, idempotency, and evidence that another agent can inspect. Vector similarity is useful for finding candidates, but it cannot decide what is true or authorized. Reliable handoffs come from combining semantic retrieval with deterministic domain rules and an auditable transaction boundary.
We also learned that cost containment and security are product features. A bounded input space, replay-before-embedding behavior, strict payload limits, least-privilege identities, sanitized errors, and a reliable concurrency-zero shutdown made it possible to test the live workflow safely.
What comes next
Following the contest, likely extensions include stronger caller-to-project authorization, multi-tenant isolation, richer evidence connectors, and operational monitoring. These are future work, not claims about the frozen submission build.
Built With
- amazonapigateway
- amazonbedrock
- awslambda
- cockroachdb
- mcp
- node.js
- typescript
Log in or sign up for Devpost to join the conversation.