Skip to content

rig-surrealdb: support dynamic_context #1646

Merged
gold-silver-copper merged 1 commit into0xPlaygrounds:mainfrom
gold-silver-copper:codex/surrealdb-dyn-fix
Apr 17, 2026
Merged

rig-surrealdb: support dynamic_context #1646
gold-silver-copper merged 1 commit into0xPlaygrounds:mainfrom
gold-silver-copper:codex/surrealdb-dyn-fix

Conversation

@gold-silver-copper
Copy link
Copy Markdown
Contributor

Fixes #1644.

Summary

dynamic_context(...) currently does not work with rig-surrealdb because the blanket
VectorStoreIndexDyn impl in rig-core assumes backends whose filter value type is
serde_json::Value, while SurrealSearchFilter intentionally uses native
surrealdb::types::Value.

This PR fixes that incompatibility without changing the public SurrealDB filter API.

What changed

  • kept SurrealSearchFilter::Value = surrealdb::types::Value
  • added TryFrom<Filter<serde_json::Value>> for SurrealSearchFilter
  • added an explicit VectorStoreIndexDyn impl for SurrealVectorStore
    that converts canonical JSON filters with try_map_filter(SurrealSearchFilter::try_from)
    before delegating to the native VectorStoreIndex implementation
  • used SurrealDB’s native Value::from_t(...) conversion path instead of a custom JSON-to-Value mapper
  • added regression tests for:
    • nested JSON filter conversion
    • dyn compatibility for SurrealVectorStore
  • added a clearer vector_store example with explicit top-hit assertions
  • updated SurrealDB example targets to require rig-core/rustls, since they call OpenAI

Manually ran:

  • cargo run -p rig-surrealdb --example vector_store --features rig-core/rustls

The updated example now returns pasta carbonara as the expected top hit and
asserts that the thresholded query narrows to that single result.

@gold-silver-copper gold-silver-copper added this pull request to the merge queue Apr 17, 2026
Merged via the queue into 0xPlaygrounds:main with commit 6535e73 Apr 17, 2026
5 of 6 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 17, 2026
This was referenced Apr 27, 2026
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.

bug: type mismatch on SurrealDB integration

1 participant