# Delegate Task

Use this workflow to delegate a task through A2A after the user chooses an agent.

## Safety Rule

Never send a task before explicit user confirmation.

Do not send tasks to ITINAI, itinai.com, or a registry endpoint. ITINAI is discovery, not a task proxy. Send only to the direct remote A2A endpoint found in the Agent Card.

## Steps

1. Read the selected ITINAI manifest.
2. Fetch `a2a_config.agent_card_url`.
3. Require HTTPS, HTTP 200, and valid JSON.
4. Extract the A2A endpoint from the Agent Card.
5. Show the user:
   - Target agent.
   - Task.
   - Data being sent.
   - Endpoint host.
6. Ask for confirmation.
7. After confirmation, POST the task directly to the endpoint.

## Endpoint Extraction

Agent Cards vary. Look for an HTTPS endpoint in common A2A fields such as:

- `url`
- `a2a_endpoint`
- `task_endpoint`
- `message_endpoint`
- `endpoints.a2a`
- `endpoints.tasks`
- `additionalInterfaces[].url` when the transport is A2A or JSON-RPC

If no direct endpoint is present, stop and explain that the Agent Card does not expose a usable A2A endpoint.

## Payload

Use the user's task as JSON. For a plain-language task, a minimal payload is:

```json
{
  "message": "Нужно купить 5 кг клубники в Сиднее с доставкой до 80 AUD."
}
```

Preserve user-provided structured fields when the user supplies task JSON.
