Skip to content

Commit 0fc95c2

Browse files
lindazqlifoundry-samples-sync[bot]
authored andcommitted
Fix langgraph toolbox cold-start latency: check real loaded tools, not CompiledStateGraph.tools (#619)
1 parent 85106cd commit 0fc95c2

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

  • .github/scripts
  • samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity

.github/scripts/mirror-back.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ is_sync_bot_identity() {
9393

9494
should_skip_commit() {
9595
local sha="$1"
96-
local author_name author_email committer_name committer_email
96+
local author_name author_email
9797
author_name=$(git -C "$PUBLIC_REPO_PATH" show -s --format='%an' "$sha")
9898
author_email=$(git -C "$PUBLIC_REPO_PATH" show -s --format='%ae' "$sha")
99-
committer_name=$(git -C "$PUBLIC_REPO_PATH" show -s --format='%cn' "$sha")
100-
committer_email=$(git -C "$PUBLIC_REPO_PATH" show -s --format='%ce' "$sha")
10199

102-
for value in "$author_name" "$author_email" "$committer_name" "$committer_email"; do
100+
# Skip only when the AUTHOR is a sync-bot identity. The sync pipeline sets both
101+
# author and committer to the bot identity. Human PRs merged via "direct rebase
102+
# merge as the App" have a human author but a sync-bot committer — those must
103+
# still be mirrored back to private.
104+
for value in "$author_name" "$author_email"; do
103105
if is_sync_bot_identity "$value"; then
104106
return 0
105107
fi

samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity/main.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def quickstart():
200200
schema["properties"] = props
201201

202202
logger.info(f"Loaded {len(tools)} tools from MCP")
203-
return create_agent(llm, tools), toolbox
203+
return create_agent(llm, tools), toolbox, tools
204204

205205

206206
def _extract_assistant_text(result: dict) -> str:
@@ -326,9 +326,8 @@ async def _get_agent():
326326
last_exc: Exception | None = None
327327
for attempt in range(1, 6):
328328
try:
329-
agent, mcp_client = await quickstart()
330-
bound_tools = getattr(agent, "tools", None) or []
331-
if not bound_tools:
329+
agent, mcp_client, tools = await quickstart()
330+
if not tools:
332331
logger.warning(
333332
"Toolbox returned 0 tools on attempt %d; retrying", attempt,
334333
)
@@ -344,7 +343,7 @@ async def _get_agent():
344343
await asyncio.sleep(min(2 ** attempt, 15))
345344
if last_exc is not None:
346345
raise last_exc
347-
_agent, _mcp_client = await quickstart()
346+
_agent, _mcp_client, _ = await quickstart()
348347
return _agent
349348

350349

0 commit comments

Comments
 (0)