Skip to content

Implement flow for agents to request additional information from client #58

@eshulman2

Description

@eshulman2

Description

Enable agents to request additional information from users when needed to complete action items. The AgentResponse already includes an additional_info_required field, but there's no mechanism to collect and provide that information back to the agent.

Current Limitation

When an agent encounters an action item that requires clarification (e.g., "Create ticket for login bug" without details about the bug), it either:

  • Makes assumptions and proceeds
  • Returns an error
  • Sets additional_info_required=true but workflow ends

🚨 Claude Proposed Solution (Read/Implement with caution) 🚨

1. Enhanced AgentResponse Schema

# src/core/schemas/agent_response.py

class InformationRequest(BaseModel):
    """Structured request for additional information."""
    field_name: str = Field(description="Name of the field needing clarification")
    question: str = Field(description="Question to ask the user")
    suggestion: Optional[str] = Field(default=None, description="Suggested value if available")
    required: bool = Field(default=True, description="Whether this field is required")
    field_type: str = Field(default="text", description="Type: text, select, date, multiline")
    options: Optional[List[str]] = Field(default=None, description="Options for select type")

class AgentResponse(BaseModel):
    response: str
    error: bool
    additional_info_required: bool
    # NEW: Structured information requests
    information_requests: Optional[List[InformationRequest]] = None

2. Information Collection Workflow

# src/core/workflows/information_collection_workflow.py

class InformationCollectionWorkflow:
    """Workflow to collect additional information from users."""

    @step
    async def request_information(
        self,
        ctx: Context,
        ev: AgentResponseEvent
    ) -> InformationEvent:
        """Extract information requests from agent response."""
        if not ev.response.additional_info_required:
            return InformationEvent(complete=True)

        return InformationEvent(
            requests=ev.response.information_requests,
            agent_name=ev.agent_name,
            action_item=ev.action_item
        )

    @step
    async def collect_from_user(
        self,
        ctx: Context,
        ev: InformationEvent
    ) -> CollectedInfoEvent:
        """Collect information from user (via CLI or API)."""
        # This step pauses workflow and waits for user input
        # Can be resumed with collected information
        pass

    @step
    async def retry_with_information(
        self,
        ctx: Context,
        ev: CollectedInfoEvent
    ) -> AgentResponseEvent:
        """Retry agent execution with additional information."""
        # Enrich action item with collected information
        enriched_item = self._enrich_action_item(
            ev.action_item,
            ev.collected_info
        )

        # Re-execute agent
        result = await self._execute_agent(
            ev.agent_name,
            enriched_item
        )

        return AgentResponseEvent(response=result)

3. API Endpoints for Information Flow

# src/core/workflow_servers/action_items_server.py

class InformationResponse(BaseModel):
    execution_id: str
    action_item_index: int
    information: Dict[str, Any]  # field_name -> value

@app.post("/provide-information")
async def provide_additional_information(request: InformationResponse):
    """Provide additional information to resume execution.

    This endpoint allows users to provide information requested by agents
    and resume the workflow execution.
    """
    # Resume workflow with provided information
    # Re-execute agent with enriched action item
    pass

@app.get("/pending-information/{execution_id}")
async def get_pending_requests(execution_id: str):
    """Get all pending information requests for an execution."""
    # Return list of information requests waiting for user input
    pass

4. Enhanced CLI Client

# src/clients/meeting_actions_client.py

def handle_information_requests(
    self,
    execution_result: AgentExecutionResult
) -> Dict[str, Any]:
    """Collect additional information from user via CLI."""

    if not execution_result.additional_info_required:
        return {}

    console.print("\n[yellow]Agent needs additional information:[/yellow]")

    collected_info = {}
    for req in execution_result.information_requests:
        console.print(f"\n[cyan]{req.question}[/cyan]")

        if req.suggestion:
            console.print(f"[dim]Suggestion: {req.suggestion}[/dim]")

        if req.field_type == "select":
            # Present options
            value = self._select_from_options(req.options)
        elif req.field_type == "date":
            value = self._get_date_input()
        elif req.field_type == "multiline":
            value = self._get_multiline_input()
        else:
            value = self.get_input(req.field_name, req.suggestion)

        if not value and req.required:
            console.print("[red]This field is required[/red]")
            continue

        collected_info[req.field_name] = value

    return collected_info

def retry_with_information(
    self,
    execution_id: str,
    action_item_index: int,
    information: Dict[str, Any]
):
    """Retry action item execution with additional information."""

    response = requests.post(
        f"{self.url}/provide-information",
        json={
            "execution_id": execution_id,
            "action_item_index": action_item_index,
            "information": information
        }
    )

    return response.json()

Example Flow

Scenario: Vague Bug Report

Original Action Item: "Create ticket for login issue"

Step 1: Agent attempts execution

{
  "response": "I need more information to create a complete ticket",
  "error": false,
  "additional_info_required": true,
  "information_requests": [
    {
      "field_name": "bug_description",
      "question": "What is the specific login issue?",
      "required": true,
      "field_type": "multiline"
    },
    {
      "field_name": "affected_users",
      "question": "Are all users affected or specific users?",
      "suggestion": "All users",
      "required": false,
      "field_type": "select",
      "options": ["All users", "Specific users", "Unknown"]
    },
    {
      "field_name": "severity",
      "question": "What is the severity?",
      "required": true,
      "field_type": "select",
      "options": ["Critical", "High", "Medium", "Low"]
    }
  ]
}

Step 2: User provides information via CLI

Agent needs additional information:

What is the specific login issue?
> Users cannot login with Google SSO, getting 403 error

Are all users affected or specific users?
Suggestion: All users
> [Select: All users]

What is the severity?
> [Select: Critical]

Step 3: System retries with enriched action item

{
  "title": "Create ticket for login issue",
  "description": "Users cannot login with Google SSO, getting 403 error. Affects all users.",
  "priority": "critical",
  "additional_context": {
    "bug_description": "Users cannot login with Google SSO, getting 403 error",
    "affected_users": "All users",
    "severity": "Critical"
  }
}

Step 4: Agent successfully creates ticket

{
  "response": "Created Jira ticket PROJ-456 for critical SSO login issue",
  "error": false,
  "additional_info_required": false
}

Acceptance Criteria

  • Enhanced AgentResponse with structured information requests
  • Information collection workflow implemented
  • API endpoints for providing information
  • CLI client collects information interactively
  • Support for different field types (text, select, date, multiline)
  • Workflow can pause and resume/re-try with information
  • Track which information was provided for each retry
  • Handle retry limits (max 3 retries)
  • Tests for information collection flow
  • Documentation with examples

Priority: 🟡 Medium
Effort: 8-10 hours
Difficulty: Medium-High

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions