Store additional context into history

Problem to solve

After storing additional context into history on the monolith side. It turned out that's not enough to AI context feature to work.

We also need to update AIGW to store additional context.

Implementation details

Quotes from Slack threads (by @lesley-r):

https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/blob/main/ai_gateway/chat/agents/react.py I would look at this method and make sure your additional context gets saved in the history properly
Note how it usually adds m.content and not everything from the Message object

The ChatMessage is also used.
But, the AIGW assembles the final prompt that will be sent to Anthropic.
It may help to add this print line here
puts("here is the body", params.to_json)
You can observe how the chat history is sent to AIGW.
The AI Gateway then processes that chat history in the method I linked before to form the final request to Anthropic

So to sum it up
I think you need to change this to include your additional context instead of just m.content

Further details

Links / references

Related Slack threads:

Edited by Vitali Tatarintev