a2aproject / a2aproject/a2a-samples

[Bug]: `AgentAuthentication` type is not defined in `a2a.types` but used in sample code

Đang mở
#409 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
1.8k
Fork
751
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### What happened?

# `AgentAuthentication` type is not defined in `a2a.types` but used in sample code

## Description

The sample code in `samples/python/agents/headless_agent_auth/__main__.py` imports and uses `AgentAuthentication` from `a2a.types`, but this type is not actually defined in the installed `a2a-sdk` package, causing an `ImportError`.

## Steps to Reproduce

1. Install `a2a-sdk>=0.3.0`:

```bash
pip install a2a-sdk>=0.3.0
```

2. Try to run the `headless_agent_auth` sample:

```bash
cd samples/python/agents/headless_agent_auth
python __main__.py
```

3. Or simply try to import:
```python
from a2a.types import AgentAuthentication
```

## Expected Behavior

The `AgentAuthentication` type should be available in `a2a.types` and the sample code should run without errors.

## Actual Behavior

```
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/path/to/__main__.py", line 18, in
from a2a.types import AgentAuthentication
ImportError: cannot import name 'AgentAuthentication' from 'a2a.types'
(/path/to/.venv/lib/python3.12/site-packages/a2a/types.py)
```

## Code Reference

The sample code in `samples/python/agents/headless_agent_auth/__main__.py` (lines 18-26, 71-81):

```python
from a2a.types import (
AgentAuthentication,
AgentCapabilities,
AgentCard,
AgentSkill,
)

# ...

agent_card = AgentCard(
name='Staff0 HR Agent',
# ...
authentication=AgentAuthentication(
schemes=['oauth2'],
credentials=json.dumps({
'tokenUrl': f'https://{os.getenv("HR_AUTH0_DOMAIN")}/oauth/token',
'scopes': {
'read:employee_status': 'Allows confirming...'
},
}),
),
)
```

## Environment

- **Python Version**: 3.12
- **a2a-sdk Version**: 0.3.0 (or higher)
- **OS**: macOS (but reproducible on other platforms)
- **Sample Code**: `samples/python/agents/headless_agent_auth/`

## Question

Is `AgentAuthentication` intentionally not included in the current release? If so:

- Should the sample code be updated to use dictionaries?
- Is there a plan to add this type in a future release?
- Is there documentation on the expected structure of the `authentication` field?

## Related Files

- `samples/python/agents/headless_agent_auth/__main__.py` - Uses `AgentAuthentication`
- `samples/python/agents/headless_agent_auth/pyproject.toml` - Requires `a2a-sdk>=0.3.0`
- `a2a/types.py` - Should define `AgentAuthentication` but doesn't

---

**Note**: This issue prevents the official sample code from running and creates confusion for developers implementing authentication in their A2A agents.

### Relevant log output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.