Skip to content

Commit 692fd20

Browse files
authored
docs: update citations section (#2002)
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
1 parent e0d7968 commit 692fd20

2 files changed

Lines changed: 66 additions & 18 deletions

File tree

docs/development/agent-integration/citations.mdx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@ title: Add Citations to Agent Responses
33
description: Add source references to agent responses with clickable links
44
---
55

6-
## Basic Usage
6+
The Citation extension allows agents to include source references in their responses.
7+
Citations appear as highlighted text with hover tooltips and clickable source links in the Agent Stack UI,
8+
making it easy for users to verify the information.
9+
10+
Each citation requires:
11+
12+
| Field | Description |
13+
|-------|-------------|
14+
| `url` | Source link |
15+
| `title` | Display title |
16+
| `description` | Brief explanation |
17+
| `start_index` | Start position in text |
18+
| `end_index` | End position in text |
19+
20+
## Example: Basic Usage
721

822
```python
923
from typing import Annotated
@@ -39,17 +53,25 @@ async def research_agent(
3953
yield citation.message(text=response_text, citations=citations)
4054
```
4155

42-
## Citation Format
56+
<Steps>
57+
<Step title="Import the citation extension">
58+
Import `CitationExtensionServer` and `CitationExtensionSpec` from `agentstack_sdk.a2a.extensions`.
59+
</Step>
4360

44-
Each citation requires:
45-
- `url`: Source link
46-
- `title`: Display title
47-
- `description`: Brief explanation
48-
- `start_index`: Start position in text
49-
- `end_index`: End position in text
61+
<Step title="Inject the extension">
62+
Add a citation parameter to your agent function using the `Annotated` type hint
63+
with `CitationExtensionSpec()`.
64+
</Step>
65+
66+
<Step title="Yield citation message">
67+
Call `yield citation.message()` with `text` and `citations`.
68+
</Step>
69+
</Steps>
5070

5171
## Multiple Citations
5272

73+
Yield multiple citations in a single response:
74+
5375
```python
5476
response_text = "Python leads AI development while JavaScript dominates web development."
5577

@@ -71,4 +93,6 @@ citations = [
7193
]
7294
```
7395

74-
Citations appear as highlighted text with hover tooltips and clickable source links in the UI.
96+
## Example: Advanced Usage
97+
98+
For a more advanced example, see [citation_agent.py](https://github.com/i-am-bee/agentstack/blob/main/apps/agentstack-sdk-py/examples/citation_agent.py).

docs/stable/agent-integration/citations.mdx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@ title: Add Citations to Agent Responses
33
description: Add source references to agent responses with clickable links
44
---
55

6-
## Basic Usage
6+
The Citation extension allows agents to include source references in their responses.
7+
Citations appear as highlighted text with hover tooltips and clickable source links in the Agent Stack UI,
8+
making it easy for users to verify the information.
9+
10+
Each citation requires:
11+
12+
| Field | Description |
13+
|-------|-------------|
14+
| `url` | Source link |
15+
| `title` | Display title |
16+
| `description` | Brief explanation |
17+
| `start_index` | Start position in text |
18+
| `end_index` | End position in text |
19+
20+
## Example: Basic Usage
721

822
```python
923
from typing import Annotated
@@ -39,17 +53,25 @@ async def research_agent(
3953
yield citation.message(text=response_text, citations=citations)
4054
```
4155

42-
## Citation Format
56+
<Steps>
57+
<Step title="Import the citation extension">
58+
Import `CitationExtensionServer` and `CitationExtensionSpec` from `agentstack_sdk.a2a.extensions`.
59+
</Step>
4360

44-
Each citation requires:
45-
- `url`: Source link
46-
- `title`: Display title
47-
- `description`: Brief explanation
48-
- `start_index`: Start position in text
49-
- `end_index`: End position in text
61+
<Step title="Inject the extension">
62+
Add a citation parameter to your agent function using the `Annotated` type hint
63+
with `CitationExtensionSpec()`.
64+
</Step>
65+
66+
<Step title="Yield citation message">
67+
Call `yield citation.message()` with `text` and `citations`.
68+
</Step>
69+
</Steps>
5070

5171
## Multiple Citations
5272

73+
Yield multiple citations in a single response:
74+
5375
```python
5476
response_text = "Python leads AI development while JavaScript dominates web development."
5577

@@ -71,4 +93,6 @@ citations = [
7193
]
7294
```
7395

74-
Citations appear as highlighted text with hover tooltips and clickable source links in the UI.
96+
## Example: Advanced Usage
97+
98+
For a more advanced example, see [citation_agent.py](https://github.com/i-am-bee/agentstack/blob/main/apps/agentstack-sdk-py/examples/citation_agent.py).

0 commit comments

Comments
 (0)