Skip to content

[Bug]: Context-overflow recovery can finalize empty instead of deterministic fallback #19550

@Jackten

Description

@Jackten

Summary

In reply-agent overflow recovery, two edge paths can finalize with no user-visible payload (effectively undefined/empty) instead of a deterministic fallback:

  1. meta.error.kind == context_overflow with empty payloads when session reset is unavailable.
  2. Overflow error payloads that normalize/filter to empty during reply payload construction.

Steps to reproduce

  1. Run main at 98962ed81d26 (package version 2026.2.16).
  2. Execute runReplyAgent with an embedded result containing:
    • meta.error.kind: context_overflow
    • either payloads: [] or payload text that normalizes to empty (e.g. whitespace-only error text).
  3. Ensure reset is unavailable (no session store/sessionKey/storePath in this run context).
  4. Observe finalization output.

Expected behavior

Overflow failure paths should always return a deterministic user-facing fallback payload.

Actual behavior

In the two edge paths above, finalization can return no renderable payload (undefined/empty outcome).

OpenClaw version

2026.2.16 (main @ 98962ed81d26)

Operating system

Ubuntu 25.10

Install method

Source checkout + pnpm

Logs, screenshots, and evidence

Overflow signatures involved include:

  • Context overflow: prompt too large
  • Context overflow: Summarization failed: 400 {"message":"prompt is too long"}

Code-path pointers:

  • src/auto-reply/reply/agent-runner-execution.ts (embedded overflow meta-error handling)
  • src/auto-reply/reply/agent-runner.ts (empty payload/finalization path)

Impact and severity

  • Affected: any channel hitting overflow edge paths where recovery output is empty/non-renderable.
  • Severity: High reliability impact (silent/empty outcomes are hard to triage).
  • Frequency: Edge-case, deterministic with targeted conditions.
  • Consequence: missing actionable error response to the user/operator.

Additional information

Related upstream work (adjacent but not complete coverage for this path):

I have a narrowly scoped fix prepared in my fork that:

  1. Forces deterministic overflow fallback when embedded overflow meta-error has zero payloads.
  2. Ensures runner finalization uses overflow fallback when payload arrays normalize/filter to empty.
  3. Adds two regression tests for those exact paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions