https://linen.dev logo
Latency Issue with composio-langgraph Tools
# 🖥│support-forum
b
Hey @udaysidagana @abhishekpatil4 we are running into significant latency when using
composio-langgraph>=0.7.15,<0.8
with Python
>=3.11,<3.13
. ### Code Snippet
Copy code
python
all_enabled_composio_tools = composio_toolset.get_tools(
    actions=array_of_action_strings,
    processors=postprocessingfunctions,
)
When calling get_tools, the execution time becomes very high as the number of actions and subtools increases. For 49 actions, the call took about 23 seconds. The latency grows further depending on how many actions strings we pass. This delay makes it difficult to use the tools in real-time scenarios, where faster response times are critical.
i
Following
Hey @udaysidagana @abhishekpatil4 any update on this? We're facing this issue on production
a
Hey @bhukyayedukondalunaik_00285, Can you share the
actions
you're passing? this would help in troubleshooting the issue
i
Hey @abhishekpatil4 It depends on what all actions are enabled , but the format for example is this -
[Action.GITHUB_ADD_A_SECURITY_MANAGER_TEAM, Action.GIT_GET_PATCH_CMD]
a
Yes, If you could share the values passed where in you're seeing latency of 23s it would be helpful to troubleshoot
i
The return value we're getting is something like this
Copy code
[StructuredTool(name='FIGMA_GET_CURRENT_USER', description='Retrieves detailed information for the currently authenticated figma user.', args_schema=<class 'composio.utils.shared.GetCurrentUserRequest'>, handle_tool_error=True, handle_validation_error=True, func=<function ComposioToolSet._wrap_action.<locals>.function at 0x7f86404e1440>), StructuredTool(name='FIGMA_GET_FILES_IN_A_PROJECT', description='Fetches a list of files in a figma project, optionally including branch metadata.', args_schema=<class 'composio.utils.shared.GetFilesInAProjectRequest'>, handle_tool_error=True, handle_validation_error=True, func=<function ComposioToolSet._wrap_action.<locals>.function at 0x7f86404e14e0>),
b
We're passing at max 128 tool actions to the toolset initializer, but the resulting latency ranges significantly between 20-30s and sometimes it take more than that.
We use Google Sheets in our workflow and these are all the actions. For refs.
Copy code
[
  'GOOGLESHEETS_ADD_SHEET',
  'GOOGLESHEETS_APPEND_DIMENSION',
  'GOOGLESHEETS_BATCH_UPDATE',
  'GOOGLESHEETS_CLEAR_BASIC_FILTER',
  'GOOGLESHEETS_DELETE_DIMENSION',
  'GOOGLESHEETS_DELETE_SHEET',
  'GOOGLESHEETS_GET_SPREADSHEET_BY_DATA_FILTER',
  'GOOGLESHEETS_GET_SPREADSHEET_INFO',
  'GOOGLESHEETS_INSERT_DIMENSION',
  'GOOGLESHEETS_SEARCH_DEVELOPER_METADATA',
  'GOOGLESHEETS_SET_BASIC_FILTER',
  'GOOGLESHEETS_SPREADSHEETS_SHEETS_COPY_TO',
  'GOOGLESHEETS_SPREADSHEETS_VALUES_APPEND',
  'GOOGLESHEETS_SPREADSHEETS_VALUES_BATCH_CLEAR',
  'GOOGLESHEETS_SPREADSHEETS_VALUES_BATCH_CLEAR_BY_DATA_FILTER',
  'GOOGLESHEETS_SPREADSHEETS_VALUES_BATCH_GET_BY_DATA_FILTER',
  'GOOGLESHEETS_UPDATE_SHEET_PROPERTIES',
  'GOOGLESHEETS_UPDATE_SPREADSHEET_PROPERTIES',
  'GOOGLESHEETS_AGGREGATE_COLUMN_DATA',
  'GOOGLESHEETS_BATCH_GET',
  'GOOGLESHEETS_BATCH_UPDATE_VALUES_BY_DATA_FILTER',
  'GOOGLESHEETS_CLEAR_VALUES',
  'GOOGLESHEETS_CREATE_CHART',
  'GOOGLESHEETS_CREATE_GOOGLE_SHEET1',
  'GOOGLESHEETS_CREATE_SPREADSHEET_COLUMN',
  'GOOGLESHEETS_CREATE_SPREADSHEET_ROW',
  'GOOGLESHEETS_EXECUTE_SQL',
  'GOOGLESHEETS_FIND_WORKSHEET_BY_TITLE',
  'GOOGLESHEETS_FORMAT_CELL',
  'GOOGLESHEETS_GET_SHEET_NAMES',
  'GOOGLESHEETS_GET_TABLE_SCHEMA',
  'GOOGLESHEETS_LIST_TABLES',
  'GOOGLESHEETS_LOOKUP_SPREADSHEET_ROW',
  'GOOGLESHEETS_QUERY_TABLE',
  'GOOGLESHEETS_SEARCH_SPREADSHEETS',
  'GOOGLESHEETS_SHEET_FROM_JSON'
]
a
this should not take 23s, I'd recommand checking the implemention on your end. Here's a snippet I tested on my end and it takes <6s & with
check_connected_accounts=False
it takes even lesser. I've attached the code snippet & a screen recording for you ref. We don't recommend getting a lot of tools & passing it to agents as it'll affect its accuracy in tool selection. If you're use case is non-agentic I would recommend using the APIs instead. Also we've deprecated the old SDK and would suggest migrating to new one. [Migration guide](https://docs.composio.dev/docs/migration) https://cdn.discordapp.com/attachments/1415706702694584444/1415966807126183936/Screen_Recording_2025-09-12_at_1.09.16_PM.mov?ex=68c5215a&is=68c3cfda&hm=44419b43216d330325541baae0b805a081d6c3b2a731fce963b8cbc3686030ec& https://cdn.discordapp.com/attachments/1415706702694584444/1415966807742873620/old_sdk.py?ex=68c5215a&is=68c3cfda&hm=eed2ba485f293c446e95d44584c1ef89988a8a29be4d9048b2b13af01c51c457&
b
We use agentic tool selection and we also pass the connected_account_ids to the ComposioToolSet. @abhishekpatil4
If we don't set the connected_account_id the requests are being sent to the first connection of the entityId and it is not ideal. Can you cofirm the same with parameters like apikey,entity id and connected_account_id here is the code snippet of our implementation
Copy code
try:
        composio_toolset = ComposioToolSet(
            entity_id=bot_config.account_id,
            api_key=app_settings.composio_api_key,
            connected_account_ids=connected_account_ids,
        )
    except Exception as e:
        logger.error(f"Error initializing Composio Toolset: {e}")
        return []

    logger.info(f"Composio Toolset: {composio_toolset}")
    actions = [getattr(Action, action_str) for action_str in actions_str]
    processor_loader = ProcessorLoader()
    post_processors = processor_loader.discover_post_processors(actions_str)

    logger.info(f"Discovered post-processors: {list(post_processors.keys())}")

    # Build processors dictionary for Composio
    processors_config = {}
    if post_processors:
        processors_config["post"] = post_processors
        logger.info(
            f"Applying post-processors to {len(post_processors)} tools"
        )

    all_enabled_composio_tools = composio_toolset.get_tools(
        actions=actions,
        processors=processors_config if processors_config else None,
    )
    logger.info(f"all_enabled_composio_tools: {all_enabled_composio_tools}")
the time difference between
Copy code
logger.info(f"Discovered post-processors: {list(post_processors.keys())}")
and 
logger.info(f"all_enabled_composio_tools: {all_enabled_composio_tools}")
is significantly increasing with number of actions.
a
If same userId is used for more than one connection, then the most recent connection would be used.
b
Yeah, but we have same entity id which has many accounts connected to it, in that case I would need to have proper tool mapping with tool to connected_account_id. But the issue if not about that, it is the concern about the latency, please confirm this based on out above implementation. Thanks @abhishekpatil4
i
@abhishekpatil4 will it always take 6s or it is dependent on the array of actions we're passing? Also is it acceptable to have 6s delay on production systems ?
We want to have our apis under ms response time and the bottleneck is composio init which takes around 2s on avg and
.get_tools
which takes, as you mentioned 6s, but in our case sometimes 23s as well. The other bottleneck is composio action cache download which takes 1min
Can you please help us here @abhishekpatil4 @udaysidagana
Also @abhishekpatil4 can you please tell me if there is any update on composio side which could be the source of increase in latency in
.get_tools
?
a
The tools are fetched by a single network call, so the time would be same but would totally depend in your internet. We’ve done a lot of improvements on the new SDK and have improved the latency.
It should not take 23s. Can you try to reproduce the issue? please enable network logs (
COMPOSIO_LOGGING_LEVEL=debug
) and you’ll see all the network calls made.. and we can troubleshoot the issue further.
The cache generation can be disabled.
No, but would ideally recommend using the new sdk
i
But even for you @abhishekpatil4 its taking 6s right? With that its not possible to have api reponse under 600ms or even 1s when the tool fetching itself is taking 6s or more
I'll try
COMPOSIO_LOGGING_LEVEL=debug
a
Yeah, as mentioned earlier we’ve done a lot of improvements in our new sdk + v3 API, and actively working on to bring down the latency. The old SDK uses the v1 API
a
I see, thanks for the details. I'm assuming the cache is not available in this case & its making an additional network calls. I would highly recommand migrating to the new SDK as we've officially deprecated the old one and won't be making any changes to it. also quick correction — in the new SDK the latency is ~1s and sometimes less than ~1/2s.
b
@abhishekpatil4 what is the standard way to provide the connected_account_id to the composio tools, in the older sdk we were able to have a mapping between toolkit slug and the connected_acc_id, in the latest version what is the best approach ?
a
You can use before execute to pass the connectedAccId. Here's the guide: https://docs.composio.dev/docs/modifiers/before-execution snippet for ref:
Copy code
@before_execute(tools=["GMAIL_SEND_EMAIL"])
def before_execute_modifier(
    tool: str,
    toolkit: str,
    params: ToolExecuteParams,
) -> ToolExecuteParams:
    params["connected_account_id"] = f"{{connected_account_id}}"
    return params
l
Do you need developer?