Skip to content

fix(reply): make overflow fallback deterministic for empty recovery payloads#19551

Draft
Jackten wants to merge 3 commits intoopenclaw:mainfrom
Jackten:fix/context-overflow-deterministic-fallback
Draft

fix(reply): make overflow fallback deterministic for empty recovery payloads#19551
Jackten wants to merge 3 commits intoopenclaw:mainfrom
Jackten:fix/context-overflow-deterministic-fallback

Conversation

@Jackten
Copy link
Contributor

@Jackten Jackten commented Feb 17, 2026

Summary

  • Problem: overflow recovery had edge paths that could finalize with no renderable payload (undefined/empty outcome) when meta.error was context_overflow.
  • Why it matters: this creates silent/non-actionable behavior in a high-friction reliability path.
  • What changed:
    • Added deterministic overflow fallback when embedded overflow meta-error returns zero payloads.
    • Added deterministic overflow fallback when payloads normalize/filter to empty in runReplyAgent.
    • Added two regressions covering both paths.
  • What did NOT change (scope boundary): no config/schema changes, no provider selection logic changes, no broad compaction refactor.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • Overflow edge paths now return a deterministic fallback response instead of potentially finalizing with an empty/undefined payload.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Ubuntu 25.10
  • Runtime/container: local source checkout
  • Model/provider: N/A (runner behavior)
  • Integration/channel (if any): reply-agent execution path
  • Relevant config (redacted): defaults

Steps

  1. Return meta.error.kind = context_overflow with payloads: [] and unavailable session reset context.
  2. Return overflow error payload that normalizes/filters to empty.
  3. Observe finalization behavior.

Expected

  • Deterministic fallback payload is returned in both edge paths.

Actual

  • Before fix: empty/undefined-style finalization possible.
  • After fix: explicit overflow fallback response returned.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Regression tests added:

  • returns a deterministic overflow fallback when error meta has no payloads
  • returns a deterministic overflow fallback when error payload normalizes to empty

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • pnpm vitest run src/auto-reply/reply/agent-runner.runreplyagent.test.ts passed (25 tests).
    • pnpm test passed.
    • pnpm build passed.
  • Edge cases checked:
    • existing compaction-reset and role-ordering tests still pass.
  • What you did not verify:
    • exhaustive channel-by-channel delivery matrix.

Note: pnpm check reports pre-existing repository-wide formatting issues (Format issues found in above 1121 files) unrelated to this PR's touched files.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly:
    • Revert this PR commit.
  • Files/config to restore:
    • src/auto-reply/reply/agent-runner-execution.ts
    • src/auto-reply/reply/agent-runner.ts
    • src/auto-reply/reply/agent-runner.runreplyagent.test.ts
  • Known bad symptoms reviewers should watch for:
    • reappearance of empty/undefined finalization behavior on overflow edge paths.

Risks and Mitigations

  • Risk: fallback could trigger in cases where empty payload was intentional.
    • Mitigation: fallback is restricted to explicit overflow/compaction error kinds.
  • Risk: overlap with adjacent overflow/compaction work.
    • Mitigation: keep patch narrowly scoped and link related issues/PRs.

AI assistance

  • AI-assisted: Yes (author verified code paths, tests, and scope).

@Jackten Jackten force-pushed the fix/context-overflow-deterministic-fallback branch from c3e13e0 to 7ddddfc Compare February 19, 2026 18:58
@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant