Skip to content

[Bug]: Compact over-budget Harness requests at the iteration limit #4271

Closed

Description

@Buktal

Describe the bug

When a Harness agent reaches its ReAct iteration limit, the fallback appends a closing instruction and sends a SUMMARY request using the working conversation. SUMMARY preparation skips conversation compaction and tool-result offloading. If the last tool result or the closing instruction pushes the request over the input budget, preparation raises ContextBudgetExceededException before the fallback model can answer.

To reproduce

  1. Configure a Harness agent with a small input budget and a low iteration limit.
  2. Use a tool that returns enough text on the last iteration to push the fallback request over the budget.
  3. Let the agent reach its iteration limit and inspect the SUMMARY request outcome.

Expected behavior

Apply the configured tool-result offloading and history compaction before sending the fallback request. Keep the closing instruction in the request, including when both keepTokens and keepMessages are set to zero. If the prepared request still exceeds the budget, reject it before invoking the fallback model.

Environment

  • AgentScope Java 2.1.0-SNAPSHOT, main at f4e6a07
  • Java 21 on Windows

Activity

  1. added a commit that references this issue on Nov 20, 2026
    cd8a21c
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions