Skip to content

feat: include index_id in context grounding tool output for tracing#742

Open
cfauchere wants to merge 3 commits intomainfrom
feat/add-index-id-to-cg-trace
Open

feat: include index_id in context grounding tool output for tracing#742
cfauchere wants to merge 3 commits intomainfrom
feat/add-index-id-to-cg-trace

Conversation

@cfauchere
Copy link
Copy Markdown

Summary

  • Capture index_id from the SDK's unified_search result on ContextGroundingRetriever (both sync and async paths)
  • Include index_id in the semantic search tool return value so the trace instrumentor in uipath-agents-python can write it to the contextGroundingTool span

Context

The contextGroundingTool trace span has an index_id field defined in uipath-agents-python (ContextGroundingToolSpanAttributes.index_id), and set_context_grounding_results already looks for content.get("index_id") in the tool output. But it was never populated because:

  1. The SDK resolves index_nameindex_id internally in unified_search but doesn't return it
  2. The retriever discards it
  3. The tool output only contains {"documents": [...]}

Without index_id in the trace, debugging Context Grounding issues (like empty search results) requires manual lookup — you can't go from the trace to the CG service logs.

Dependencies

Requires a corresponding change in uipath-python to expose index_id on UnifiedQueryResult. Until then, resolved_index_id will be None (the code uses getattr with a fallback to avoid breaking).

Test plan

  • Verify resolved_index_id is populated after unified_search when SDK exposes index_id
  • Verify index_id appears in the contextGroundingTool trace span attributes
  • Verify no regression when SDK does not yet expose index_id (getattr fallback returns None)

🤖 Generated with Claude Code

The context grounding tool's trace span has an index_id field but it was
never populated because the tool output didn't include it. The index ID
is resolved inside the SDK's unified_search but discarded before reaching
the instrumentor.

This change captures the resolved index_id from the search result on the
retriever and includes it in the semantic search tool return value, so
the trace instrumentor in uipath-agents-python can write it to the span.

Requires a corresponding SDK change to expose index_id on UnifiedQueryResult.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Clement Fauchere and others added 2 commits March 31, 2026 18:53
Depends on UiPath/uipath-python#1534 which exposes index_id on the result.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Depends on UiPath/uipath-python#1534.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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