Skip to content

feat(mcp-server): explain task_claim_file rejections with a reason-specific message#545

Merged
NagyVikt merged 1 commit into
mainfrom
agent/claude/explain-task-claim-file-rejection-direct-2026-05-14-23-35
May 14, 2026
Merged

feat(mcp-server): explain task_claim_file rejections with a reason-specific message#545
NagyVikt merged 1 commit into
mainfrom
agent/claude/explain-task-claim-file-rejection-direct-2026-05-14-23-35

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Automated by gx branch finish (PR flow).

…ecific message

`task_claim_file` and the `TaskThread.claimFile` / `normalizeOptionalClaimPath`
paths used to throw `INVALID_CLAIM_PATH: claim path is not claimable` with no
hint at the reason. Telemetry showed agents bouncing off the same surface for
the same input — e.g. `colony/packages/core/test` (a directory) — because the
message gave them nothing to act on.

The rejection branch now classifies the failure and renders a specific
message per reason: directory ("claim individual files inside it
instead"), pseudo (/dev/null etc), outside_repo, empty, plus the legacy
generic fallback. Existing `INVALID_CLAIM_PATH` error code is preserved.

New `@colony/storage` exports:
* `classifyClaimPathRejection(context)` — pure classifier paralleling
  `normalizeRepoFilePath`. Returns the reason or `null`.
* `claimPathRejectionMessage(reason, file_path)` — single source of truth
  for the user-facing message so the MCP `task_claim_file` handler and
  `TaskThread.claimFile` stay in sync.
* New storage method `classifyTaskFilePathRejection(task_id, file_path,
  cwd?)` plumbs the task → repo_root lookup that `normalizeTaskFilePath`
  already does, so callers only pay for the classifier on the error
  branch.

Tests:
* `packages/storage/test/claim-path.test.ts` covers all five reasons
  (existing directory, trailing-slash directory, pseudo, empty,
  outside_repo) plus message rendering for each.
* `apps/mcp-server/test/task-threads.test.ts` updates the existing pseudo-
  path test to assert the new message and adds a directory case asserting
  the recovery hint.

Storage: 149/149 PASS. mcp-server: 273/273 PASS. Lint clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@NagyVikt NagyVikt merged commit 9e1a791 into main May 14, 2026
@NagyVikt NagyVikt deleted the agent/claude/explain-task-claim-file-rejection-direct-2026-05-14-23-35 branch May 14, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant