mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Product journeys test real hiring and delegation on a hosted test
stack every day.
> - The hire-delegate-reuse journey failed on three attempts today, at
three different steps.
> - One failure graded a hired agent's run as final while its
exact-session retry was still scheduled. #22826 fixed the same gap for
agent task journeys, but the hire observer has its own run check.
> - The other two failures recorded only `journey_operation_failed`. The
API client gives fixed failure codes, but the journey result dropped
them.
> - This pull request makes the hire observer wait for a scheduled
same-run retry, and it keeps the fixed API failure codes in the
evidence.
> - The benefit is fewer false failures, and a clear failure code when a
hosted API call fails.
## Linked Issues or Issue Description
Refs #22826, #22825
**What happened?**
The daily QA staging smoke failed `hire-delegate-reuse` three times on
2026-11-25:
1. Setup failed after the lead agent was created. The result said only
`journey_operation_failed`.
2. The lead hired the teammate and replied. On the next observation the
journey failed with `journey_operation_failed`.
3. The first delegated task completed. During the review task, the hired
agent's run was `running`. One second later the journey failed with
`hire_native_run_failed`.
**Expected behavior**
A failed native run with an agent-owned exact-session retry scheduled
inside the campaign deadline is still in progress. The journey keeps
observing it. A failure caused by an API status or transport error is
recorded with that fixed code, for example `api_status_500`.
**Steps to reproduce**
Run the new tests against the previous code. `assertHireRuns` throws
`hire_native_run_failed` for a pending same-run retry. `journeyFailure`
turns `ConnectionFailure("api_status_500")` into
`journey_operation_failed`.
**Paperclip version or commit**
Harness pin 6d5541b109 on the QA staging
smoke.
## What Changed
- `assertHireRuns` takes an optional campaign deadline. With it, a run
that `isPendingNativeRecovery` accepts is not treated as failed. The
observer passes `options.deadlineAt`. The idle wait still needs every
run to succeed, so a pending retry never counts as completion.
- `journeyFailure` keeps a `ConnectionFailure` code when it is one of
the fixed codes: `api_status_NNN`, `api_request_failed`,
`sensitive_api_request_failed`, `invalid_api_route`,
`invalid_api_timeout`. It matches the class by name as well, because the
Cloud provider can load its own copy of the class. Other errors still
become `journey_operation_failed`.
## Verification
- Red: the new hire recovery test and three new `journeyFailure` tests
failed on the previous code.
- Green: `npx vitest run --config tests/runner-e2e/vitest.config.ts` on
`hire-delegate-evidence`, `hire-delegate-flow`, `journey-failure`,
`agent-recovery` and `campaign`: 124 tests pass.
- `node scripts/typecheck-test-projects.mjs tests/runner-e2e` passes.
- SDK input pins refreshed with `source-sdk-public-inputs.mjs --write`.
No change.
- After merge, I will pin `QA_SMOKE_HARNESS_SHA` to the merge commit and
run `hire-delegate-reuse` alone on staging.
## Risks
- Low risk. The change is test harness code only.
- The retry wait uses the same strict predicate as #22826: native
runtime, agent-owned recovery, remaining attempts, no successor, and a
retry time inside the deadline. Terminal and exhausted failures still
fail at once.
- Only fixed, identifier-shaped codes are kept. Free-form messages, URLs
and response bodies are still dropped.
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, GitHub CLI, read-only AWS S3 evidence access).
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>