Skip to content
Merged
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
26 changes: 18 additions & 8 deletions python/composio/core/models/tool_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from __future__ import annotations

import typing as t
from types import SimpleNamespace

import typing_extensions as te
from composio_client.types.tool_router_create_session_params import ConfigToolkit

from composio.client import HttpClient
Expand All @@ -19,11 +19,19 @@
# Data Types


class ToolRouterSession(te.TypedDict):
"""Tool router session response."""
class ToolRouterSession(SimpleNamespace):
"""Tool router session response with both dot notation and dict-style access."""

session_id: str # Unique session identifier
url: str # Chat session MCP URL
def __init__(self, session_id: str, url: str):
super().__init__(session_id=session_id, url=url)

def __getitem__(self, key: str) -> str:
"""Support dict-style access like session['url']"""
return getattr(self, key)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Session Access Violates Expected Dictionary Behavior

The ToolRouterSession.__getitem__ method raises AttributeError for missing keys. Dict-style access, as intended, should raise KeyError instead, which can break error handling that expects standard dictionary behavior.

Fix in Cursor Fix in Web


def __setitem__(self, key: str, value: str) -> None:
"""Support dict-style assignment like session['url'] = 'new_url'"""
setattr(self, key, value)


class ToolRouter(Resource):
Expand Down Expand Up @@ -73,9 +81,11 @@ def create_session(
... manually_manage_connections=False
... )
>>>
>>> # Access session details
>>> print(session['session_id'])
>>> print(session['url'])
>>> # Access session details (both ways work!)
>>> print(session.session_id) # Dot notation (preferred)
>>> print(session['session_id']) # Dict-style access
>>> print(session.url) # Dot notation (preferred)
>>> print(session['url']) # Dict-style access
"""
try:
# Normalize toolkits to the format expected by the API
Expand Down
2 changes: 1 addition & 1 deletion python/composio/core/models/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import functools
import typing as t

from composio_client import omit
import typing_extensions as te
from composio_client import omit

from composio.client import HttpClient
from composio.client.types import (
Expand Down
2 changes: 1 addition & 1 deletion python/composio/core/models/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import uuid
from concurrent.futures import ThreadPoolExecutor
from unittest import mock
from composio_client import omit

import typing_extensions as te
from composio_client import omit
from pysher import Pusher
from pysher.channel import Channel as PusherChannel
from pysher.connection import Connection as PusherConnection
Expand Down
10 changes: 6 additions & 4 deletions python/providers/google_adk/google_adk_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
new_message=content,
)
for event in events:
if (event.is_final_response()
and event.content is not None
and event.content.parts
and len(event.content.parts) > 0):
if (
event.is_final_response()
and event.content is not None
and event.content.parts
and len(event.content.parts) > 0
):
print("Agent Response: ", event.content.parts[0].text)
Loading