Skip to content

[Bug] Webhook interface accumulates chat history across independent events #23

Description

@RadCod3

Description

Webhook events are usually independent, fire-and-forget notifications, but the current implementation (both Python and Ballerina interpreters) accumulates LLM chat history across all webhook invocations.

Steps to Reproduce

  1. Write a simple webhook AFM agent and run it with debug logs.
  2. Send two webhook events:
  # Event 1: provide some information
  curl -X POST http://localhost:8085/webhook \
    -H "Content-Type: application/json" \
    -d '{"message": "The project codename is Apollo and the deadline is March 15."}'
  # Event 2: ask about that information
  curl -X POST http://localhost:8085/webhook \
    -H "Content-Type: application/json" \
    -d '{"message": "What is the project codename and when is the deadline?"}'
  1. Debug logs show the second LLM request includes the full history from the first:
  {"messages": [
    {"role": "system", "content": "..."},
    {"role": "user", "content": "The project codename is Apollo and the deadline is March 15."},
    {"role": "assistant", "content": "Got it! The project codename is Apollo with a March 15 deadline. How can I help?"},
    {"role": "user", "content": "What is the project codename and when is the deadline?"}
  ]}

Impact

  • Context from unrelated events leaks into subsequent agent runs
  • Token usage grows unbounded over the process lifetime
  • Agent behavior drifts as history accumulates

Expected behavior

Each webhook event should be processed with a clean context — system prompt + current event payload only, with no history from prior events.

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