Skip to content

added option to choose connection by name from jeen metadata - #31

Merged
yuvalkh merged 2 commits into
mainfrom
yuval/choose-catalog-connection
Aug 5, 2026
Merged

added option to choose connection by name from jeen metadata#31
yuvalkh merged 2 commits into
mainfrom
yuval/choose-catalog-connection

Conversation

@yuvalkh

@yuvalkh yuvalkh commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added a catalog connection selector to the agent testing page, including automatic loading and required selection before submitting.
    • Agent chat now uses the selected catalog connection for schema/metadata.
    • Added an endpoint to retrieve available catalog connections.
  • Bug Fixes
    • Improved ambiguity detection: when the agent generates a clarifying question, the request is now consistently classified as ambiguous.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds catalog connection selection. It sends connection_id from the frontend through the backend and agent state to Jeen metadata requests. It also changes ambiguity classification when clarifying questions are present.

Changes

Connection-aware agent flow

Layer / File(s) Summary
Connection discovery API
backend/app/config.py, backend/app/routers/agent.py
Adds Jeen MCP settings, authenticated client setup, and GET /agent/connections.
Connection selector and chat request
frontend/src/api/agent.ts, frontend/src/pages/AgentTestingPage.tsx, backend/app/routers/agent.py
Loads available connections, replaces the table-status selector, tracks the selected connection, and sends connection_id with chat requests.
Agent connection propagation
agent/src/agent/mcp_server.py, agent/src/agent/state.py, agent/src/agent/nodes/schema_explorer.py, agent/src/agent/utils/jeen_metadata_client.py
Carries connection_id through agent state and uses it for catalog and table metadata requests, with configured-ID fallback.
Ambiguity classification
agent/src/agent/nodes/detect_ambiguity.py
Classifies results with non-empty clarifying questions as ambiguous and reorders AmbiguityResult fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentTestingPage
  participant AgentRouter
  participant Agent
  participant JeenMCP
  AgentTestingPage->>AgentRouter: GET /agent/connections
  AgentRouter->>JeenMCP: list_connections
  JeenMCP-->>AgentRouter: connections
  AgentRouter-->>AgentTestingPage: connection list
  AgentTestingPage->>AgentRouter: ChatRequest(connection_id)
  AgentRouter->>Agent: chat_with_agent(connection_id)
  Agent->>JeenMCP: get_catalog_prompt(connection_id)
  JeenMCP-->>Agent: catalog prompt
Loading

Possibly related PRs

Poem

A rabbit picked a connection bright,
And sent it through the hop at night.
Jeen shared tables, clear and wide,
While ambiguity turned aside.
Hop, hop — the path stayed in sight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: allowing users to choose a Jeen metadata connection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yuval/choose-catalog-connection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
frontend/src/pages/AgentTestingPage.tsx (1)

385-396: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Bind the connection to the active thread.

The catalog selector remains changeable while the thread is interrupted. handleApprove and handleReject then use the current selectedConnection, but agent/src/agent/mcp_server.py:59-87 resumes the persisted graph without replacing its original connection_id. If the user changes the selector, the UI sends one connection while the agent continues with another. Disable the selector for an active thread, or store and reuse the thread's connection ID.

Also applies to: 1054-1066

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/pages/AgentTestingPage.tsx` around lines 385 - 396, The Catalog
Select bound to selectedConnection must not diverge from the active thread’s
persisted connection_id. Update the AgentTestingPage thread state and
approval/rejection flow around handleApprove and handleReject so an active
thread either disables the selector or reuses its stored connection ID; apply
the same behavior to the corresponding selector instance near the alternate
location.
backend/app/routers/agent.py (1)

360-362: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Surface connection-discovery failures instead of treating them as an empty catalog.

The backend returns success with an empty list for MCP failures, and the frontend only logs rejected requests. Users cannot distinguish “no connections” from an unavailable or unauthorized catalog service.

  • backend/app/routers/agent.py#L360-L362: return a failure response or explicit error payload.
  • frontend/src/pages/AgentTestingPage.tsx#L912-L915: render the failure and provide retry feedback.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/routers/agent.py` around lines 360 - 362, Surface the MCP
connection-discovery failure instead of converting it to an empty list: update
the error path in agent.py around the list-connections handler so it returns a
failure response or explicit error payload from the same exception branch that
currently logs and returns {"connections": []}. Then update AgentTestingPage.tsx
in the request-handling/rendering path to detect that failure payload, show the
error state to the user, and offer retry feedback instead of treating it as an
empty catalog or only logging the rejection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@backend/app/routers/agent.py`:
- Around line 360-362: Surface the MCP connection-discovery failure instead of
converting it to an empty list: update the error path in agent.py around the
list-connections handler so it returns a failure response or explicit error
payload from the same exception branch that currently logs and returns
{"connections": []}. Then update AgentTestingPage.tsx in the
request-handling/rendering path to detect that failure payload, show the error
state to the user, and offer retry feedback instead of treating it as an empty
catalog or only logging the rejection.

In `@frontend/src/pages/AgentTestingPage.tsx`:
- Around line 385-396: The Catalog Select bound to selectedConnection must not
diverge from the active thread’s persisted connection_id. Update the
AgentTestingPage thread state and approval/rejection flow around handleApprove
and handleReject so an active thread either disables the selector or reuses its
stored connection ID; apply the same behavior to the corresponding selector
instance near the alternate location.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6a4094c8-aa97-4766-8aaa-0d011f265d0a

📥 Commits

Reviewing files that changed from the base of the PR and between 44cad72 and e8e28d9.

📒 Files selected for processing (4)
  • agent/src/agent/mcp_server.py
  • agent/src/agent/state.py
  • backend/app/routers/agent.py
  • frontend/src/pages/AgentTestingPage.tsx

@yuvalkh
yuvalkh merged commit 0f863a6 into main Aug 5, 2026
1 check passed
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