kagent-adk 0.6.20__py3-none-any.whl → 0.6.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of kagent-adk might be problematic. Click here for more details.

kagent/adk/_a2a.py CHANGED
@@ -7,6 +7,7 @@ from typing import Callable
7
7
  import httpx
8
8
  from a2a.server.apps import A2AFastAPIApplication
9
9
  from a2a.server.request_handlers import DefaultRequestHandler
10
+ from a2a.server.tasks import InMemoryTaskStore
10
11
  from a2a.types import AgentCard
11
12
  from agentsts.adk import ADKRunner, ADKSessionService, ADKSTSIntegration, ADKTokenPropagationPlugin
12
13
  from fastapi import FastAPI, Request
@@ -118,6 +119,42 @@ class KAgentApp:
118
119
 
119
120
  return app
120
121
 
122
+ def build_local(self) -> FastAPI:
123
+ session_service = InMemorySessionService()
124
+
125
+ def create_runner() -> Runner:
126
+ return Runner(
127
+ agent=self.root_agent,
128
+ app_name=self.app_name,
129
+ session_service=session_service,
130
+ )
131
+
132
+ agent_executor = A2aAgentExecutor(
133
+ runner=create_runner,
134
+ )
135
+
136
+ task_store = InMemoryTaskStore()
137
+ request_context_builder = KAgentRequestContextBuilder(task_store=task_store)
138
+ request_handler = DefaultRequestHandler(
139
+ agent_executor=agent_executor,
140
+ task_store=task_store,
141
+ request_context_builder=request_context_builder,
142
+ )
143
+
144
+ a2a_app = A2AFastAPIApplication(
145
+ agent_card=self.agent_card,
146
+ http_handler=request_handler,
147
+ )
148
+
149
+ faulthandler.enable()
150
+ app = FastAPI()
151
+
152
+ app.add_route("/health", methods=["GET"], route=health_check)
153
+ app.add_route("/thread_dump", methods=["GET"], route=thread_dump)
154
+ a2a_app.add_routes_to_app(app)
155
+
156
+ return app
157
+
121
158
  async def test(self, task: str):
122
159
  session_service = InMemorySessionService()
123
160
  SESSION_ID = "12345"
@@ -273,21 +273,12 @@ class A2aAgentExecutor(AgentExecutor):
273
273
  session_name = text[:20] + ("..." if len(text) > 20 else "")
274
274
  break
275
275
 
276
- # Prepare kwargs for create_session
277
- create_session_kwargs = {
278
- "app_name": runner.app_name,
279
- "user_id": user_id,
280
- "state": {},
281
- "session_id": session_id,
282
- }
283
-
284
- if session_name is not None:
285
- create_session_kwargs["session_name"] = session_name
286
-
287
- # We pass the kwargs using ** to avoid issues with optional
288
- # parameters like `session_name` that exist within
289
- # `KAgentSessionService` but not in ADK `BaseSessionService`
290
- session = await runner.session_service.create_session(**create_session_kwargs)
276
+ session = await runner.session_service.create_session(
277
+ app_name=runner.app_name,
278
+ user_id=user_id,
279
+ state={"session_name": session_name},
280
+ session_id=session_id,
281
+ )
291
282
 
292
283
  # Update run_args with the new session_id
293
284
  run_args["session_id"] = session.id
@@ -32,7 +32,6 @@ class KAgentSessionService(BaseSessionService):
32
32
  user_id: str,
33
33
  state: Optional[dict[str, Any]] = None,
34
34
  session_id: Optional[str] = None,
35
- session_name: Optional[str] = None,
36
35
  ) -> Session:
37
36
  # Prepare request data
38
37
  request_data = {
@@ -41,8 +40,8 @@ class KAgentSessionService(BaseSessionService):
41
40
  }
42
41
  if session_id:
43
42
  request_data["id"] = session_id
44
- if session_name:
45
- request_data["name"] = session_name
43
+ if state and state.get("session_name"):
44
+ request_data["name"] = state.get("session_name", "")
46
45
 
47
46
  # Make API call to create session
48
47
  response = await self.client.post(
kagent/adk/cli.py CHANGED
@@ -57,6 +57,9 @@ def run(
57
57
  host: str = "127.0.0.1",
58
58
  port: int = 8080,
59
59
  workers: int = 1,
60
+ local: Annotated[
61
+ bool, typer.Option("--local", help="Run with in-memory session service (for local development)")
62
+ ] = False,
60
63
  ):
61
64
  app_cfg = KAgentConfig()
62
65
 
@@ -66,8 +69,15 @@ def run(
66
69
  with open(os.path.join(working_dir, name, "agent-card.json"), "r") as f:
67
70
  agent_card = json.load(f)
68
71
  agent_card = AgentCard.model_validate(agent_card)
72
+
69
73
  kagent_app = KAgentApp(root_agent, agent_card, app_cfg.url, app_cfg.app_name)
70
- server = kagent_app.build()
74
+
75
+ if local:
76
+ logger.info("Running in local mode with InMemorySessionService")
77
+ server = kagent_app.build_local()
78
+ else:
79
+ server = kagent_app.build()
80
+
71
81
  configure_tracing(server)
72
82
 
73
83
  uvicorn.run(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kagent-adk
3
- Version: 0.6.20
3
+ Version: 0.6.21
4
4
  Summary: kagent-adk is an sdk for integrating adk agents with kagent
5
5
  Requires-Python: >=3.11.0
6
6
  Requires-Dist: a2a-sdk>=0.3.1
@@ -1,9 +1,9 @@
1
1
  kagent/adk/__init__.py,sha256=Cam9hwhl6Z1tZ3WJIB1KATX24MwRMpiyBLYF64DTqQI,182
2
- kagent/adk/_a2a.py,sha256=4bb8imLvJR1j8iyocjUlIc3o9ww58XNlWx_oNCb8DJY,5272
3
- kagent/adk/_agent_executor.py,sha256=XU1ps53I6E3toI6cGM-K4cxQOqaz4cELh-biFlZM9lE,11504
4
- kagent/adk/_session_service.py,sha256=M8RS0jk2YiPx-nDFSeRka7a25CFEe-Pzb0b18SrojXE,5761
2
+ kagent/adk/_a2a.py,sha256=B1ZiVFJHNJyJ_6HsCbAG5w5-wF9xrNKhr3-ok9CCick,6424
3
+ kagent/adk/_agent_executor.py,sha256=3aFMR41FwluDZZJGkpsL4yhz7JgqTTSbKtLeENrr0TE,11090
4
+ kagent/adk/_session_service.py,sha256=7o2T4-572hAvpD3KZQn1ExPvI67aEuLcyHqQXB3b2JI,5757
5
5
  kagent/adk/_token.py,sha256=OL46m7U5vUTby1WWjVB7Jqzig4TWddzoAmLVLlfSdAg,2515
6
- kagent/adk/cli.py,sha256=Sdw9FXnUmeHfgJhdRDq1zpoNMf6GM7x35ZDz_OkQgJg,2963
6
+ kagent/adk/cli.py,sha256=_yluK6p7sbUld5juWCyIu3E8U1_Zys7eWxBabcHXXIo,3251
7
7
  kagent/adk/types.py,sha256=kcNpRwo6XcfMtgsOchgDuslYjMY-7pSlVnglihoUKss,5685
8
8
  kagent/adk/converters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  kagent/adk/converters/error_mappings.py,sha256=1KUJPS8VrcaTv6yUKb5Whg-S2XX8YGJmtTIeZqnqvuw,2769
@@ -12,7 +12,7 @@ kagent/adk/converters/part_converter.py,sha256=8Ej9xGRYW8YoPnExGDnEUw1beurCfkNhA
12
12
  kagent/adk/converters/request_converter.py,sha256=iTmTmhlnyRfuYyFi4WmpTSXPz22xjjotbe750j-CvYA,1072
13
13
  kagent/adk/models/__init__.py,sha256=mqD0JhS9kT1rMpFNLq5-qnjstpp6lzT9xADaOfjrUKY,78
14
14
  kagent/adk/models/_openai.py,sha256=EpZTqxAEaKhgi-98sqyQhArckWwoGh-C34fC8MyClHk,17187
15
- kagent_adk-0.6.20.dist-info/METADATA,sha256=B0AtUJ_qD2Pr6NT_vuJDBpJChk7skUbjIq7TAZ-e0Ng,1014
16
- kagent_adk-0.6.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- kagent_adk-0.6.20.dist-info/entry_points.txt,sha256=a1Q2Inc9L0dvXWEkwnCdf9cfXdpX5Dl2Q6DhNWNjhxw,50
18
- kagent_adk-0.6.20.dist-info/RECORD,,
15
+ kagent_adk-0.6.21.dist-info/METADATA,sha256=oPN2egxeoRZpz_hOoBSH1f8GgDSjRbe6pczg3UhfiSc,1014
16
+ kagent_adk-0.6.21.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
+ kagent_adk-0.6.21.dist-info/entry_points.txt,sha256=a1Q2Inc9L0dvXWEkwnCdf9cfXdpX5Dl2Q6DhNWNjhxw,50
18
+ kagent_adk-0.6.21.dist-info/RECORD,,