Skip to content

feat(agents): execute code generations via agent

What does this merge request do and why?

Implement code generations via Agents. The approach similar to feat(agents): code completions for custom model... (!1063 - merged)

Current behavior

Code Generations request goes through Rails to generate a prompt and send it to AI Gateway:

sequenceDiagram
    participant Client
    participant Rails
    participant AIGateway
    participant Model

    Client ->> Rails: POST /api/v4/code_suggestions/generations with an instruction
    Rails ->> AIGateway: POST /v2/code/generations with a prompt built from the instruction
    AIGateway ->> Model: sends a prompt

Proposal

Code Generations request sends a prompt that contains user instructions only and additional data and AI Gateway generates a prompt to send it to a model. To indicate that the agent functionality must be used, use_agent flag is additionally sent.

sequenceDiagram
    participant Client
    participant Rails
    participant AIGateway
    participant Model

    Client ->> Rails: POST /api/v4/code_suggestions/generations with an instruction
    Rails ->> AIGateway: POST /v2/code/generations[use_agents: true] with necessary data
    AIGateway ->> Model: generates a prompt and sends it

For Code Generations, we can use prompt field to pass the additional information for code generation, so we cannot nullify it to indicate agent usage:

  • Use a flag (like use_agent boolean field) to indicate agent usage
  • Eventually, prompt field contains the user instruction only
  • For the first iterations, we can pass the whole prompt and then iteratively migrate different parts from the Rails prompt to AI Gateway

Testing

Testing steps are described in this issue: Prompt Migration: collaboration issue to for Co... (gitlab-org/gitlab#473394 - closed)

Edited by Igor Drozdov

Merge request reports

Loading