|
43 | 43 |
|
44 | 44 |
|
45 | 45 | class ParametersConfig(BaseModel): |
46 | | - """Configuration for the parameters passed to the A2A send_message request.""" |
| 46 | + """Configuration for the parameters passed to the A2A send_message request.""" |
47 | 47 |
|
48 | | - request_metadata: Optional[dict[str, Any]] = None |
49 | | - client_call_context: Optional[ClientCallContext] = None |
50 | | - # TODO: Add support for requested_extension and |
51 | | - # message_send_configuration once they are supported by the A2A client. |
52 | | - # |
53 | | - # requested_extension: Optional[list[str]] = None |
54 | | - # message_send_configuration: Optional[MessageSendConfiguration] = None |
| 48 | + request_metadata: Optional[dict[str, Any]] = None |
| 49 | + client_call_context: Optional[ClientCallContext] = None |
| 50 | + # TODO: Add support for requested_extension and |
| 51 | + # message_send_configuration once they are supported by the A2A client. |
| 52 | + # |
| 53 | + # requested_extension: Optional[list[str]] = None |
| 54 | + # message_send_configuration: Optional[MessageSendConfiguration] = None |
55 | 55 |
|
56 | 56 |
|
57 | 57 | class RequestInterceptor(BaseModel): |
58 | | - """Interceptor for A2A requests.""" |
| 58 | + """Interceptor for A2A requests.""" |
59 | 59 |
|
60 | | - before_request: Optional[ |
61 | | - Callable[ |
62 | | - [InvocationContext, A2AMessage, ParametersConfig], |
63 | | - Awaitable[tuple[Union[A2AMessage, Event], ParametersConfig]], |
64 | | - ] |
65 | | - ] = None |
66 | | - """Hook executed before the agent starts processing the request. |
| 60 | + before_request: Optional[ |
| 61 | + Callable[ |
| 62 | + [InvocationContext, A2AMessage, ParametersConfig], |
| 63 | + Awaitable[tuple[Union[A2AMessage, Event], ParametersConfig]], |
| 64 | + ] |
| 65 | + ] = None |
| 66 | + """Hook executed before the agent starts processing the request. |
67 | 67 |
|
68 | 68 | Returns an Event if the request should be aborted and the Event |
69 | 69 | returned to the caller. |
70 | 70 | """ |
71 | 71 |
|
72 | | - after_request: Optional[ |
73 | | - Callable[ |
74 | | - [InvocationContext, A2AEvent, Event], Awaitable[Union[Event, None]] |
75 | | - ] |
76 | | - ] = None |
77 | | - """Hook executed after the agent has processed the request. |
| 72 | + after_request: Optional[ |
| 73 | + Callable[ |
| 74 | + [InvocationContext, A2AEvent, Event], Awaitable[Union[Event, None]] |
| 75 | + ] |
| 76 | + ] = None |
| 77 | + """Hook executed after the agent has processed the request. |
78 | 78 |
|
79 | 79 | Returns None if the event should not be sent to the caller. |
80 | 80 | """ |
81 | 81 |
|
82 | 82 |
|
83 | 83 | class A2aRemoteAgentConfig(BaseModel): |
84 | | - """Configuration for A2A remote agents.""" |
85 | | - |
86 | | - # Converts standard A2A Messages into ADK Event. |
87 | | - a2a_message_converter: A2AMessageToEventConverter = ( |
88 | | - convert_a2a_message_to_event |
89 | | - ) |
90 | | - |
91 | | - # Converts an A2A Task into an ADK Event. |
92 | | - a2a_task_converter: A2ATaskToEventConverter = convert_a2a_task_to_event |
93 | | - |
94 | | - # Converts A2A TaskStatusUpdateEvents into ADK Event. |
95 | | - a2a_status_update_converter: A2AStatusUpdateToEventConverter = ( |
96 | | - convert_a2a_status_update_to_event |
97 | | - ) |
98 | | - |
99 | | - # Converts A2A TaskArtifactUpdateEvents into ADK Event. |
100 | | - a2a_artifact_update_converter: A2AArtifactUpdateToEventConverter = ( |
101 | | - convert_a2a_artifact_update_to_event |
102 | | - ) |
103 | | - |
104 | | - # A low-level hook that converts individual A2A Message Parts |
105 | | - # into native ADK/GenAI Part objects. |
106 | | - # This is utilized internally by the other converters. |
107 | | - a2a_part_converter: A2APartToGenAIPartConverter = ( |
108 | | - convert_a2a_part_to_genai_part |
109 | | - ) |
110 | | - |
111 | | - request_interceptors: Optional[list[RequestInterceptor]] = None |
112 | | - |
113 | | - def __deepcopy__(self, memo): |
114 | | - cls = self.__class__ |
115 | | - copied_values = {} |
116 | | - for k, v in self.__dict__.items(): |
117 | | - if not k.startswith('_'): |
118 | | - if callable(v): |
119 | | - copied_values[k] = v |
120 | | - else: |
121 | | - copied_values[k] = copy.deepcopy(v, memo) |
122 | | - result = cls.model_construct(**copied_values) |
123 | | - memo[id(self)] = result |
124 | | - return result |
| 84 | + """Configuration for A2A remote agents.""" |
| 85 | + |
| 86 | + # Converts standard A2A Messages into ADK Event. |
| 87 | + a2a_message_converter: A2AMessageToEventConverter = ( |
| 88 | + convert_a2a_message_to_event |
| 89 | + ) |
| 90 | + |
| 91 | + # Converts an A2A Task into an ADK Event. |
| 92 | + a2a_task_converter: A2ATaskToEventConverter = convert_a2a_task_to_event |
| 93 | + |
| 94 | + # Converts A2A TaskStatusUpdateEvents into ADK Event. |
| 95 | + a2a_status_update_converter: A2AStatusUpdateToEventConverter = ( |
| 96 | + convert_a2a_status_update_to_event |
| 97 | + ) |
| 98 | + |
| 99 | + # Converts A2A TaskArtifactUpdateEvents into ADK Event. |
| 100 | + a2a_artifact_update_converter: A2AArtifactUpdateToEventConverter = ( |
| 101 | + convert_a2a_artifact_update_to_event |
| 102 | + ) |
| 103 | + |
| 104 | + # A low-level hook that converts individual A2A Message Parts |
| 105 | + # into native ADK/GenAI Part objects. |
| 106 | + # This is utilized internally by the other converters. |
| 107 | + a2a_part_converter: A2APartToGenAIPartConverter = ( |
| 108 | + convert_a2a_part_to_genai_part |
| 109 | + ) |
| 110 | + |
| 111 | + request_interceptors: Optional[list[RequestInterceptor]] = None |
| 112 | + |
| 113 | + def __deepcopy__(self, memo): |
| 114 | + cls = self.__class__ |
| 115 | + copied_values = {} |
| 116 | + for k, v in self.__dict__.items(): |
| 117 | + if not k.startswith("_"): |
| 118 | + if callable(v): |
| 119 | + copied_values[k] = v |
| 120 | + else: |
| 121 | + copied_values[k] = copy.deepcopy(v, memo) |
| 122 | + result = cls.model_construct(**copied_values) |
| 123 | + memo[id(self)] = result |
| 124 | + return result |
0 commit comments