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

Recorded here
Lines+20added
Lines−6removed
From line 261 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 261, old and new numbered
/
lines
from line 261
261261 ```
262262 
263263 ```php PHP
264 use Anthropic\Beta\Sessions\Events\ManagedAgentsAgentMessageEvent;
265 use Anthropic\Beta\Sessions\Events\ManagedAgentsSessionErrorEvent;
266 use Anthropic\Beta\Sessions\Events\ManagedAgentsTextBlock;
267 
264268 // Open the stream first, then send the user message
265269 $stream = $client->beta->sessions->events->streamStream($session->id);
266270 $client->beta->sessions->events->send(
from line 279
275279 
276280 foreach ($stream as $event) {
277281 match (true) {
278 $event instanceof \Anthropic\Beta\Sessions\Events\ManagedAgentsAgentMessageEvent => array_walk(
282 $event instanceof ManagedAgentsAgentMessageEvent => array_walk(
279283 $event->content,
280 static fn ($block) => $block instanceof \Anthropic\Beta\Sessions\Events\ManagedAgentsTextBlock ? print($block->text) : null,
284 static fn ($block) => $block instanceof ManagedAgentsTextBlock ? print($block->text) : null,
281285 ),
282 $event instanceof \Anthropic\Beta\Sessions\Events\ManagedAgentsSessionErrorEvent => printf("\n[Error: %s]", $event->error?->message ?? 'unknown'),
286 $event instanceof ManagedAgentsSessionErrorEvent => printf("\n[Error: %s]", $event->error?->message ?? 'unknown'),
283287 default => null,
284288 };
285289 if ($event->type === 'session.status_idle' || $event->type === 'session.error') {
from line 529
525529 ```
526530 
527531 ```php PHP
532 use Anthropic\Beta\Sessions\Events\ManagedAgentsAgentMessageEvent;
533 use Anthropic\Beta\Sessions\Events\ManagedAgentsTextBlock;
534 
528535 $stream = $client->beta->sessions->events->streamStream($session->id);
529536 
530537 // Stream is open and buffering. List history before tailing live.
from line 547
540547 }
541548 $seenEventIds[$event->id] = true;
542549 match (true) {
543 $event instanceof \Anthropic\Beta\Sessions\Events\ManagedAgentsAgentMessageEvent => array_walk(
550 $event instanceof ManagedAgentsAgentMessageEvent => array_walk(
544551 $event->content,
545 static fn ($block) => $block instanceof \Anthropic\Beta\Sessions\Events\ManagedAgentsTextBlock ? print($block->text) : null,
552 static fn ($block) => $block instanceof ManagedAgentsTextBlock ? print($block->text) : null,
546553 ),
547554 default => null,
548555 };
from line 1776
17691776 ```
17701777 
17711778 ```php PHP
1772 // In PHP, pass the types you want on EventListParams; see the Anthropic PHP SDK.
1779 $events = $client->beta->sessions->events->list(
1780 $session->id,
1781 types: ['agent.tool_use', 'agent.tool_result'],
1782 );
1783 foreach ($events->data as $event) {
1784 $processedAt = ($event->processedAt ?? null)?->format(DATE_RFC3339) ?? 'null';
1785 echo "[{$event->type}] {$processedAt}\n";
1786 }
17731787 ```
17741788 
17751789 ```ruby Ruby
Feedback