Skip to content

Commit 571d69b

Browse files
Merge pull request #119 from scaleapi/revert-113-release-please--branches--main--changes--next
Revert "release: 0.4.17"
2 parents 20d7022 + 49a2070 commit 571d69b

File tree

7 files changed

+86
-75
lines changed

7 files changed

+86
-75
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.4.17"
2+
".": "0.4.16"
33
}

CHANGELOG.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# Changelog
22

3-
## 0.4.17 (2025-09-29)
4-
5-
Full Changelog: [v0.4.16...v0.4.17](https://github.com/scaleapi/agentex-python/compare/v0.4.16...v0.4.17)
6-
7-
### Chores
8-
9-
* **internal:** codegen related update ([2fdc0e7](https://github.com/scaleapi/agentex-python/commit/2fdc0e75ea3874cf896cdbb119b50a4165b2e942))
10-
* **internal:** version bump ([0a59ad4](https://github.com/scaleapi/agentex-python/commit/0a59ad40b55b3577ef2addcea2fe4c0e4f002d49))
11-
* **internal:** version bump ([6174ef1](https://github.com/scaleapi/agentex-python/commit/6174ef1573a539f5e0f57bc625a67da31311afb6))
12-
133
## 0.4.16 (2025-09-16)
144

155
Full Changelog: [v0.4.15...v0.4.16](https://github.com/scaleapi/agentex-python/compare/v0.4.15...v0.4.16)

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "agentex-sdk"
3-
version = "0.4.17"
3+
version = "0.4.16"
44
description = "The official Python library for the agentex API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -86,6 +86,7 @@ dev-dependencies = [
8686
"dirty-equals>=0.6.0",
8787
"importlib-metadata>=6.7.0",
8888
"rich>=13.7.1",
89+
"nest_asyncio==1.6.0",
8990
"pytest-xdist>=3.6.1",
9091
"debugpy>=1.8.15",
9192
]

src/agentex/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "agentex"
4-
__version__ = "0.4.17" # x-release-please-version
4+
__version__ = "0.4.16" # x-release-please-version

src/agentex/lib/core/services/adk/providers/openai.py

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ async def run_agent_auto_send(
358358
},
359359
) as span:
360360
heartbeat_if_in_workflow("run agent auto send")
361+
361362
async with mcp_server_context(mcp_server_params, mcp_timeout_seconds) as servers:
362363
tools = [tool.to_oai_function_tool() for tool in tools] if tools else []
363364
handoffs = [Agent(**handoff.model_dump()) for handoff in handoffs] if handoffs else []
@@ -395,9 +396,12 @@ async def run_agent_auto_send(
395396
result = await Runner.run(
396397
starting_agent=agent, input=input_list, previous_response_id=previous_response_id
397398
)
398-
item.raw_item.model_dump()
399-
if isinstance(item.raw_item, BaseModel)
400-
else item.raw_item
399+
else:
400+
result = await Runner.run(starting_agent=agent, input=input_list)
401+
402+
if span:
403+
span.output = {
404+
"new_items": [
401405
item.raw_item.model_dump() if isinstance(item.raw_item, BaseModel) else item.raw_item
402406
for item in result.new_items
403407
],
@@ -427,6 +431,7 @@ async def run_agent_auto_send(
427431

428432
elif item.type == "tool_call_item":
429433
tool_call_item = item.raw_item
434+
430435
# Extract tool call information using the helper method
431436
call_id, tool_name, tool_arguments = self._extract_tool_call_info(tool_call_item)
432437
tool_call_map[call_id] = tool_call_item
@@ -552,15 +557,9 @@ async def run_agent_streamed(
552557
) as span:
553558
heartbeat_if_in_workflow("run agent streamed")
554559

555-
async with mcp_server_context(
556-
mcp_server_params, mcp_timeout_seconds
557-
) as servers:
560+
async with mcp_server_context(mcp_server_params, mcp_timeout_seconds) as servers:
558561
tools = [tool.to_oai_function_tool() for tool in tools] if tools else []
559-
handoffs = (
560-
[Agent(**handoff.model_dump()) for handoff in handoffs]
561-
if handoffs
562-
else []
563-
)
562+
handoffs = [Agent(**handoff.model_dump()) for handoff in handoffs] if handoffs else []
564563
agent_kwargs = {
565564
"name": agent_name,
566565
"instructions": agent_instructions,
@@ -573,9 +572,7 @@ async def run_agent_streamed(
573572
"tool_use_behavior": tool_use_behavior,
574573
}
575574
if model_settings is not None:
576-
agent_kwargs["model_settings"] = (
577-
model_settings.to_oai_model_settings()
578-
)
575+
agent_kwargs["model_settings"] = model_settings.to_oai_model_settings()
579576
if input_guardrails is not None:
580577
agent_kwargs["input_guardrails"] = input_guardrails
581578
if output_guardrails is not None:
@@ -603,9 +600,7 @@ async def run_agent_streamed(
603600
if span:
604601
span.output = {
605602
"new_items": [
606-
item.raw_item.model_dump()
607-
if isinstance(item.raw_item, BaseModel)
608-
else item.raw_item
603+
item.raw_item.model_dump() if isinstance(item.raw_item, BaseModel) else item.raw_item
609604
for item in result.new_items
610605
],
611606
"final_output": result.final_output,
@@ -738,6 +733,7 @@ async def run_agent_streamed_auto_send(
738733
if event.type == "run_item_stream_event":
739734
if event.item.type == "tool_call_item":
740735
tool_call_item = event.item.raw_item
736+
741737
# Extract tool call information using the helper method
742738
call_id, tool_name, tool_arguments = self._extract_tool_call_info(tool_call_item)
743739
tool_call_map[call_id] = tool_call_item
@@ -750,12 +746,10 @@ async def run_agent_streamed_auto_send(
750746
)
751747

752748
# Create tool request using streaming context (immediate completion)
753-
async with (
754-
self.streaming_service.streaming_task_message_context(
755-
task_id=task_id,
756-
initial_content=tool_request_content,
757-
) as streaming_context
758-
):
749+
async with self.streaming_service.streaming_task_message_context(
750+
task_id=task_id,
751+
initial_content=tool_request_content,
752+
) as streaming_context:
759753
# The message has already been persisted, but we still need to send an upda
760754
await streaming_context.stream_update(
761755
update=StreamTaskMessageFull(
@@ -781,12 +775,9 @@ async def run_agent_streamed_auto_send(
781775
)
782776

783777
# Create tool response using streaming context (immediate completion)
784-
async with (
785-
self.streaming_service.streaming_task_message_context(
786-
task_id=task_id,
787-
initial_content=tool_response_content
788-
) as streaming_context
789-
):
778+
async with self.streaming_service.streaming_task_message_context(
779+
task_id=task_id, initial_content=tool_response_content
780+
) as streaming_context:
790781
# The message has already been persisted, but we still need to send an update
791782
await streaming_context.stream_update(
792783
update=StreamTaskMessageFull(
@@ -812,14 +803,10 @@ async def run_agent_streamed_auto_send(
812803
),
813804
)
814805
# Open the streaming context
815-
item_id_to_streaming_context[
816-
item_id
817-
] = await streaming_context.open()
806+
item_id_to_streaming_context[item_id] = await streaming_context.open()
818807
unclosed_item_ids.add(item_id)
819808
else:
820-
streaming_context = item_id_to_streaming_context[
821-
item_id
822-
]
809+
streaming_context = item_id_to_streaming_context[item_id]
823810

824811
# Stream the delta through the streaming service
825812
await streaming_context.stream_update(
@@ -849,14 +836,10 @@ async def run_agent_streamed_auto_send(
849836
),
850837
)
851838
# Open the streaming context
852-
item_id_to_streaming_context[
853-
item_id
854-
] = await streaming_context.open()
839+
item_id_to_streaming_context[item_id] = await streaming_context.open()
855840
unclosed_item_ids.add(item_id)
856841
else:
857-
streaming_context = item_id_to_streaming_context[
858-
item_id
859-
]
842+
streaming_context = item_id_to_streaming_context[item_id]
860843

861844
# Stream the summary delta through the streaming service
862845
await streaming_context.stream_update(
@@ -890,14 +873,10 @@ async def run_agent_streamed_auto_send(
890873
),
891874
)
892875
# Open the streaming context
893-
item_id_to_streaming_context[
894-
item_id
895-
] = await streaming_context.open()
876+
item_id_to_streaming_context[item_id] = await streaming_context.open()
896877
unclosed_item_ids.add(item_id)
897878
else:
898-
streaming_context = item_id_to_streaming_context[
899-
item_id
900-
]
879+
streaming_context = item_id_to_streaming_context[item_id]
901880

902881
# Stream the content delta through the streaming service
903882
await streaming_context.stream_update(
@@ -925,6 +904,7 @@ async def run_agent_streamed_auto_send(
925904
# to close the streaming context, but they do!!!
926905
# They output both a ResponseReasoningSummaryTextDoneEvent and a ResponseReasoningSummaryPartDoneEvent
927906
# I have no idea why they do this.
907+
928908
elif isinstance(event.data, ResponseReasoningTextDoneEvent):
929909
# Handle reasoning content text completion
930910
item_id = event.data.item_id
@@ -940,9 +920,7 @@ async def run_agent_streamed_auto_send(
940920

941921
# Finish the streaming context (sends DONE event and updates message)
942922
if item_id in item_id_to_streaming_context:
943-
streaming_context = item_id_to_streaming_context[
944-
item_id
945-
]
923+
streaming_context = item_id_to_streaming_context[item_id]
946924
await streaming_context.close()
947925
if item_id in unclosed_item_ids:
948926
unclosed_item_ids.remove(item_id)
@@ -952,17 +930,17 @@ async def run_agent_streamed_auto_send(
952930
# Create a copy to avoid modifying set during iteration
953931
remaining_items = list(unclosed_item_ids)
954932
for item_id in remaining_items:
955-
if (item_id in unclosed_item_ids and
956-
item_id in item_id_to_streaming_context): # Check if still unclosed
957-
streaming_context = item_id_to_streaming_context[
958-
item_id
959-
]
933+
if (
934+
item_id in unclosed_item_ids and item_id in item_id_to_streaming_context
935+
): # Check if still unclosed
936+
streaming_context = item_id_to_streaming_context[item_id]
960937
await streaming_context.close()
961938
unclosed_item_ids.discard(item_id)
962939

963940
except InputGuardrailTripwireTriggered as e:
964941
# Handle guardrail trigger by sending a rejection message
965942
rejection_message = "I'm sorry, but I cannot process this request due to a guardrail. Please try a different question."
943+
966944
# Try to extract rejection message from the guardrail result
967945
if hasattr(e, "guardrail_result") and hasattr(e.guardrail_result, "output"):
968946
output_info = getattr(e.guardrail_result.output, "output_info", {})
@@ -993,6 +971,7 @@ async def run_agent_streamed_auto_send(
993971
type="full",
994972
),
995973
)
974+
996975
# Re-raise to let the activity handle it
997976
raise
998977

@@ -1030,6 +1009,7 @@ async def run_agent_streamed_auto_send(
10301009
type="full",
10311010
),
10321011
)
1012+
10331013
# Re-raise to let the activity handle it
10341014
raise
10351015

src/agentex/lib/sdk/fastacp/fastacp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
logger = make_logger(__name__)
2525

26-
2726
class FastACP:
2827
"""Factory for creating FastACP instances
2928

tests/test_client.py

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import os
77
import sys
88
import json
9+
import time
910
import asyncio
1011
import inspect
12+
import subprocess
1113
import tracemalloc
1214
from typing import Any, Union, cast
15+
from textwrap import dedent
1316
from unittest import mock
1417
from typing_extensions import Literal
1518

@@ -20,17 +23,14 @@
2023

2124
from agentex import Agentex, AsyncAgentex, APIResponseValidationError
2225
from agentex._types import Omit
23-
from agentex._utils import asyncify
2426
from agentex._models import BaseModel, FinalRequestOptions
2527
from agentex._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
2628
from agentex._base_client import (
2729
DEFAULT_TIMEOUT,
2830
HTTPX_DEFAULT_TIMEOUT,
2931
BaseClient,
30-
OtherPlatform,
3132
DefaultHttpxClient,
3233
DefaultAsyncHttpxClient,
33-
get_platform,
3434
make_request_options,
3535
)
3636

@@ -1643,9 +1643,50 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16431643

16441644
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
16451645

1646-
async def test_get_platform(self) -> None:
1647-
platform = await asyncify(get_platform)()
1648-
assert isinstance(platform, (str, OtherPlatform))
1646+
def test_get_platform(self) -> None:
1647+
# A previous implementation of asyncify could leave threads unterminated when
1648+
# used with nest_asyncio.
1649+
#
1650+
# Since nest_asyncio.apply() is global and cannot be un-applied, this
1651+
# test is run in a separate process to avoid affecting other tests.
1652+
test_code = dedent("""
1653+
import asyncio
1654+
import nest_asyncio
1655+
import threading
1656+
1657+
from agentex._utils import asyncify
1658+
from agentex._base_client import get_platform
1659+
1660+
async def test_main() -> None:
1661+
result = await asyncify(get_platform)()
1662+
print(result)
1663+
for thread in threading.enumerate():
1664+
print(thread.name)
1665+
1666+
nest_asyncio.apply()
1667+
asyncio.run(test_main())
1668+
""")
1669+
with subprocess.Popen(
1670+
[sys.executable, "-c", test_code],
1671+
text=True,
1672+
) as process:
1673+
timeout = 10 # seconds
1674+
1675+
start_time = time.monotonic()
1676+
while True:
1677+
return_code = process.poll()
1678+
if return_code is not None:
1679+
if return_code != 0:
1680+
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1681+
1682+
# success
1683+
break
1684+
1685+
if time.monotonic() - start_time > timeout:
1686+
process.kill()
1687+
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1688+
1689+
time.sleep(0.1)
16491690

16501691
async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None:
16511692
# Test that the proxy environment variables are set correctly

0 commit comments

Comments
 (0)