Skip to content

[FEAT] agentic-core conversation and responses database CRUD.#33

Open
maralbahari wants to merge 10 commits into
vllm-project:mainfrom
EmbeddedLLM:impl-database-crud
Open

[FEAT] agentic-core conversation and responses database CRUD.#33
maralbahari wants to merge 10 commits into
vllm-project:mainfrom
EmbeddedLLM:impl-database-crud

Conversation

@maralbahari
Copy link
Copy Markdown
Collaborator

@maralbahari maralbahari commented May 28, 2026

Summary

This will be part of agentic-core after #29 merged will open for review

Integrated complete SQLx-based storage layer for persistent conversation and response management. Implements trait-based CRUD operations with connection pooling supporting SQLite, PostgreSQL, and MySQL. Two main stores (ConversationStore and ResponseStore) handle persisting input/output items with metadata and rehydrating full conversation/response history from database.

Features:

  • Database connection pooling with optional URL configuration (defaults to SQLite)
  • ConversationStore: persist turns with items and responses, rehydrate full conversation history
  • ResponseStore: persist responses with items and metadata, rehydrate by response ID
  • Schema migrations and initialization via SchemaManager
  • Type-safe database models with sqlx FromRow derive

Test Plan

Unit tests (39 passing):

  • Model CRUD operations, schema initialization, type conversions, error handling
  • IO conversion from data types resulted from database models to Rust data types.

Integration tests (18 passing):

  • Store-level CRUD, error handling for disabled/missing resources
  • Multi-turn conversations with response chaining
  • Concurrent operations, foreign key constraints, edge cases

Benchmarks:

  • conversation_persist: measure insertion of items and response records
  • response_persist: measure response creation with item tracking
  • conversation_rehydrate: measure full conversation retrieval from database
  • response_rehydrate: measure response history lookup by ID

All tests pass. No clippy warnings.

Running Benchmarks

To run the storage CRUD benchmarks:

cargo bench -p agentic-core --bench storage_crud 

Or run with specific sample count and target time:

cargo bench -p agentic-core --bench storage_crud -- --sample-size 100 --warm-up-time 3.000 s

Benchmark Results

Benchmarking conversation_persist
conversation_persist    time:   [1.4119 ms 1.4390 ms 1.4663 ms]

Benchmarking response_persist
response_persist        time:   [893.67 µs 908.53 µs 923.55 µs]

Benchmarking conversation_rehydrate
conversation_rehydrate  time:   [1.4377 ms 1.4701 ms 1.5037 ms]

Benchmarking response_rehydrate
response_rehydrate      time:   [1.0061 ms 1.0270 ms 1.0488 ms]

Performance Notes

Response persist is ~1.5x faster than conversation persist because:

  • ResponseStore.persist() stores history_item_ids directly in the responses table (single lookup)
  • ConversationStore.persist() must query the items table to determine the next sequence number for conversation items (additional query)

Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
@maralbahari maralbahari marked this pull request as ready for review May 29, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant