Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions agents/chat/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions apps/adk-cli/src/kagenti_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import httpx
import openai
import pydantic
from a2a.client import A2AClientError, Client, ClientConfig, ClientFactory
from a2a.client import A2AClientError, Client, ClientCallContext, ClientConfig, ClientFactory
from a2a.extensions.common import HTTP_EXTENSION_HEADER
from a2a.types import AgentCard
from kagenti_adk.platform.context import ContextToken
from google.protobuf.json_format import MessageToDict
Expand Down Expand Up @@ -131,16 +132,26 @@ class OpenAPISchema(pydantic.BaseModel):
return None


def make_extension_context(extensions: list[str] | None = None) -> ClientCallContext | None:
"""Create a ClientCallContext with extension URIs as service parameters."""
if not extensions:
return None
return ClientCallContext(service_parameters={HTTP_EXTENSION_HEADER: ",".join(extensions)})


@asynccontextmanager
async def a2a_client(agent_card: AgentCard, context_token: ContextToken) -> AsyncIterator[Client]:
async def a2a_client(
agent_card: AgentCard,
context_token: ContextToken,
) -> AsyncIterator[Client]:
try:
async with httpx.AsyncClient(
headers={"Authorization": f"Bearer {context_token.token.get_secret_value()}"},
follow_redirects=True,
timeout=timedelta(hours=1).total_seconds(),
) as httpx_client:
yield ClientFactory(ClientConfig(httpx_client=httpx_client, use_client_preference=True)).create(
card=agent_card
card=agent_card,
)
except A2AClientError as ex:
card_data = json.dumps(
Expand Down
Loading
Loading