Files
PaperClipAI/server/src/services/native-runtime
782bd8d8eb fix(chat): continue a Slack question that a person answered in Paperclip (#22524)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents can work on tasks that start in Slack. They can ask the
person a question, and Paperclip posts the question card to Slack.
> - The person can answer in Slack or on the Paperclip task page.
Paperclip then starts a new run to continue the chat, and that run must
prove the answer before it can start.
> - If the Slack card had a native Respond button and the person
answered on the task page, the proof refused the answer. The run failed
setup with `reviewed_chat_execution_binding_not_authorized`
(`question_response_missing`), and the task stayed blocked. The agent
did not receive the answer.
> - This pull request accepts that task-page answer when the stored
Slack tokens show that the task-page answer replaced the Slack controls.
> - The benefit is that a person can answer an agent's Slack question on
the task page, and the agent continues the work.

## Linked Issues or Issue Description

**What happened?**
A task started in Slack. The agent asked a text question. Slack showed
the card with a native "Respond" button. The person answered on the
Paperclip task page. The continuation run failed during setup with
`reviewed_chat_execution_binding_not_authorized`, denial reason
`question_response_missing`. Recovery then set the task to blocked.

**Steps to reproduce**
1. Connect a Slack bot that has actions and modals.
2. Start a task from a Slack message.
3. Let the agent ask an `ask_user_questions` text question. Slack shows
a "Respond" button.
4. Answer the question on the Paperclip task page, not in Slack.
5. The continuation run fails setup with `question_response_missing`.

**Expected behavior**
The answer reaches the agent, and the continuation run starts.

**Cause**
The task-page answer expires all Slack tokens for the question with
`interaction_resolved_elsewhere`. The answer proof in
`resolveQuestionResponseChain` accepted a Slack task-page answer only if
no Slack answer tokens existed at all and every card action was a link.
A card with a native Respond button always failed both checks.

Related: #17255 added the Slack native question forms and the task-page
answer proof.

## What Changed

- `external-chat-question-response.ts`: the task-page answer query now
ignores Slack answer tokens only when their status is `expired` with
result code `interaction_resolved_elsewhere`. Any other token state
(processed, issued, or expired for another reason) still makes the proof
use the Slack action path, as before.
- `external-chat-question-response.ts`: a Slack card can now have
callback actions, but only when each callback `actionId` matches a
superseded token (`question_answer` or `question_form_open`) of the same
interaction, publication, endpoint and conversation. GitHub cards still
must have only links.
- `external-chat-wait.integration.test.ts`: the Board-answer fixture can
now publish a Slack text question with a native form. A new regression
test answers it on the task page and attests the continuation. The
Board-answer refusal matrix now runs for this card too, with two new
cases: a Slack token that the answer did not supersede, and an unknown
callback button.

## Verification

- Red before the fix: the new test `attests a Slack question answered in
Paperclip after its native form was published` failed with denial
`["question_response_missing"]`. This is the same denial reason as the
failed run.
- Green after the fix: the same test passes. The continuation input
contains the answer.
- `pnpm vitest run
src/services/native-runtime/external-chat-wait.integration.test.ts` (in
`server`): all 301 tests pass. This includes the 14 refusal cases for
the native-form card (other user, viewer, revoked membership, revoked
identity, wrong target, wrong wake, unpublished card, processed Slack
action, deleted source message, paused endpoint, revoked resource,
changed answer hash, token not superseded, unknown callback).
- Mutation check: when I let any callback through, the
`foreign_callback` case fails. When I ignore token state, the
`unsuperseded_token` case fails.
- `photon/channel.integration.test.ts` and
`agent-action-audit-routes.test.ts` pass.
- `heartbeat-process-recovery.test.ts`: 4 sandbox-lease tests fail in my
sandbox with `isRetryableEnvironmentHttpStatus is not a function`. They
fail the same way on unmodified master, so this change does not cause
them.
- The full server `tsc` was killed by the sandbox memory limit. CI is
the type gate.

## Risks

- This change makes the answer proof accept more answers, so I kept it
narrow. A Slack task-page answer is accepted only when the stored tokens
prove that the task-page answer replaced every Slack answer token. All
other checks do not change: the same person must answer, membership and
identity link must be current, the endpoint must be active, the
publication must be published, and the answer hash must match.
- If a Slack answer and a task-page answer race, any token that the
task-page answer did not expire still refuses the proof. This fails
closed, as before.
- No migration. No change to GitHub, Speko, Photon or Slack
native-answer paths.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution.

## 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
- [ ] 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
- [ ] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 19:22:33 -08:00
..