a2aproject / a2aproject/a2a-samples

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

Open Beginner friendly
#409 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.8k
Forks
751
PR merge metrics
No merged PRs in 30d

Description

### 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

Contributor guide

Open the contributing guide

Research direction

Check the a2a/types.py file in the a2a-sdk package to see if AgentAuthentication is defined. Compare with the sample code in samples/python/agents/headless_agent_auth/__main__.py. Determine if the type is missing or if the sample should use a different structure. The fix likely involves updating the SDK's type definitions or the sample's import/usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.