internal/translator/claude/interactions: response translator hardcodes status:"completed", ignoring stop_reason:"tool_use" and "max_tokens"

Open Beginner friendly
#7,975 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
api, backend

Research direction

Open internal/translator/claude/interactions/interactions_claude_response.go and read convertClaudeMessageToInteractions (line 64), convertClaudeSSEToInteractionsNonStream (line 82) and the streaming appendClaudeInteractionsCompleted (line 517), which all write a literal "status": "completed". Trace where the Claude stop_reason (and delta.stop_reason on the SSE path) is available at each site and map tool_use to requires_action, max_tokens to incomplete, end_turn to completed. Run go test -v -race -run TestRepro_ClaudeInteractionsHardcodesCompletedOnToolUse ./internal/translator/claude/interactions first to confirm the failure, and add cases for each stop_reason including the streaming path; done means non-stream and stream both emit the mapped status.

Written by the indexing model from the issue text.

Description

Summary

In internal/translator/claude/interactions/interactions_claude_response.go:64, 82, 517, convertClaudeMessageToInteractions, convertClaudeSSEToInteractionsNonStream, and streaming appendClaudeInteractionsCompleted hardcode "status": "completed" and never inspect Claude's stop_reason / delta.stop_reason ("tool_use" -> "requires_action", "max_tokens" -> "incomplete").

Environment
  • CLIProxyAPI revision: origin/dev at 32842348 (confirmed on v8.1.2)
  • OS / Go: Windows 11 amd64, go1.27.4
  • Route: Interactions API -> Claude -> ConvertClaudeResponseToInteractionsNonStream / ConvertClaudeResponseToInteractions
Minimal Reproduction & Observed vs Expected
go test -v -race -count=1 -run TestRepro_ClaudeInteractionsHardcodesCompletedOnToolUse ./internal/translator/claude/interactions

Observed output (origin/dev 32842348):

=== RUN   TestRepro_ClaudeInteractionsHardcodesCompletedOnToolUse
    repro_v812_test.go:16: status = "completed" on stop_reason=tool_use, want "requires_action"; out={"id":"msg_1","object":"interaction","status":"completed","model":"claude-sonnet-4-6","steps":[{"type":"function_call","name":"lookup","arguments":{"q":"x"},"id":"toolu_1","call_id":"toolu_1"}],...}
--- FAIL: TestRepro_ClaudeInteractionsHardcodesCompletedOnToolUse (0.00s)
Check / Field Observed (origin/dev 32842348) Expected
status on stop_reason: "tool_use" "completed" "requires_action"
Proposed fix (internal/translator/**)

Map Claude stop_reason ("tool_use" -> "requires_action", "max_tokens" -> "incomplete", "end_turn" -> "completed") in interactions_claude_response.go:64, 82, 517.

What ran / Not run
  • Ran: Hermetic go test -v -race -count=1 -run TestRepro_ClaudeInteractionsHardcodesCompletedOnToolUse ./internal/translator/claude/interactions against origin/dev (32842348).
  • Not run: Live upstream calls.
Dominant language
Go
Stars
58.8k
Forks
9k
Avg merge
14h 20m
Merged PRs (30d)
67

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from router-for-me/CLIProxyAPI

All issues in router-for-me/CLIProxyAPI

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.