## TL;DR
Stop trusting generated values that cannot be traced to a record. The agent produced entitlements that were already revoked, which means it filled gaps in its inputs with plausible inventions. Rebuild the step so every value it emits carries the identifier of the AWS IAM or source record it came from, add a validation pass that rejects any value with no matching source record, and route rejections to a human instead of letting the agent repair them by generating again. Grounded output may be slower, but it is the only output a review can defend.

```text
agent hallucinating entitlements that were already revoked: generated wrong values and validation failed with error
```

## Use this when
- Agent output contains entitlements that were already revoked or similar values that source systems do not support.
- Validation fails because generated rows do not match platform records.
- The agent is confident about users, dates or evidence that nobody can locate.

## Not for this skill when
- The values match an authoritative source that reviewers did not expect. That is a source reconciliation question, not invention.
- The agent output is empty because its inputs were empty. Fix the input collection first.

## Steps
1. Collect the wrong outputs and, for each one, search the authoritative source, AWS IAM and CloudTrail records, recording whether the value exists there in any form. Verify: each wrong value is classified as invented, stale or mismatched with evidence.
2. Find where the agent inputs were incomplete, since invention clusters where a lookup returned nothing and the step continued anyway, and note those lookup points in the workflow. Verify: the gap points that invited invention are listed.
3. Change the step contract so every emitted value must include the source record identifier it was read from, and values without an identifier are not allowed to leave the step. Verify: the step output format requires a source identifier per value.
4. Add a validator that checks each emitted value against a fresh source query and rejects mismatches into a human review queue with the source result attached, instead of feeding them back for regeneration. Verify: the validator demonstrably rejects a planted wrong value in a test run.
5. Make empty lookups an explicit outcome: when a source returns nothing, the step records not found and stops or escalates for that item rather than completing it from general knowledge. Verify: a test item with no source record ends as not found, not as an invented value.
6. Rerun the task to revoke a stale IAM role with grounding and validation on, and audit a random sample of outputs back to source records with a human reviewer. Verify: the sampled outputs all trace to real source records.
7. Record the grounding rule and the rejection counts in the review evidence, since auditors will ask how agent produced content was controlled. Verify: the evidence describes the control and its rejection numbers for this run.

## Why it happens
Language models complete patterns, and a review step that presents a gap, a missing manager, an unknown date, a plausible looking name, is an invitation to complete it. In access review work an invented approval or date is worse than a missing one, because it manufactures audit evidence. Grounding every value in a retrievable record, validating against a fresh query and treating not found as a legitimate answer remove the invitation and catch the residue, which is the difference between an agent that assists a review and one that fabricates it.

## Variants and edge cases

### agent invented values while trying to revoke a stale IAM role
The invention phrasing. Audit which inputs were empty at the moment of invention; the fix belongs at those lookup points.

### how to validate agent output against source records in a review
The control phrasing. Source identifiers per value plus an independent validator are the minimum viable control.

### agent reported entitlements that were already revoked
The specific failure phrasing for this vertical. Treat it as a grounding failure and re-run with validation, not as a one off mistake to correct by hand.

Edge cases to check before closing the review cycle:
- Never assume a timed out call did nothing. Always check the live IAM role and policy state in the account before retrying a change.
- Two retries at the same settings prove nothing. Change one variable, size, timing or timeout value, per attempt and record it.
- Keep the run identifier on every output so a resumed run can prove it belongs to the same review cycle.

Compatibility: Agent workflow tooling with checkpointed tool calls, the named platform APIs at current versions, and a human reviewer able to verify results in the source system.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_MRYNL5qn9srzipMHAHM-Og
