Skip to content

fix(bridge): treat crush tool_use finish as intermediate, not turn failure - #935

Closed
jinon86 wants to merge 1 commit into
mainfrom
fix/crush-tool-use-finish
Closed

fix(bridge): treat crush tool_use finish as intermediate, not turn failure#935
jinon86 wants to merge 1 commit into
mainfrom
fix/crush-tool-use-finish

Conversation

@jinon86

@jinon86 jinon86 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

증상

방통(VPS3) crush 레인에서 k3가 도구를 부르는 턴이 전부 ❌ Processing failed: tool_use로 실패 (duration.jsonl success=false 연속). 순수 텍스트 답변 턴(canary5b)만 성공했습니다.

근본 원인 (소스 레벨 확정)

crush는 모델이 도구 호출로 끝내는 모든 중간 어시스턴트 메시지에 finish part reason="tool_use"를 붙입니다 (fantasy.FinishReasonToolCalls → message.FinishReasonToolUse, 게다가 AddFinish(reason, "", "")로 message/details는 빈 문자열).

브릿지 _complete_turn_FINISH_OK{"end_turn","stop","stop_sequence","length","tool_calls"} — crush의 실제 어휘 "tool_use"가 없어 else 분기로 떨어지고, detail = message or details or reason이 빈 문자열 둘을 지나 reason 그대로 → ErrorEvent(message="tool_use") → 사용자에게 Processing failed: tool_use.

permissions deny question(#934)으로는 못 고치는 이유가 이것 — 트리거는 특정 도구가 아니라 도구 사용 자체입니다. #934는 비대화형 경로 강화로는 유효하나 본 건의 수정이 아닙니다.

수정

_FINISH_INTERMEDIATE = {"tool_use"}를 추가하고 _complete_turn에서 즉시 return — 중간 경계에서는 턴을 끝내지도 실패시키지도 않고 수집을 계속합니다. 권한 거부는 crush가 StopTurn → end_turn으로 변환해 주므로 기존 완료 경로가 그대로 동작합니다.

검증

  • 회귀 테스트 4건 추가: tool_use 무시·수집 계속→end_turn 완료 / 미지 reason은 상세와 함께 실패 유지 / cancel은 interrupt 유지
  • 전체 브릿지 스위트: 2222 passed (test_config_voice_provider 1건 실패는 clean main에서도 재현되는 pre-existing 환경 의존)
  • 방통 배포본에 동일 패치 핫적용 + 브릿지 재시작 완료 — 실전 턴 재검증 진행 중

🤖 Generated with Claude Code

…ilure

crush maps the provider's tool_calls finish to reason="tool_use" on every
assistant message that ends with tool calls, with empty message/details
(AddFinish(reason, "", "")). _FINISH_OK never contained it, so every
tool-using turn fell into the error branch and surfaced the bare reason
string: "Processing failed: tool_use" (bangtong 2026-08-04 — pure-text
turns passed, e.g. canary5b, while any real task failed).

The finish is an intermediate step boundary: the agent loop runs the tools
and calls the model again, and permission denials already arrive as
end_turn (crush maps StopTurn). Ignore it and keep collecting; the turn
still completes on end_turn/stop, errors on unknown reasons, and
interrupts on cancel.

Regression tests: tool_use ignored + collection continues to end_turn,
unknown reason still fails with detail, cancel still interrupts.
Full bridge suite: 2222 passed (1 pre-existing env-dependent failure in
test_config_voice_provider, reproduces on clean main).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jinon86

jinon86 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

종결 — main에 이미 반영됨(상위집합), 리베이스하면 오히려 회귀

충돌 해소를 시도하기 전에 main 현황을 대조한 결과, 이 PR의 수정은 #942(squash 98a8f7d9)와 #943(squash a4c56b88, 2026-08-04 머지)로 이미 반영돼 있습니다. 충돌은 같은 줄을 서로 다르게 고쳤기 때문입니다.

동작은 동일

이 PR main (#943)
상수 _FINISH_INTERMEDIATE = {"tool_use"} _FINISH_CONTINUE = {"tool_calls", "tool_use"}
_complete_turn 해당 시 early return 동일

다만 이 PR에는 회귀가 남아 있습니다

이 PR은 tool_calls_FINISH_OK그대로 둡니다. main은 이를 _FINISH_CONTINUE로 옮겼고, 코드 주석이 그 이유를 명시합니다:

tool_calls is the same signal under OpenAI naming. The kimi pilot only ever produced the Anthropic spelling, so its presence in the terminal set was never exercised — it would have truncated turns the same way.

즉 OpenAI 계열 프로바이더에서는 tool_calls가 종결로 취급돼 턴이 빈 응답으로 잘립니다. 지금 이 PR을 리베이스해 머지하면 그 경로가 되살아납니다.

테스트도 main이 상위집합

이 PR이 추가하는 bridge/tests/test_crush_tool_use_finish.pytool_use 단일 케이스만 다룹니다. main의 test_crush_model_pin.py는:

  • test_tool_call_finish_keeps_the_turn_open["tool_use", "tool_calls"] 파라미터화 (이 PR이 놓친 경로까지 포함)
  • test_terminal_finish_reasons_complete_the_turn
  • test_unknown_finish_reason_still_fails_the_turn

를 이미 갖고 있어, 이 PR의 테스트 파일이 추가로 잡는 회귀가 없습니다.

판단

살릴 고유 가치가 없고 리베이스는 회귀를 들여옵니다. not planned로 종결합니다. 근본 증상(bangtong 2026-08-04 "Processing failed: tool_use")은 #943으로 해결된 상태입니다.

@jinon86 jinon86 closed this Aug 5, 2026
@jinon86
jinon86 deleted the fix/crush-tool-use-finish branch August 5, 2026 11:16
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