Skip to content

[Bug]: Feishu embedded agent returns HTTP 401 "Invalid token" to user instead of retrying with refreshed token #56197

@lokamir

Description

@lokamir

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Feishu embedded agent returns raw HTTP 401 "Invalid token" error to user instead of retrying with refreshed token

Steps to reproduce

1.Configure Feishu as a messaging channel with model routing through AutoGLM proxy (zai provider)
2.Wait for the model API's JWT token to expire (or start a new session when the token is near expiry)
3.Send any message from the Feishu client
4.The bot replies with "HTTP 401: Invalid token"

Expected behavior

The embedded agent should detect the 401, trigger a token refresh, and retry the request. At minimum, it should not surface the raw HTTP error message to the end user.

Actual behavior

The 401 error is passed directly as the reply text to the Feishu user. Logs show the token refresh (config reload) occurs after the error has already been returned. The webchat session recovers after refresh, but the Feishu embedded agent continues to fail intermittently on subsequent requests.

[feishu] received message from ou_cb34... (p2p)
[feishu] dispatching to agent (session=agent:main:feishu:direct:ou_cb34...)
[pi-ai] request POST .../chat/completions status=401
[agent/embedded] embedded run agent end: isError=true error=HTTP 401: "Invalid token"
[feishu] dispatch complete (queuedFinal=true, replies=1)
[reload] config change detected; evaluating reload (models.providers.zai.models)
[reload] config change applied

OpenClaw version

2026.2.25

Operating system

Windows 10 (x64)

Install method

No response

Model

pony-alpha-2 (GLM-5-Turbo)

Provider / routing chain

zai → autoglm-api.zhipuai.cn/autoclaw-proxy/proxy/autoclaw

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions