## TL;DR
Print and pin the active data context before validating: load the context from the project's great_expectations directory explicitly, log its mode and datasource list, and fail fast if the datasources do not match the project the agent thinks it is in. A wrong context, such as an ephemeral one or another project's config, validates the wrong data or nothing at all while looking like a configuration error elsewhere.

```text
when agent tried to run great expectations validation agent used wrong data context error failed
```

## Use this when
- The check or run fails with this symptom: the agent ran validation against the wrong Great Expectations data context.
- You are working on an agent running Great Expectations validation from a script or notebook and the failure repeats on the same data or configuration.
- You need the failing rows, rule, or stage isolated before changing thresholds or code.

## Not for this skill when
- A project that intentionally uses an ephemeral context in tests, where the fix is constructing it with the right datasources rather than loading a file context.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Instantiate the context from the explicit project directory and log the context mode and configured datasource names. Verify: the run output states which context and datasources are active
2. Compare the active datasources against the project's expected list and stop on any mismatch before running checkpoints. Verify: a mismatch halts the run with the two lists shown
3. Run one checkpoint and open its result to confirm the validated table is the intended one. Verify: the result names the expected table and batch
4. Record the context path in the run report so later failures can be compared against the same configuration. Verify: the report carries the context location used

## Variant phrasings
### agent used wrong data context great expectations
The wrong-context phrasing.
### validation ran against wrong project gx agent
The wrong-project phrasing.
### great expectations ephemeral context agent missing suites
The ephemeral-context phrasing.

Compatibility: Agents running Great Expectations checkpoints and validations programmatically

## Why it happens
Great Expectations resolves its context from several sources, working directory, environment, or an ephemeral default, and an agent running from a different directory silently gets a different context. The validation then runs faithfully against the wrong configuration, so the error looks like missing suites or empty results instead of a wrong starting point.

## Edge cases / pitfalls
- Multiple projects on one machine make working-directory drift common; pass the context path as an argument, never rely on the current directory.
- An empty result set from the wrong context can look like passing validation; assert the batch row count is nonzero.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_j-EqwN90hEuPkeTgdtYKvg
