Skip to content

Commit 32cb94d

Browse files
authored
Revert "feat(cloud): add OAuth2/JWT authentication support for CloudStrategy"
1 parent 3c0c5bb commit 32cb94d

File tree

102 files changed

+4886
-7660
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4886
-7660
lines changed

agentkit/apps/a2a_app/telemetry.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
logger = logging.getLogger("agentkit." + __name__)
4848

49-
5049
class Telemetry:
5150
def __init__(self):
5251
self.tracer = get_tracer("agentkit.a2a_app")
@@ -58,6 +57,7 @@ def __init__(self):
5857
explicit_bucket_boundaries_advisory=_GEN_AI_CLIENT_OPERATION_DURATION_BUCKETS,
5958
)
6059

60+
6161
def trace_a2a_agent(
6262
self,
6363
func: Callable,
@@ -69,9 +69,7 @@ def trace_a2a_agent(
6969
"""Get current span and set required attributes."""
7070
trace_id = span.get_span_context().trace_id
7171
span_id = span.get_span_context().span_id
72-
logger.debug(
73-
f"Set attributes for span with trace_id={trace_id}, span_id={span_id}"
74-
)
72+
logger.debug(f"Set attributes for span with trace_id={trace_id}, span_id={span_id}")
7573

7674
# ===============================
7775
# Set attributes for current span
@@ -89,18 +87,12 @@ def trace_a2a_agent(
8987
if user_id:
9088
span.set_attribute(key="gen_ai.user.id", value=user_id)
9189

92-
span.set_attribute(
93-
key="gen_ai.input",
94-
value=safe_serialize_to_json_string(request.message.parts),
95-
)
90+
span.set_attribute(key="gen_ai.input", value=safe_serialize_to_json_string(request.message.parts))
9691

9792
span.set_attribute(key="gen_ai.span.kind", value="a2a_agent")
9893
span.set_attribute(key="gen_ai.operation.name", value="invoke_agent")
9994
span.set_attribute(key="gen_ai.operation.type", value="a2a_agent")
100-
attributes = {
101-
"gen_ai_operation_name": "invoke_agent",
102-
"gen_ai_operation_type": "a2a_agent",
103-
}
95+
attributes={"gen_ai_operation_name": "invoke_agent", "gen_ai_operation_type": "a2a_agent"}
10496

10597
if exception:
10698
self.handle_exception(span, exception)
@@ -124,3 +116,4 @@ def handle_exception(span: trace.Span, exception: Exception) -> None:
124116

125117

126118
telemetry = Telemetry()
119+

agentkit/apps/mcp_app/telemetry.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
logger = logging.getLogger("agentkit." + __name__)
4646

47-
4847
class Telemetry:
4948
def __init__(self):
5049
self.tracer = get_tracer("agentkit.mcp_app")
@@ -57,22 +56,20 @@ def __init__(self):
5756
)
5857

5958
def trace_tool(
60-
self,
61-
func: Callable,
62-
span: Span,
63-
args: dict,
64-
func_result: any,
65-
operation_type: str,
66-
exception: Exception,
59+
self,
60+
func: Callable,
61+
span: Span,
62+
args: dict,
63+
func_result: any,
64+
operation_type: str,
65+
exception: Exception,
6766
) -> None:
6867
"""Get current span and set required attributes."""
6968

7069
trace_id = span.get_span_context().trace_id
7170
span_id = span.get_span_context().span_id
7271

73-
logger.debug(
74-
f"Set attributes for span with trace_id={trace_id}, span_id={span_id}"
75-
)
72+
logger.debug(f"Set attributes for span with trace_id={trace_id}, span_id={span_id}")
7673

7774
# ===============================
7875
# Set attributes for current span
@@ -82,19 +79,14 @@ def trace_tool(
8279

8380
span.set_attribute(key="gen_ai.func_name", value=func.__name__)
8481

85-
span.set_attribute(
86-
key="gen_ai.input", value=safe_serialize_to_json_string(args)
87-
)
82+
span.set_attribute(key="gen_ai.input", value=safe_serialize_to_json_string(args))
8883
safe_result = safe_serialize_to_json_string(func_result)
8984
span.set_attribute(key="gen_ai.output", value=safe_result)
9085

9186
span.set_attribute(key="gen_ai.span.kind", value="tool")
9287
span.set_attribute(key="gen_ai.operation.name", value="tool")
9388
span.set_attribute(key="gen_ai.operation.type", value=operation_type)
94-
attributes = {
95-
"gen_ai_operation_name": "tool",
96-
"gen_ai_operation_type": operation_type,
97-
}
89+
attributes = {"gen_ai_operation_name": "tool", "gen_ai_operation_type": operation_type}
9890

9991
if exception:
10092
self.handle_exception(span, exception)
@@ -118,3 +110,4 @@ def handle_exception(span: trace.Span, exception: Exception) -> None:
118110

119111

120112
telemetry = Telemetry()
113+

agentkit/apps/simple_app/simple_app_handlers.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ async def handle(self, request: Request) -> Response | StreamingResponse:
7373

7474
logger.info("Returning non-streaming response")
7575
safe_json_string = safe_serialize_to_json_string(result)
76-
telemetry.trace_agent_finish(safe_json_string, None)
76+
telemetry.trace_agent_finish(
77+
safe_json_string, None
78+
)
7779
except Exception as e:
7880
logger.error("Invoke handler function failed: %s", e)
79-
telemetry.trace_agent_finish("", e)
81+
telemetry.trace_agent_finish(
82+
"", e
83+
)
8084
raise e
8185

8286
return Response(safe_json_string, media_type="application/json")
@@ -156,7 +160,9 @@ def _sync_stream_with_error_handling(self, generator):
156160
finally:
157161
# finish trace span and record metrics
158162
result = safe_serialize_to_json_string(last_value)
159-
telemetry.trace_agent_finish(result, exception)
163+
telemetry.trace_agent_finish(
164+
result, exception
165+
)
160166

161167
async def _stream_with_error_handling(self, generator):
162168
"""Wrap async generator to handle errors and convert to SSE format."""
@@ -178,7 +184,9 @@ async def _stream_with_error_handling(self, generator):
178184
finally:
179185
# finish trace span and record metrics
180186
result = safe_serialize_to_json_string(last_value)
181-
telemetry.trace_agent_finish(result, exception)
187+
telemetry.trace_agent_finish(
188+
result, exception
189+
)
182190

183191

184192
class PingHandler(BaseHandler):

agentkit/apps/simple_app/telemetry.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ def trace_agent(
9292
trace_id = span.get_span_context().trace_id
9393
span_id = span.get_span_context().span_id
9494

95-
logger.debug(
96-
f"Set attributes for span with trace_id={trace_id}, span_id={span_id}"
97-
)
95+
logger.debug(f"Set attributes for span with trace_id={trace_id}, span_id={span_id}")
9896

9997
# ===============================
10098
# Set attributes for current span
@@ -114,9 +112,7 @@ def trace_agent(
114112
if user_id:
115113
span.set_attribute(key="gen_ai.user.id", value=user_id)
116114

117-
span.set_attribute(
118-
key="gen_ai.input", value=safe_serialize_to_json_string(payload)
119-
)
115+
span.set_attribute(key="gen_ai.input", value=safe_serialize_to_json_string(payload))
120116

121117
span.set_attribute(key="gen_ai.span.kind", value="workflow")
122118
span.set_attribute(key="gen_ai.operation.name", value="invoke_agent")
@@ -132,10 +128,7 @@ def trace_agent_finish(
132128

133129
if span and span.is_recording():
134130
span.set_attribute(key="gen_ai.output", value=func_result)
135-
attributes = {
136-
"gen_ai_operation_name": "invoke_agent",
137-
"gen_ai_operation_type": "agent",
138-
}
131+
attributes={"gen_ai_operation_name": "invoke_agent", "gen_ai_operation_type": "agent"}
139132
if exception:
140133
self.handle_exception(span, exception)
141134
attributes["error_type"] = exception.__class__.__name__

agentkit/client/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
from agentkit.client.base_iam_client import BaseIAMClient
2424

2525
__all__ = [
26-
"BaseServiceClient",
27-
"BaseAgentkitClient",
28-
"BaseIAMClient",
29-
"ApiConfig",
26+
'BaseServiceClient',
27+
'BaseAgentkitClient',
28+
'BaseIAMClient',
29+
'ApiConfig',
3030
]

agentkit/client/base_agentkit_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626
class BaseAgentkitClient(BaseServiceClient):
2727
"""
2828
Base client for all AgentKit services.
29-
29+
3030
This class provides:
3131
1. Common credential initialization
3232
2. Unified API invocation logic with error handling
3333
3. Automatic ApiInfo generation with flexible configuration
34-
34+
3535
Subclasses should override API_ACTIONS with either:
3636
- Simple dict mapping: {"ActionName": "ActionName"}
3737
- Detailed ApiConfig: {"ActionName": ApiConfig(action="ActionName", method="GET", path="/custom")}
3838
"""
39-
39+
4040
# Subclasses should override this with their API action configurations
4141
API_ACTIONS: Dict[str, Union[str, ApiConfig]] = {}
42-
42+
4343
def __init__(
4444
self,
4545
access_key: str = "",
@@ -50,7 +50,7 @@ def __init__(
5050
) -> None:
5151
"""
5252
Initialize the AgentKit client.
53-
53+
5454
Args:
5555
access_key: Volcengine access key
5656
secret_key: Volcengine secret key
@@ -64,23 +64,23 @@ def __init__(
6464
region=region,
6565
session_token=session_token,
6666
service_name=service_name,
67-
credential_env_prefix="AGENTKIT",
67+
credential_env_prefix='AGENTKIT',
6868
)
69-
69+
7070
def _get_service_config(self) -> Dict[str, str]:
7171
"""
7272
Get AgentKit service configuration.
73-
73+
7474
Returns:
7575
Dictionary with host, api_version, and service
7676
"""
7777
host, api_version, service = get_volc_agentkit_host_info()
7878
return {
79-
"host": host,
80-
"api_version": api_version,
81-
"service": service,
79+
'host': host,
80+
'api_version': api_version,
81+
'service': service,
8282
}
83-
83+
8484
def _get(self, api_action: str, params: Dict[str, Any] = None) -> str:
8585
"""Legacy method for GET requests."""
8686
try:

agentkit/client/base_iam_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@
2525
class BaseIAMClient(BaseServiceClient):
2626
"""
2727
Base client for IAM services.
28-
28+
2929
This class provides the same interface as BaseAgentkitClient but for IAM services:
3030
1. Common credential initialization
3131
2. Unified API invocation logic with error handling
3232
3. Automatic ApiInfo generation with flexible configuration
33-
33+
3434
Subclasses should override API_ACTIONS with either:
3535
- Simple dict mapping: {"ActionName": "ActionName"}
3636
- Detailed ApiConfig: {"ActionName": ApiConfig(action="ActionName", method="GET", path="/custom")}
3737
"""
38-
38+
3939
# Subclasses should override this with their API action configurations
4040
API_ACTIONS: Dict[str, Union[str, ApiConfig]] = {}
41-
41+
4242
# IAM service specific configuration
4343
IAM_API_VERSION = "2018-01-01"
4444
IAM_SERVICE_CODE = "iam"
45-
IAM_HOST = "open.volcengineapi.com"
46-
45+
IAM_HOST ="open.volcengineapi.com"
46+
4747
def __init__(
4848
self,
4949
access_key: str = "",
@@ -54,7 +54,7 @@ def __init__(
5454
) -> None:
5555
"""
5656
Initialize the IAM client.
57-
57+
5858
Args:
5959
access_key: Volcengine access key
6060
secret_key: Volcengine secret key
@@ -68,18 +68,18 @@ def __init__(
6868
region=region,
6969
session_token=session_token,
7070
service_name=service_name,
71-
credential_env_prefix="IAM",
71+
credential_env_prefix='IAM',
7272
)
73-
73+
7474
def _get_service_config(self) -> Dict[str, str]:
7575
"""
7676
Get IAM service configuration.
77-
77+
7878
Returns:
7979
Dictionary with host, api_version, and service
8080
"""
8181
return {
82-
"host": self.IAM_HOST,
83-
"api_version": self.IAM_API_VERSION,
84-
"service": self.IAM_SERVICE_CODE,
82+
'host': self.IAM_HOST,
83+
'api_version': self.IAM_API_VERSION,
84+
'service': self.IAM_SERVICE_CODE,
8585
}

0 commit comments

Comments
 (0)