fix(lancedb): tag search span as RETRIEVER + populate input/output#176
Open
SuhaniNagpal7 wants to merge 1 commit into
Open
fix(lancedb): tag search span as RETRIEVER + populate input/output#176SuhaniNagpal7 wants to merge 1 commit into
SuhaniNagpal7 wants to merge 1 commit into
Conversation
The LanceDB instrumentor emits a span for table.search().to_list() /
to_pyarrow() but never sets the FI canonical retriever keys. Future
AGI dashboard shows Type=unknown with empty Input/Output panels.
LanceDB uses a query-builder pattern where the actual query lives on
the builder instance as `_query` / `_limit` rather than in args/kwargs.
The wrapper now reads from those attributes.
Changes (all in traceai_lancedb/_wrappers.py)
- Optional `fi_instrumentation.fi_types` import with raw-string fallback.
- In `SearchWrapper.__call__`:
- Set `gen_ai.span.kind = "RETRIEVER"`.
- Build an input summary {limit, output_format} extended with either
`query` (capped at 500 chars, for text queries) or `vector_dim`
(for vector queries) based on what's on the builder instance.
- Set `input.value` as the JSON summary with `input.mime_type =
application/json`.
- After the wrapped call, set `output.value` based on output_format:
- `to_list` → JSON of the first 50 rows
- PyArrow table (`num_rows` attribute) → JSON via `to_pylist()` or
`to_pydict()` of the first 50 rows
- Set `output.mime_type = application/json` in both cases.
Add/Update/Delete/CreateTable/DropTable/OpenTable are untouched.
Verified end-to-end via Future AGI MCP. `lancedb search` span now
shows Type=Retriever in the dashboard with populated Input/Output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LanceDBInstrumentoremits a span fortable.search()(.to_list()/.to_pyarrow()etc.) but never sets the FI canonical retriever keys. Future AGI dashboard renders the span as Type: unknown with empty Input/Output panels.LanceDB uses a query-builder pattern where the actual query lives on the builder instance as
_query/_limit(instead of being in args/kwargs), so the wrapper reads from those attributes.What changes
All in
traceai_lancedb/_wrappers.py:fi_instrumentation.fi_typesimport with raw-string fallback.SearchWrapper.__call__:gen_ai.span.kind = \"RETRIEVER\"{limit, output_format}extended with eitherquery(capped at 500 chars, for text queries) orvector_dim(for vector queries) based on what's on the builder instance.input.value= JSON of the summary;input.mime_type = application/json.output.valuebased onoutput_format:to_list→ JSON of the first 50 rowsnum_rows) → JSON viato_pylist()orto_pydict()of the first 50 rowsoutput.mime_type = application/jsonin both cases.Add/Update/Delete/CreateTable/DropTable/OpenTableare untouched.Verified
_query=[0.1,0.2,0.3]and_limit=2.lancedb searchspan shows:{\"limit\": 2, \"output_format\": \"to_list\", \"vector_dim\": 3}[{\"id\": \"doc1\", \"text\": \"Eiffel Tower\"}, {\"id\": \"doc2\", \"text\": \"Statue of Liberty\"}]Out of scope
Per-document
retrieval.documents.N.*attrs (Tier 3). Other 6 vector DBs get their own PRs.