fix(tools): clarify kanban_complete phantom-card retry guidance

When kanban_complete rejects a created_cards list as hallucinated, the
task is intentionally left in-flight (the gate runs before the write
txn) so the worker can retry with a corrected list or pass
created_cards=[] to skip the check. The retry path already worked, but
the previous error wording read like a terminal failure and workers
were observed abandoning the run instead of trying again.

Spell out the recovery path explicitly in the tool_error response
("Your task is still in-flight ... Retry kanban_complete with ...") and
add regression coverage at both the kernel and tool layers so the
retry contract — and the wording the worker depends on to discover
it — is pinned.

Fixes #22923
This commit is contained in:
konsisumer 2026-05-10 09:52:39 +02:00 committed by Teknium
parent 2f00559d9e
commit 62cfe79e93
3 changed files with 181 additions and 2 deletions

View file

@ -406,12 +406,21 @@ def _handle_complete(args: dict, **kw) -> str:
# Structured rejection — surface the phantom ids so the
# worker can retry with a corrected list or drop the
# field. Audit event already landed in the DB.
#
# The task itself was NOT mutated (the gate runs before
# the write txn), so the worker can simply call
# kanban_complete again. Spell that out — without it the
# model often interprets a tool_error as a terminal
# failure and either blocks or crashes the run instead
# of retrying. See #22923.
return tool_error(
f"kanban_complete blocked: the following created_cards "
f"do not exist or were not created by this worker: "
f"{', '.join(hall_err.phantom)}. "
f"Either omit them, use only ids returned from successful "
f"kanban_create calls, or remove the created_cards field."
f"Your task is still in-flight (no state change). "
f"Retry kanban_complete with the same summary/metadata "
f"and either drop these ids from created_cards, or pass "
f"created_cards=[] to skip the card-claim check entirely."
)
if not ok:
return tool_error(