Skip to content

Bug: Feishu API errors silently swallowed, agent receives outcome=completed on failure #119862

Open

Description

@Enominera

Description

When the Feishu API returns an error (e.g., HTTP 400 with code=230099), the gateway logs the error but still returns outcome=completed to the agent. The agent has no way to know the message was not delivered to the user.

Steps to Reproduce

  1. Agent generates a reply containing many markdown tables (exceeding Feishu's card table limit)
  2. Gateway calls Feishu API to send the message
  3. Feishu returns HTTP 400: code=230099, msg="card table number over limit"
  4. Gateway logs: [error]: code: 230099
  5. Gateway returns to agent: outcome=completed, replies=1

Expected Behavior

  • Gateway should return outcome=failed when Feishu API returns an error
  • Error details (code + message) should be included in the response
  • Agent should be able to retry or notify the user

Actual Behavior

  • Error is logged but not propagated to agent
  • outcome=completed is returned unconditionally
  • Agent believes the message was delivered successfully
  • User receives nothing

Root Cause

In reply-dispatcher, queuedCounts is incremented on enqueue but not decremented on failure. The onError callback only logs the error without re-throwing or updating the dispatch result. The outcome is set to "completed" unconditionally at the end of the dispatch flow.

Suggested Fix

Gateway side:

  • When Feishu API returns HTTP 4xx/5xx or code != 0, set outcome=failed
  • Include structured error info in response: {outcome, error_code, error_msg}
  • Track failedCounts in dispatch result

Optional hardening:

  • Pre-validate card content (e.g., table count) before sending
  • Add monitoring for "success reported but downstream failed" scenarios

Impact

Users may believe their messages were delivered when they were not. This affects any Feishu integration where the agent generates content that triggers API errors.

Activity

  1. added
    P2Normal backlog priority with limited blast radius.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR 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.
    on Aug 6, 2026
  2. clawsweeper commented on Aug 6, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work. Reviewed October 3, 2026, 1:55 AM ET / 05:55 UTC.

    Summary
    Delivery accounting and table-limit fallback have improved, but current main still records a completed processing outcome independently of delivery failure and does not expose provider error details through that outcome. The earlier repair PR closed unmerged, so the remaining reporting request merits a focused contract decision.

    Likely related people: steipete and joshavant, medium-confidence routing candidates from shared delivery history.

    Reproducibility: unclear. for the exact agent-facing claim: source proves that a successful agent run with failed delivery can retain completed processing diagnostics, but no live run or model-visible response was verified.

    Maintainer decision needed

    Question Recommendation
    Should delivery failures be exposed separately through the existing settled-receipt contract, or should they change the shared processed outcome? Keep separate run and delivery outcomes: Define sanitized delivery-error feedback at the existing settlement boundary and identify its agent-facing consumer.

    Why: Current code deliberately distinguishes agent execution from transport settlement; redefining completed would affect sibling channels and public consumers, while the requested model feedback has no identified entrypoint.

    Next step
    Resolve the shared reporting contract and identify the model-visible consumer before scoping a repair; no new fix PR should be dispatched yet.

    Review details

    Best possible solution:

    Use the existing settled-receipt owner to expose sanitized delivery failures separately from agent-run completion, preserving duplicate-safe recovery.

    Do we have a high-confidence way to reproduce the issue?

    Unclear for the exact agent-facing claim: source proves that a successful agent run with failed delivery can retain completed processing diagnostics, but no live run or model-visible response was verified.

    Is this the best way to solve the issue?

    The proposed unconditional failed outcome is not yet the best-supported repair; extending the existing settlement contract preserves the distinction between execution failure, rejected delivery, and ambiguous delivery.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The report does not identify the agent-facing entrypoint that receives outcome=completed; current source establishes that processing diagnostics can say completed after delivery failure, but not that the model receives that diagnostic.
    • Changing the shared processing outcome or exposing provider errors requires a defined contract for partial delivery, ambiguous sends, recovery-owned retries, and sanitized error details.

    Codex review notes: model internal, reasoning medium; reviewed against 6a565393916d.

    Label changes

    Label changes:

    No label changes.

    Label justifications:

    • P1: Failed channel delivery can leave users without an answer while processing diagnostics still indicate completion.
    • impact:message-loss: The report concerns rejected Feishu replies and missing delivery feedback.
    Evidence reviewed

    What I checked:

    Likely related people:

    • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    • joshavant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. added
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    and removed
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Aug 6, 2026
  4. 4 remaining items

  5. self-assigned this
    on Aug 11, 2026
  6. removed their assignment
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm 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.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions