Skip to content

[Bug]: Task doesn't contain full history #136

@benclarkeio

Description

@benclarkeio

What happened?

Issue:
When sending multiple messages to the same task (same taskId), the Task.history field only contains messages from the current turn instead of accumulating all historical messages. This is inconsistent with the Python SDK behavior.

Expected Behavior:
When continuing an existing task:

  • Message 1 response: task.history = [user1, agent1]
  • Message 2 response: task.history = [user1, agent1, user2, agent2]
  • Message 3 response: task.history = [user1, agent1, user2, agent2, user3, agent3]

Actual Behavior:

  • Message 1 response: task.history = [user1, agent1] ✅
  • Message 2 response: task.history = [user2, agent2] ❌ (missing user1, agent1)
  • Message 3 response: task.history = [user3, agent3] ❌ (missing all previous)

Root Cause:
The DefaultRequestHandler/ResultManager builds the task history from events published to the ExecutionEventBus during the current execution only. When a RequestContext contains an existing task with prior history, those historical messages are not republished to the event bus, causing them to be lost in the final response.

Workaround:
In the AgentExecutor.execute() method, manually republish historical messages before processing:

if (task?.history && Array.isArray(task.history) && task.history.length > 0) {
    for (const historicalMessage of task.history) {
        eventBus.publish(historicalMessage);
    }
}

Expected Fix:
The SDK should automatically republish historical messages from requestContext.task.history when present, similar to how the Python SDK handles this scenario.

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions