Skip to content

Refactor prompt to treat needs-action as a system labelย #2140

@AlaeMghirbi

Description

@AlaeMghirbi

Why?

The LLM prompt currently performs two distinct tasks in a single request:

  1. Action Classification: Determine if email needs action (YES/NO)
  2. Label choice: Select relevant labels from user's labels
    => violates the single responsibility principle

Problems identified :

  • Two separate task sections with different instructions
  • Action is a boolean, labels are IDs

What?

Refactor LlmMailBackendClassifierListener to treat needs-action as a system label rather than a separate classification task.
The goal is to have a single, generic action in the prompt that reads the provided labels (both system and user labels) and then performs the classification.

Before:

OUTPUT: YES,labelA,labelB

After:

OUTPUT: Needs-action,labelA,labelB

How?

  1. Update LlmOutput parsing logic:
    Keep only List<String> labels: Parse output as comma-separated label IDs only
  2. Change flags' setting logic: No special handling for "action" field
  3. Update userPrompt in build_user_prompt()to include the system labels in addition to user context labels
  4. Simplify system prompt: Single task: "Select relevant labels"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions