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

event-deltas changedmanaged-agents/event-deltas

Nearest release: v2.1.304, published under an hour after 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+16added
Lines−139removed
From line 107 where the diff opens
First seen 8 Oct 2026 this site's first read of the page
Recorded edits12to this page, all time

The whole hunk

from line 107, old and new numbered
/
lines
from line 107
107107 
108108The following examples opt in to `agent.message` previews and reconcile them with the buffered event:
109109 
110<CodeGroup exclude="shell:CLI">
111 ```bash cURL
112 # Opt in to agent.message previews via event_deltas, then accumulate manually.
113 exec {stream}< <(
114 curl --fail-with-body -sS -N \
115 "https://api.anthropic.com/v1/sessions/$SESSION_ID/events/stream?beta=true&event_deltas%5B%5D=agent.message" \
116 -H "x-api-key: $ANTHROPIC_API_KEY" \
117 -H "anthropic-version: 2023-06-01" \
118 -H "anthropic-beta: managed-agents-2026-04-01" \
119 -H "accept: text/event-stream"
120 )
110<CodeGroup exclude="shell:cURL, shell:CLI">
111 <CodeGroupItem language="cURL">
112 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.
113 </CodeGroupItem>
121114 
122 curl --fail-with-body -sS \
123 "https://api.anthropic.com/v1/sessions/$SESSION_ID/events?beta=true" \
124 -H "x-api-key: $ANTHROPIC_API_KEY" \
125 -H "anthropic-version: 2023-06-01" \
126 -H "anthropic-beta: managed-agents-2026-04-01" \
127 -H "content-type: application/json" \
128 -d '{
129 "events": [
130 {
131 "type": "user.message",
132 "content": [{"type": "text", "text": "In one short sentence, describe what an event delta is."}]
133 }
134 ]
135 }' >/dev/null
136 
137 # Accumulate deltas keyed by (message id, content index); the final
138 # agent.message carries the full text, so it replaces every preview for that id.
139 declare -A preview
140 while IFS= read -r -u "$stream" event_line; do
141 [[ $event_line == data:* ]] || continue
142 event_json=${event_line#data: }
143 case $(jq -r '.type' <<<"$event_json") in
144 event_start)
145 preview_id=$(jq -r '.event.id' <<<"$event_json")
146 printf '[event_start id=%s]\n' "$preview_id"
147 ;;
148 event_delta)
149 preview_key=$(jq -r '.event_id + ":" + (.delta.index | tostring)' <<<"$event_json")
150 preview[$preview_key]+=$(jq -r '.delta.content.text' <<<"$event_json")
151 printf '[event_delta] %s\n' "${preview[$preview_key]}"
152 ;;
153 agent.message)
154 msg_id=$(jq -r '.id' <<<"$event_json")
155 for preview_key in "${!preview[@]}"; do
156 [[ $preview_key == "$msg_id":* ]] && unset "preview[$preview_key]"
157 done
158 printf '[agent.message id=%s] ' "$msg_id"
159 jq -j '.content[] | select(.type == "text") | .text' <<<"$event_json"
160 printf '\n'
161 ;;
162 span.model_request_end)
163 for preview_key in "${!preview[@]}"; do
164 printf '[closing unreconciled preview for %s]\n' "${preview_key%%:*}"
165 done
166 preview=()
167 ;;
168 session.status_idle)
169 break
170 ;;
171 esac
172 done
173 exec {stream}<&-
174 ```
175 
176115 <CodeGroupItem language="CLI">
177116 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.
178117 </CodeGroupItem>
from line 568
629568 
630569<CodeGroup>
631570 ```bash cURL
632 # List the session's threads and pick a child: child threads carry a non-null
633 # parent_thread_id, and the primary thread's parent_thread_id is null.
634 THREAD_ID=$(
635 curl --fail-with-body -sS \
636 "https://api.anthropic.com/v1/sessions/$SESSION_ID/threads?beta=true" \
637 -H "x-api-key: $ANTHROPIC_API_KEY" \
638 -H "anthropic-version: 2023-06-01" \
639 -H "anthropic-beta: managed-agents-2026-04-01" |
640 jq -er 'first(.data[] | select(.parent_thread_id != null)).id'
641 )
642 
643 # The child thread's stream takes the same event_deltas[] parameter as the
644 # session stream. Percent-encode the brackets (%5B%5D) and quote the URL.
645 exec {stream}< <(
646 curl --fail-with-body -sS -N \
647 "https://api.anthropic.com/v1/sessions/$SESSION_ID/threads/$THREAD_ID/stream?beta=true&event_deltas%5B%5D=agent.message" \
648 -H "x-api-key: $ANTHROPIC_API_KEY" \
649 -H "anthropic-version: 2023-06-01" \
650 -H "anthropic-beta: managed-agents-2026-04-01" \
651 -H "accept: text/event-stream"
652 )
653 
654 while IFS= read -r -u "$stream" event_line; do
655 [[ $event_line == data:* ]] || continue
656 event_json=${event_line#data: }
657 case $(jq -r '.type' <<<"$event_json") in
658 event_delta)
659 jq -j '.delta.content.text' <<<"$event_json"
660 ;;
661 agent.message)
662 # The buffered event is the authoritative record; render its content.
663 printf '\n'
664 jq -j '.content[] | select(.type == "text") | .text' <<<"$event_json"
665 printf '\n'
666 ;;
667 session.thread_status_idle)
668 break
669 ;;
670 esac
671 done
672 exec {stream}<&-
571 # The thread stream takes the same event_deltas[] parameter as the session stream.
572 # Percent-encode the brackets (%5B%5D) and quote the URL.
573 curl --fail-with-body -sS -N \
574 "https://api.anthropic.com/v1/sessions/$SESSION_ID/threads/$THREAD_ID/stream?beta=true&event_deltas%5B%5D=agent.message" \
575 -H "x-api-key: $ANTHROPIC_API_KEY" \
576 -H "anthropic-version: 2023-06-01" \
577 -H "anthropic-beta: managed-agents-2026-04-01" \
578 -H "accept: text/event-stream"
673579 ```
674580 
675581 ```bash CLI
676 # List the session's threads and pick a child: child threads carry a non-null
677 # parent_thread_id, and the primary thread's parent_thread_id is null
678 # (--transform's #(parent_thread_id!=~null) query matches non-null values).
679 THREAD_ID=$(ant beta:sessions:threads list \
582 # The thread stream takes the same event_deltas parameter as the session stream,
583 # one --event-delta flag per event type to preview.
584 ant beta:sessions:threads:events stream \
680585 --session-id "$SESSION_ID" \
681 --format raw --transform 'data.#(parent_thread_id!=~null).id' --raw-output)
682 
683 # The child thread's stream takes the same event_deltas parameter as the
684 # session stream, one --event-delta flag per event type to preview. @tostr
685 # re-encodes each text field as a JSON string, so every value stays on one
686 # YAML line and jq's fromjson recovers the original text.
687 transform='{type,frag:delta.content.text|@tostr,text:content.#(type=="text").text|@tostr}'
688 exec {stream}< <(ant beta:sessions:threads:events stream \
689 --session-id "$SESSION_ID" \
690586 --thread-id "$THREAD_ID" \
691 --event-delta agent.message \
692 --transform "$transform" \
693 --format yaml)
694 
695 type=
696 while IFS= read -r -u "$stream" line; do
697 case "$line" in
698 type:\ session.thread_status_idle) break ;;
699 type:\ *) type=${line#type: } ;;
700 frag:*)
701 [[ $type == event_delta ]] || continue
702 jq -j fromjson <<<"${line#frag: }" ;;
703 text:*)
704 [[ $type == agent.message ]] || continue
705 # The buffered event is the authoritative record; render its content.
706 printf '\n'
707 jq -r fromjson <<<"${line#text: }" ;;
708 esac
709 done
710 exec {stream}<&-
587 --event-delta agent.message
711588 ```
712589 
713590 ```python Python
Feedback