events-and-streaming changedmanaged-agents/events-and-streaming
Nearest release: v2.1.309, published 13 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+0added
Lines−21removed
From line
692
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits32to this page, all time
The whole hunk
from line 692, old and new numbered
/
from line 692
692692 for event in stream:
693693 match event.type:
694694 case "agent.custom_tool_use":
695 # Run the tool
696695 result = call_tool(event.name, event.input)
697696
698 # Send the result back
699697 client.beta.sessions.events.send(
700698 session.id,
701699 events=[
from line 715
717715 loop: for await (const event of stream) {
718716 switch (event.type) {
719717 case "agent.custom_tool_use": {
720 // Run the tool
721718 const result = await callTool(event.name, event.input);
722719
723 // Send the result back
724720 await client.beta.sessions.events.send(session.id, {
725721 events: [
726722 {
from line 742
746742 {
747743 if (streamEvent.Value is BetaManagedAgentsAgentCustomToolUseEvent toolUse)
748744 {
749 // Run the tool
750745 var result = await CallTool(toolUse.Name, toolUse.Input);
751746
752 // Send the result back
753747 await client.Beta.Sessions.Events.Send(session.ID, new()
754748 {
755749 Events =
from line 772
778772 for stream.Next() {
779773 switch event := stream.Current().AsAny().(type) {
780774 case anthropic.BetaManagedAgentsAgentCustomToolUseEvent:
781 // Run the tool
782775 result := callTool(event.Name, event.Input)
783 // Send the result back
784776 if _, err := client.Beta.Sessions.Events.Send(ctx, session.ID, anthropic.BetaSessionEventSendParams{
785777 Events: []anthropic.BetaManagedAgentsEventParamsUnion{{
786778 OfUserCustomToolResult: &anthropic.BetaManagedAgentsUserCustomToolResultEventParams{
from line 804
812804 for (var event : (Iterable<BetaManagedAgentsStreamSessionEvents>) stream.stream()::iterator) {
813805 switch (event.type().value()) {
814806 case AGENT_CUSTOM_TOOL_USE -> {
815 // Run the tool
816807 var toolUse = event.asAgentCustomToolUse();
817808 var result = callTool(toolUse.name(), toolUse.input());
818809
819 // Send the result back
820810 client.beta().sessions().events().send(
821811 session.id(),
822812 EventSendParams.builder()
from line 832
842832 foreach ($stream as $event) {
843833 switch (true) {
844834 case $event instanceof \Anthropic\Beta\Sessions\Events\ManagedAgentsAgentCustomToolUseEvent:
845 // Run the tool
846835 $result = callTool($event->name, $event->input);
847836
848 // Send the result back
849837 $client->beta->sessions->events->send(
850838 $session->id,
851839 events: [
from line 858
870858 client.beta.sessions.events.stream_events(session.id).each do |event|
871859 case event
872860 when Anthropic::Beta::Sessions::BetaManagedAgentsAgentCustomToolUseEvent
873 # Run the tool
874861 result = call_tool.call(event.name, event.input)
875 # Send the result back
876862 client.beta.sessions.events.send_(
877863 session.id,
878864 events: [
from line 900
914900 match stop_reason.type:
915901 case "requires_action":
916902 for event_id in stop_reason.event_ids:
917 # Approve the pending tool call
918903 client.beta.sessions.events.send(
919904 session.id,
920905 events=[
from line 929
944929 }
945930
946931 for (const eventId of event.stop_reason.event_ids) {
947 // Approve the pending tool call
948932 await client.beta.sessions.events.send(session.id, {
949933 events: [
950934 {
from line 951
967951 {
968952 foreach (var eventId in requiresAction.EventIds)
969953 {
970 // Approve the pending tool call
971954 await client.Beta.Sessions.Events.Send(session.ID, new()
972955 {
973956 Events =
from line 984
1001984 switch stopReason := event.StopReason.AsAny().(type) {
1002985 case anthropic.BetaManagedAgentsSessionRequiresAction:
1003986 for _, eventID := range stopReason.EventIDs {
1004 // Approve the pending tool call
1005987 if _, err := client.Beta.Sessions.Events.Send(ctx, session.ID, anthropic.BetaSessionEventSendParams{
1006988 Events: []anthropic.BetaManagedAgentsEventParamsUnion{{
1007989 OfUserToolConfirmation: &anthropic.BetaManagedAgentsUserToolConfirmationEventParams{
from line 1012
10301012 .takeWhile(stopReason -> !stopReason.isEndTurn())
10311013 .filter(stopReason -> stopReason.isRequiresAction())
10321014 .flatMap(stopReason -> stopReason.asRequiresAction().eventIds().stream())
1033 // Approve each pending tool call
10341015 .forEach(toolUseId -> client.beta().sessions().events().send(
10351016 session.id(),
10361017 EventSendParams.builder()
from line 1031
10501031 switch (true) {
10511032 case $event->stopReason instanceof \Anthropic\Beta\Sessions\Events\ManagedAgentsSessionRequiresAction:
10521033 foreach ($event->stopReason->eventIDs as $eventId) {
1053 // Approve the pending tool call
10541034 $client->beta->sessions->events->send(
10551035 $session->id,
10561036 events: [
from line 1058
10781058 case stop_reason
10791059 when Anthropic::Beta::Sessions::BetaManagedAgentsSessionRequiresAction
10801060 stop_reason.event_ids.each do |event_id|
1081 # Approve the pending tool call
10821061 client.beta.sessions.events.send_(
10831062 session.id,
10841063 events: [
No line in this hunk matches that.