Skip to content

Draft: fix(chat): react prompt is not following paper and Anthropic CoT training data

Shinya Maeda requested to merge fix-react-prompt into main

What does this merge request do and why?

This MR fixes the react prompt for Duo Chat. There are a couple of issues in the prompt:

  • It's not following the paper. Hence, our prompt doesn't work in a way that the researcher (Google Research, Brain team) published in the paper.
  • According to Antrhopic documentations, there are no evidences that Claudes are trained for ReAct, but it's trained for Chain-of-thought (CoT). Since ReAct is an extension of CoT, we should build the prompt based on the Anthropic CoT guideline and extend it for ReAct.

Fixes https://gitlab.com/gitlab-org/gitlab/-/issues/493570+ and "thought" of agent step is not correctly parsed (#659 - closed)

Ref https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/chain-of-thought and https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/chain-prompts

Evaluation

TODO

How to set up and validate locally

Requests for vibe check:

curl -X 'POST'         'http://localhost:5052/v2/chat/agent'         -H 'accept: application/json'         -H 'Content-Type: application/json'         -H 'x-gitlab-enabled-feature-flags: expanded_ai_logging'         -d '{
  "prompt": "How to write a python method?",
  "options": {
    "chat_history": [
      {"role": "user", "content": "How can I log output?"},
      {"role": "assistant", "content": "Use print function"}
    ],
    "agent_scratchpad": {
      "agent_type": "react",
      "steps": []
    }
  }
}'
curl -X 'POST'         'http://localhost:5052/v2/chat/agent'         -H 'accept: application/json'         -H 'Content-Type: application/json'         -H 'x-gitlab-enabled-feature-flags: expanded_ai_logging'         -d '{
  "prompt": "Summarize this issue https://gitlab.com/gitlab-org/gitlab/-/issues/494161",
  "options": {
    "chat_history": [
      {"role": "user", "content": "How can I log output?"},
      {"role": "assistant", "content": "Use print function"}
    ],
    "agent_scratchpad": {
      "agent_type": "react",
      "steps": []
    }
  }
}'
curl -X 'POST' \
  'http://localhost:5052/v2/chat/agent' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'x-gitlab-enabled-feature-flags: expanded_ai_logging' \
  -d '{
  "prompt": "Summarize this issue https://gitlab.com/gitlab-org/gitlab/-/issues/494161",
  "options": {
    "chat_history": [
      {"role": "user", "content": "How can I log output?"},
      {"role": "assistant", "content": "Use print function"}
    ],
    "agent_scratchpad": {
      "agent_type": "react",
      "steps": [
        {
          "thought": "The user has provided a specific issue URL, which meets the conditions for using the issue_reader tool. I should use this tool to retrieve the content of the issue and then summarize it.",
          "tool": "issue_reader",
          "tool_input": "Summarize https://gitlab.com/gitlab-org/gitlab/-/issues/494161",
          "observation": "The issue 494161 is about fixing some of the V2 chat agent logs are not working."
        }
      ]
    }
  }
}'

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.
Edited by Shinya Maeda

Merge request reports

Loading