Follow Discord
Sweep 22 Oct 2026 · 04:32Z Build v2.1.308 527 read Stable v2.1.308 Latest v2.1.308 Next v2.1.308 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

events-and-streaming changedmanaged-agents/events-and-streaming

Nearest release: v2.1.301, published 5 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+65added
Lines−79removed
From line 27 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits29to this page, all time

The whole hunk

from line 27, old and new numbered
/
lines
from line 27
2727 
2828Stream events from the session to receive real-time updates as the agent works. A stream delivers only the events emitted after it opens, so open the stream before you send events to avoid a race condition.
2929 
30<CodeGroup>
30<CodeGroup exclude="shell:CLI">
3131 ```bash cURL
3232 # Open the stream first, then send the user message
3333 exec {stream}< <(
from line 46
4646 -H "anthropic-version: 2023-06-01" \
4747 -H "anthropic-beta: managed-agents-2026-04-01" \
4848 -H "content-type: application/json" \
49 -d @- >/dev/null <<'EOF'
50 {
51 "events": [
52 {
53 "type": "user.message",
54 "content": [{"type": "text", "text": "Summarize the repo README"}]
55 }
56 ]
57 }
58 EOF
49 -d '{
50 "events": [
51 {
52 "type": "user.message",
53 "content": [{"type": "text", "text": "Summarize the repo README"}]
54 }
55 ]
56 }' >/dev/null
5957 
6058 while IFS= read -r -u "$stream" event_line; do
6159 [[ $event_line == data:* ]] || continue
from line 74
7674 exec {stream}<&-
7775 ```
7876 
79 ```bash CLI
80 # This workflow does not translate well to a one-off shell command.
81 # Use one of the SDK examples in this code group instead.
82 ```
77 <CodeGroupItem language="CLI">
78 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
79 </CodeGroupItem>
8380 
8481 ```python Python
8582 # Open the stream first, then send the user message
from line 330
3333302. [List the full event history](https://platform.claude.com/docs/en/managed-agents/events-and-streaming#list-past-events) to seed a set of seen event IDs.
3343313. Tail the live stream, skipping any events already returned by the history list.
335332 
336<CodeGroup>
333<CodeGroup exclude="shell:CLI">
337334 ```bash cURL
338335 exec {stream}< <(
339336 curl --fail-with-body -sS -N \
from line 374
377374 exec {stream}<&-
378375 ```
379376 
380 ```bash CLI
381 # This workflow does not translate well to a one-off shell command.
382 # Use one of the SDK examples in this code group instead.
383 ```
377 <CodeGroupItem language="CLI">
378 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
379 </CodeGroupItem>
384380 
385381 ```python Python
386382 with client.beta.sessions.events.stream(session.id) as stream:
from line 593
597593 -H "anthropic-version: 2023-06-01" \
598594 -H "anthropic-beta: managed-agents-2026-04-01" \
599595 -H "content-type: application/json" \
600 -d @- <<'EOF'
601 {
602 "events": [
603 {
604 "type": "user.message",
605 "content": [
606 {"type": "text", "text": "Analyze the performance of the sort function in utils.py"}
607 ]
608 }
609 ]
610 }
611 EOF
596 -d '{
597 "events": [
598 {
599 "type": "user.message",
600 "content": [
601 {"type": "text", "text": "Analyze the performance of the sort function in utils.py"}
602 ]
603 }
604 ]
605 }'
612606 ```
613607 
614608 ```bash CLI
from line 768
774768 
775769The following example answers each call as it arrives:
776770 
777<CodeGroup>
771<CodeGroup exclude="shell:CLI">
778772 ```bash cURL
779773 exec {stream_fd}< <(curl --fail-with-body -sS -N \
780774 "https://api.anthropic.com/v1/sessions/$SESSION_ID/events/stream?beta=true" \
from line 805
811805 exec {stream_fd}<&-
812806 ```
813807 
814 ```bash CLI
815 # This workflow does not translate well to a one-off shell command.
816 # Use one of the SDK examples in this code group instead.
817 ```
808 <CodeGroupItem language="CLI">
809 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
810 </CodeGroupItem>
818811 
819812 ```python Python
820813 with client.beta.sessions.events.stream(session.id) as stream:
from line 1031
10381031 
10391032The following example approves every pending call:
10401033 
1041<CodeGroup>
1034<CodeGroup exclude="shell:CLI">
10421035 ```bash cURL
10431036 exec {stream_fd}< <(curl --fail-with-body -sS -N \
10441037 "https://api.anthropic.com/v1/sessions/$SESSION_ID/events/stream?beta=true" \
from line 1068
10751068 exec {stream_fd}<&-
10761069 ```
10771070 
1078 ```bash CLI
1079 # This workflow does not translate well to a one-off shell command.
1080 # Use one of the SDK examples in this code group instead.
1081 ```
1071 <CodeGroupItem language="CLI">
1072 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
1073 </CodeGroupItem>
10821074 
10831075 ```python Python
10841076 with client.beta.sessions.events.stream(session.id) as stream:
from line 1276
12841276 -H "anthropic-version: 2023-06-01" \
12851277 -H "anthropic-beta: managed-agents-2026-04-01" \
12861278 -H "content-type: application/json" \
1287 -d @- <<'EOF'
1288 {
1289 "events": [
1290 {
1291 "type": "user.message",
1292 "content": [
1293 {"type": "text", "text": "Now run the tests against the changes you made earlier."}
1294 ]
1295 }
1296 ]
1297 }
1298 EOF
1279 -d '{
1280 "events": [
1281 {
1282 "type": "user.message",
1283 "content": [
1284 {"type": "text", "text": "Now run the tests against the changes you made earlier."}
1285 ]
1286 }
1287 ]
1288 }'
12991289 ```
13001290 
13011291 ```bash CLI
from line 1447
14571447 -H "anthropic-version: 2023-06-01" \
14581448 -H "anthropic-beta: managed-agents-2026-04-01" \
14591449 -H "content-type: application/json" \
1460 -d @- <<'EOF'
1461 {
1462 "events": [
1463 {"type": "user.interrupt"},
1464 {
1465 "type": "user.message",
1466 "content": [
1467 {"type": "text", "text": "Instead, focus on fixing the bug in line 42."}
1468 ]
1469 }
1470 ]
1471 }
1472 EOF
1450 -d '{
1451 "events": [
1452 {"type": "user.interrupt"},
1453 {
1454 "type": "user.message",
1455 "content": [
1456 {"type": "text", "text": "Instead, focus on fixing the bug in line 42."}
1457 ]
1458 }
1459 ]
1460 }'
14731461 ```
14741462 
14751463 ```bash CLI
from line 1808
18201808 -H "anthropic-version: 2023-06-01" \
18211809 -H "anthropic-beta: managed-agents-2026-04-01" \
18221810 -H "content-type: application/json" \
1823 -d @- <<'EOF'
1824 {
1825 "events": [
1826 {
1827 "type": "system.message",
1828 "content": [
1829 {"type": "text", "text": "The user's current timezone is America/New_York."}
1830 ]
1831 }
1832 ]
1833 }
1834 EOF
1811 -d '{
1812 "events": [
1813 {
1814 "type": "system.message",
1815 "content": [
1816 {"type": "text", "text": "The current timezone of the user is America/New_York."}
1817 ]
1818 }
1819 ]
1820 }'
18351821 ```
18361822 
18371823 ```bash CLI
Feedback