fix: surface project context in system prompt for connection discovery#278
Closed
suryaiyer95 wants to merge 2 commits intomainfrom
Closed
fix: surface project context in system prompt for connection discovery#278suryaiyer95 wants to merge 2 commits intomainfrom
suryaiyer95 wants to merge 2 commits intomainfrom
Conversation
Inject a `<project-context>` block into the system prompt based on the workspace fingerprint, so the LLM agent knows how to handle SQL connections appropriately for the open project. - dbt project detected: try dbt connection first (profiles.yml), fall back to configured warehouse, then ask user for credentials — with the detected adapter type (e.g. snowflake, bigquery) pre-filled in the prompt - No dbt project: check for existing warehouse connection, ask user for adapter-scoped credentials if none is configured The LLM is explicitly told not to assume the dbt connection will succeed, ensuring graceful fallback and correct credential prompting when it fails. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances the session system prompt by injecting a <project-context> block derived from workspace fingerprinting so the agent can make better, adapter-specific decisions when discovering SQL/dbt/warehouse connections.
Changes:
- Build the environment system prompt as an array (
parts) and optionally append a<project-context>section. - Detect workspace tags (including dbt + warehouse adapter) and add connection-discovery guidance to the system prompt based on those tags.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…drift - Wrap fingerprint detection in try/catch so a failure never blocks session startup (addresses Sentry MEDIUM bug report) - Call `Fingerprint.detect()` directly instead of `get() ?? detect()`: `detect()` already caches per-cwd, so this is equivalent but avoids injecting stale tags when the cwd changes (addresses Copilot comment) - Export `ADAPTER_TAGS` from fingerprint module as the single source of truth; reuse it in both `detectDir` (replacing the hardcoded regex) and the system prompt builder — fixes the missing `sqlite` and prevents future drift (addresses Copilot comment) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
<project-context>block into the system prompt based on workspace fingerprint detectionprofiles.yml), fall back to a configured warehouse connection, and ask the user for credentials (scoped to the detected adapter) if both failsnowflake,bigquery) is surfaced in both paths so credential prompts are specific, not genericMotivation
Previously the agent had no awareness of the open project's connection context. It would either silently fail or ask for generic credentials. This change makes the agent behave like it understands the environment — trying the right path first and asking the right questions when things don't work.
Test plan
profiles.yml— agent should use dbt connection without asking for credentials.sqlfluff+ snowflake) — agent should ask for warehouse credentials scoped to that adapter<project-context>block should be omitted entirely🤖 Generated with Claude Code