Skip to content

Legacy handler ignores history_length on message/stream #1363

Closed

Description

@ConnorMoss02

What happens

With the legacy request handler, message/stream with history_length=0 still returns the full history on Task events, and history_length=-1 is not rejected. message/send trims and rejects both correctly.

Why

LegacyRequestHandler.on_message_send calls validate_history_length and apply_history_length (default_request_handler.py), but on_message_send_stream calls neither. The v2 handler already applies it on streams.

Version

main @ d316d0e

Activity

  1. added theissue type on Oct 22, 2026
  2. added
    component: serverIssues related to frameworks for agent execution, HTTP/event handling, database persistence logic.
    on Oct 22, 2026
  3. rohityan commented on Oct 22, 2026

    @rohityan

    Hi @ConnorMoss02, thanks for reporting this and opening the fix PR #1364. Your approach for the fix looks correct.

    In src/a2a/server/request_handlers/default_request_handler.py, LegacyRequestHandler.on_message_send_stream fails to validate history_length at request start and never truncates task.history on emitted Task events via apply_history_length. As a result, negative values are not rejected, and streamed tasks return their full history regardless of configuration.

    Assigning this issue to you until the PR is reviewed. Meanwhile, clients can manually slice task.history[-history_length:] if history_length > 0 else [] on received Task objects and guard outbound requests against negative history_length values.

  4. added a commit that references this issue on Oct 23, 2026
    261c074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

component: serverIssues related to frameworks for agent execution, HTTP/event handling, database persistence logic.status:awaiting response

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions