The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: bind the delegated child to the entry actually leased, not the pool's shared cursor
teknium1c38f7f6d4cea
diff --git a/tests/tools/test_delegate.py b/tests/tools/test_delegate.pyindex ec9cee514dc..12c747bb2ab 100644--- a/tests/tools/test_delegate.py+++ b/tests/tools/test_delegate.py@@ -1343,7 +1343,7 @@ class TestChildCredentialLeasing(unittest.TestCase):child = MagicMock()child._credential_pool = MagicMock()child._credential_pool.acquire_lease.return_value = "cred-b"- child._credential_pool.current.return_value = leased_entry+ child._credential_pool.entries.return_value = [leased_entry] # bound by leased id, not the shared cursorchild.run_conversation.return_value = {"final_response": "done","completed": True,diff --git a/tools/delegate_tool_child_run.py b/tools/delegate_tool_child_run.pyindex a24c0d9b3ac..5cad59da6f0 100644--- a/tools/delegate_tool_child_run.py+++ b/tools/delegate_tool_child_run.py@@ -396,12 +396,14 @@ def _lease_child_credential(child: Any) -> tuple[Any, Optional[str]]:child_pool = getattr(child, "_credential_pool", None)if child_pool is None:return None, None- from tools.delegate_tool_config import _entry_serves_endpoint+ from agent.credential_pool import credential_pool_entry_serves_endpoint as _entry_serves_endpointbase_url = getattr(child, "base_url", None)leased_cred_id = child_pool.acquire_lease()if leased_cred_id is not None:with _quiet("Failed to bind child to leased credential: %s"):- leased_entry = child_pool.current()+ # Resolve the leased entry by id: the pool is shared with the parent/siblings, so current() is a+ # mutable cursor that may already point at someone else's pick.+ leased_entry = next((e for e in child_pool.entries() if e.id == leased_cred_id), None)if not _entry_serves_endpoint(leased_entry, base_url):child_pool.release_lease(leased_cred_id)leased_entry = next(