Skip to content

Custom Provider (9router) Returns 0 Output Tokens via Telegram #377

@caothuyen

Description

@caothuyen

GoClaw Bug Report: Custom Provider (9router) Returns 0 Output Tokens via Telegram

Environment

  • GoClaw Version: v2.4.0 (protocol 3)
  • OS: Windows 10.0.26200 (x64)
  • Provider: 9router (custom OpenAI-compatible provider)
  • Base URL: http://host.docker.internal:20128/v1
  • Model: kr/claude-sonnet-4.5
  • Channel: Telegram
  • Agent Type: Predefined (shared context)

Issue Description

When using a custom provider (9router) with Claude models via Telegram channel, the agent receives 0 output tokens and does not call any tools. The same configuration works perfectly via Web Chat (ws).

Reproduction Steps

  1. Configure custom provider "9router" with base URL http://host.docker.internal:20128/v1
  2. Create agent with:
    • Provider: 9router
    • Model: kr/claude-sonnet-4.5
    • Tool Policy: full
    • Skills: enabled
  3. Bind agent to Telegram channel
  4. Send message via Telegram requesting tool usage (e.g., "check weather in HCM")

Expected Behavior

Agent should:

  • Call appropriate tools (web_search, web_fetch, etc.)
  • Return complete response with output tokens
  • Work the same way as Web Chat

Actual Behavior

Via Telegram:

  • Input tokens: 28.9K - 29.3K
  • Output tokens: 0 (or very few: 14-129)
  • Spans: 2 (1 LLM, 0 tool)
  • No tool calls
  • Empty or truncated response

Via Web Chat (same agent, same provider):

  • Input tokens: 25.8K - 152.1K
  • Output tokens: 96 - 360
  • Spans: 2 - 10 (includes tool calls)
  • Tools called successfully
  • Complete responses

Trace Evidence

Failed Telegram Request (03:11:34 PM)

Duration: 4.1s
Tokens: 29.3K / 0
Spans: 2 (1 LLM, 0 tool)
Status: completed
Output: (empty)

Successful Web Chat Request (03:09:51 PM)

Duration: 27.5s
Tokens: 100.3K / 360
Spans: 10 (multiple LLM + tool calls)
Status: completed
Output: (complete response with tool results)

Successful Telegram Request with Different Model (02:40:30 PM)

Model: openrouter/stepfun/step-3.5-flash:free
Duration: 42.6s
Tokens: 77.0K / 983
Spans: 8 (4 LLM, 3 tool)
Tools: web_search, web_fetch (x2)
Status: completed
Output: (complete weather response)

Logs

time=2026-03-23T07:46:11.287Z level=INFO msg="resolved agent from DB" agent=jarvis-qd model=kr/claude-sonnet-4.5 provider=9router
time=2026-03-23T07:46:12.120Z level=INFO msg="system prompt built" mode=full contextFiles=6 hasMemory=true hasSpawn=true isBootstrap=false promptLen=24132
time=2026-03-23T07:46:17.195Z level=INFO msg="stream: ended, handing off to Send()" chat_id=5233603014 message_id=274

Note: No "tool call" log entries for Telegram requests with 9router/Claude.

Analysis

What Works

  • ✅ 9router provider is accessible and responding
  • ✅ Telegram channel integration is functional
  • ✅ Web Chat with 9router/Claude works perfectly
  • ✅ Telegram with OpenRouter/stepfun model works perfectly
  • ✅ System prompt is built successfully (24KB)
  • ✅ Stream ends without errors

What Fails

  • ❌ 9router + Claude + Telegram = 0 output tokens
  • ❌ No tool calls via Telegram with 9router/Claude
  • ❌ Response appears to be cut off or not streamed properly

Hypothesis

The issue appears to be specific to the combination of:

  1. Custom provider (9router)
  2. Claude models (kr/claude-sonnet-4.5)
  3. Telegram channel

Possible causes:

  • Streaming response handling differs between Telegram and Web Chat
  • Claude response format may not be compatible with Telegram streaming handler
  • Timeout or buffer issue specific to Telegram integration
  • Tool definitions may not be sent correctly to Claude via Telegram
  • Response size or format incompatibility with Telegram message limits

Workarounds

  1. Use Web Chat instead of Telegram with 9router/Claude
  2. Use OpenRouter provider instead of 9router for Telegram
  3. Use different model (e.g., stepfun/step-3.5-flash:free) via OpenRouter

Additional Context

  • Provider 9router is a custom OpenAI-compatible API gateway
  • Same API key and configuration works for Web Chat
  • No errors in GoClaw logs
  • Container is healthy and running normally
  • All dependencies (Python 3.12.12, Node.js v22.22.0, pip3) are installed

Request

Please investigate why custom providers with Claude models return 0 output tokens via Telegram while working correctly via Web Chat. This appears to be a channel-specific integration issue with streaming responses from custom providers.


Reporter: Cao Thuyên
Date: 2026-03-23
GoClaw Version: v2.4.0
Issue Type: Bug - Channel Integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions