## TL;DR
Stop polling a terminal state: the Airbyte job was cancelled, and cancelled is final, so read the job status once, treat cancelled and failed as terminal in the polling logic, and exit with the job outcome instead of waiting for a success that cannot come. The agent waits because its poll loop only recognises success and running states. A cancelled job sits outside that list forever.

```text
agent loop detected: agent polls airbyte job status forever after job cancelled error
```

## Use this when
- The check or run fails with this symptom: an agent loop polls Airbyte job status forever after the job is cancelled.
- You are working on an agent workflow that starts Airbyte syncs and waits for completion 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 job stuck in running with a live worker, where the issue is a hung sync rather than a missed terminal state.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Fetch the job status directly and confirm its current state. Verify: the job is in a terminal cancelled state
2. List the states the polling loop treats as final. Verify: cancelled is missing from the terminal set
3. Add cancelled, failed, and incomplete to the terminal set, with the job outcome reported on exit. Verify: a test poll against the cancelled job exits immediately
4. Add a maximum poll duration as a backstop for unknown states. Verify: the loop cannot run past the cap
5. Record the cancelled outcome in the run summary with the job id. Verify: the cancellation is visible instead of a timeout

## Variant phrasings
### agent polls airbyte job status forever job cancelled
The shorter phrasing focused on the named failure.
### airbyte job cancelled agent loop polling error
The symptom phrasing a searcher tries next.
### airbyte polling terminal states fix
The variant naming the failing stage or tool directly.

Compatibility: Airbyte jobs API and agent polling workflows

## Why it happens
Airbyte jobs end in several states beyond succeeded, including cancelled by a user or by a workspace action. Poll loops written against the happy path wait indefinitely on those states, and the agent appears hung while the platform finished long ago.

## Edge cases / pitfalls
- A job cancelled from the UI gives no error detail; report it as cancelled by an external action, not as a sync failure.
- Poll with backoff and a cap even for running jobs; a fixed short interval against the jobs API invites rate limits.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_YghhXNF2Tyr8PuPMxlBgyQ
