wso2 / wso2/reference-implementations-afm

[Bug] Webhook interface accumulates chat history across independent events

Open
#23 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2
Forks
4
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing webhook event handling in the Python and Ballerina interpreters, then reproduce the issue with the two curl requests from the report and inspect the debug logs. Done means each webhook request contains only the system prompt and current event payload, with no history from prior events, in both implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.