Skip to content

Refactor ReAct Agent V2

Shinya Maeda requested to merge fix-react-agent-v2 into master

This is a high priority MR for Switch to Chat Agent V2 (gitlab-org#13533 - closed). Please prioritize the review and merge.

What does this MR do and why?

This MR improves the executor class of Duo Chat Agent V2. There are a couple of things:

Related to fix(chat): respond unknown event response in v2 (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!1325 - merged)

Closes Parse unformatted answers from LLM (#480563 - closed) Refactor AIGateway::Client (and the other servi... (#462694 - closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Test ReactAgent:

Gitlab::Llm::DuoChat::ReactAgent.new(User.first).step({prompt: "Hi, how are you?", options: { chat_history: "" } })
Gitlab::Llm::DuoChat::ReactAgent.new(User.first).step({prompt: "Summarize this issue #123", options: { chat_history: "" } })
Gitlab::Llm::DuoChat::ReactAgent.new(User.first).step({prompt: "Hi, how are you? Do not include Final Answer: in response. Do not include Thought: in response. Do not include Action: in response.", options: { chat_history: "" } })

Test CoT:

agent = Gitlab::Llm::DuoChat::ReactAgent.new(User.first)
agent.step({prompt: "Summarize this issue #123", options: { chat_history: "" } })
agent.update_observation("This issue #123 is about how to create a deep learning model from scratch")
agent.step({prompt: "Summarize this issue #123", options: { chat_history: "" } })

or Test multi-step executor:

prompt_message = Gitlab::Llm::ChatMessage.new(
    content: "Summarize this issue #123",
    role: "user",
    user: User.first,
    ai_action: "chat",
    context: Gitlab::Llm::AiMessageContext.new(resource: User.first),
    client_subscription_id: 'test',
)
ai_prompt_class = nil
options = {:content=>"Hello", :extra_resource=>{}, :action=>:chat}
Gitlab::Llm::Completions::Chat.new(prompt_message, ai_prompt_class, options).execute
Edited by Shinya Maeda

Merge request reports

Loading