Skip to content
Open
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
8 changes: 4 additions & 4 deletions agentex/src/api/routes/checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

from fastapi import APIRouter, Response

from src.api.schemas.authorization_types import (
AgentexResourceType,
AuthorizedOperationType,
)
from src.api.schemas.checkpoints import (
BlobResponse,
CheckpointListItem,
Expand All @@ -14,10 +18,6 @@
PutWritesRequest,
WriteResponse,
)
from src.api.schemas.authorization_types import (
AgentexResourceType,
AuthorizedOperationType,
)
from src.domain.use_cases.checkpoints_use_case import DCheckpointsUseCase
from src.utils.authorization_shortcuts import DAuthorizedBodyId
from src.utils.logging import make_logger
Expand Down
4 changes: 1 addition & 3 deletions agentex/src/domain/repositories/checkpoint_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ async def list_checkpoints(
self.async_ro_session_maker() as session,
async_sql_exception_handler(),
):
query = select(CheckpointORM).where(
CheckpointORM.thread_id == thread_id
)
query = select(CheckpointORM).where(CheckpointORM.thread_id == thread_id)

if checkpoint_ns is not None:
query = query.where(CheckpointORM.checkpoint_ns == checkpoint_ns)
Expand Down
6 changes: 5 additions & 1 deletion agentex/src/domain/services/agent_acp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,11 @@ async def get_headers(
# message, streaming and cancel (which call get_headers(agent) with no
# request_headers) would drop traceparent and the downstream agent would
# start a detached trace. The inbound headers are on self._request.
inbound_headers = dict(self._request.headers) if getattr(self, "_request", None) is not None else {}
inbound_headers = (
dict(self._request.headers)
if getattr(self, "_request", None) is not None
else {}
)
trace_context_headers = extract_trace_context_headers(inbound_headers)
delegation_headers = self.get_delegation_headers(agent)
auth_headers = await self.get_agent_auth_headers(agent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ async def test_retrieve_agentic_agent_preserves_type(self, isolated_client):
get_response = await isolated_client.get(f"/agents/{agent_id}")
assert get_response.status_code == 200
agent_data = get_response.json()
assert (
agent_data["acp_type"] == "agentic"
), "API should return 'agentic' for legacy agents, not convert to 'async'"
assert agent_data["acp_type"] == "agentic", (
"API should return 'agentic' for legacy agents, not convert to 'async'"
)

# Retrieve by name
get_by_name_response = await isolated_client.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,12 @@ async def test_null_blob_stored_correctly(self, isolated_repositories):
repo = isolated_repositories["checkpoint_repository"]

blobs = [
{"channel": "empty_channel", "version": "v1", "type": "empty", "blob": None},
{
"channel": "empty_channel",
"version": "v1",
"type": "empty",
"blob": None,
},
]
checkpoint = {
"id": "cp-1",
Expand Down
6 changes: 3 additions & 3 deletions agentex/tests/integration/api/health/test_health_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ async def test_health_endpoint_variations(self, isolated_client):

for endpoint in health_endpoints:
response = await isolated_client.get(endpoint)
assert (
response.status_code == 200
), f"Health endpoint {endpoint} should return 200"
assert response.status_code == 200, (
f"Health endpoint {endpoint} should return 200"
)

@pytest.mark.asyncio
async def test_health_endpoint_http_methods(self, isolated_client):
Expand Down
6 changes: 3 additions & 3 deletions agentex/tests/integration/test_redis_stream_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ async def test_send_data_sets_ttl_on_stream_key(self, isolated_repositories):
# while still catching a regression where EXPIRE isn't called.
assert ttl > 0, f"Expected positive TTL, got {ttl}"
assert ttl <= 3600, f"Expected TTL <= 3600, got {ttl}"
assert (
ttl >= 3480
), f"Expected TTL >= 3480 (within 120s of configured), got {ttl}"
assert ttl >= 3480, (
f"Expected TTL >= 3480 (within 120s of configured), got {ttl}"
)

# Cleanup
await repo.redis.delete(topic)
Expand Down
2 changes: 1 addition & 1 deletion agentex/tests/integration/test_task_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ async def test_event_xadded_after_connected_is_delivered(
for _ in range(10):
try:
evt = await asyncio.wait_for(gen.__anext__(), timeout=4)
except (TimeoutError, asyncio.TimeoutError):
except TimeoutError:
break # stream went silent — sentinel was dropped
if evt.startswith("data: ") and sentinel in evt:
received = True
Expand Down
1 change: 1 addition & 0 deletions agentex/tests/unit/api/test_states_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from src.api.schemas.states import UpdateStateRequest


@pytest.mark.unit
def test_update_state_request_ignores_legacy_parent_identifiers():
request = UpdateStateRequest.model_validate(
Expand Down
9 changes: 7 additions & 2 deletions agentex/tests/unit/api/test_webhook_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ async def test_forward_path_reserved_chars_are_url_encoded(self, monkeypatch):
name="o/r",
forward_path="github-pr/cfg-9?mode=review#frag ment",
)
resp, _ = await self._call(monkeypatch, req, base_env="https://sgp.example.com/")
resp, _ = await self._call(
monkeypatch, req, base_env="https://sgp.example.com/"
)

assert (
resp.webhook_path
Expand Down Expand Up @@ -154,7 +156,10 @@ async def test_slack_without_secret_rejected(self, monkeypatch):
# Slack signs with the app's existing Signing Secret — we can't generate one,
# so omitting it must 400 rather than store a random value that never matches.
req = CreateWebhookTriggerRequest(
agent_name="a", source=AgentAPIKeyType.SLACK, name="my-app", forward_path="slack"
agent_name="a",
source=AgentAPIKeyType.SLACK,
name="my-app",
forward_path="slack",
)
with pytest.raises(HTTPException) as exc:
await self._call(monkeypatch, req)
Expand Down
6 changes: 3 additions & 3 deletions agentex/tests/unit/repositories/test_agent_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ async def test_agent_repository_crud_operations(postgres_url, isolated_test_sche

# Should be empty after rollback
agent_list = await repository2.list()
assert (
len(agent_list) == 0
), f"Expected 0 agents after rollback, got {len(agent_list)}"
assert len(agent_list) == 0, (
f"Expected 0 agents after rollback, got {len(agent_list)}"
)
print("✅ TRANSACTION ROLLBACK verification successful")

finally:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ async def test_agent_task_tracker_repository_crud_operations(postgres_url):
# The task creation should have automatically created an AgentTaskTracker
# Let's find it and test our operations
all_trackers = await tracker_repo.list()
assert (
len(all_trackers) >= 1
), "Task creation should have created an AgentTaskTracker"
assert len(all_trackers) >= 1, (
"Task creation should have created an AgentTaskTracker"
)

# Find our tracker
our_tracker = None
Expand Down
6 changes: 3 additions & 3 deletions agentex/tests/unit/temporal/test_healthcheck_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ async def sleep(_):

await workflow_instance.run({"agent_id": "agent-1", "acp_url": "http://agent"})

assert status_updates == [
["agent-1", "Unhealthy"]
], "the fifth consecutive failed probe must mark the agent unhealthy"
assert status_updates == [["agent-1", "Unhealthy"]], (
"the fifth consecutive failed probe must mark the agent unhealthy"
)
assert probe_count == 5, "the workflow must wait for five failed probes"
continue_as_new.assert_not_called()
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ async def test_both_agentic_and_async_have_same_allowed_methods(self):
agentic_methods = set(ACP_TYPE_TO_ALLOWED_RPC_METHODS[ACPType.AGENTIC])
async_methods = set(ACP_TYPE_TO_ALLOWED_RPC_METHODS[ACPType.ASYNC])

assert (
agentic_methods == async_methods
), "AGENTIC and ASYNC should have identical allowed RPC methods"
assert agentic_methods == async_methods, (
"AGENTIC and ASYNC should have identical allowed RPC methods"
)

# Verify they include the expected methods
expected_methods = {
Expand Down Expand Up @@ -362,6 +362,6 @@ async def test_agentic_and_async_agents_both_use_not_sync_logic(self):
# Both AGENTIC and ASYNC should pass the same conditional checks
agentic_is_not_sync = agentic_agent.acp_type != ACPType.SYNC
async_is_not_sync = async_agent.acp_type != ACPType.SYNC
assert (
agentic_is_not_sync == async_is_not_sync
), "AGENTIC and ASYNC should have identical behavior in != SYNC checks"
assert agentic_is_not_sync == async_is_not_sync, (
"AGENTIC and ASYNC should have identical behavior in != SYNC checks"
)
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ def test_returns_none_for_empty_credentials(self):
assert extract_agent_key_from_authorization("AgentKey ") is None

def test_strips_surrounding_whitespace(self):
assert (
extract_agent_key_from_authorization(" AgentKey abc123 ") == "abc123"
)
assert extract_agent_key_from_authorization(" AgentKey abc123 ") == "abc123"


@pytest.mark.asyncio
Expand Down
18 changes: 9 additions & 9 deletions agentex/tests/unit/use_cases/test_slack_gateway_use_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,9 +1766,9 @@ async def test_the_link_is_never_broadcast(self, monkeypatch):

for method, payload in (c.args for c in api.await_args_list):
if method == "chat.postMessage":
assert (
payload["channel"] == "D_DM"
), f"the nonce was posted to {payload['channel']}, not the DM"
assert payload["channel"] == "D_DM", (
f"the nonce was posted to {payload['channel']}, not the DM"
)
# Nothing that lands in channel history mentions it.
broadcast = [
p
Expand Down Expand Up @@ -2812,9 +2812,9 @@ def test_duplicate_names_resolve_the_same_way_for_every_worker():
other = {"id": "x", "name": "something-else", "created_at": "2020-01-01T00:00:00"}

for order in ([older, newer, other], [newer, other, older], [other, newer, older]):
assert (
sg._canonical_named(order, "slack-agentex-bot") == "b-older"
), "list order must not change the answer"
assert sg._canonical_named(order, "slack-agentex-bot") == "b-older", (
"list order must not change the answer"
)
assert sg._canonical_named([older, newer], "absent") is None


Expand Down Expand Up @@ -3047,9 +3047,9 @@ async def test_cooldown_is_released_when_nothing_could_be_delivered(monkeypatch)

await uc._notify_config_forbidden(_inbound(team_id="T", user="U1"))

assert deleted == [
"slack:config_forbidden:T:U1"
], "nothing was delivered, so the next turn must be allowed to retry"
assert deleted == ["slack:config_forbidden:T:U1"], (
"nothing was delivered, so the next turn must be allowed to retry"
)


@pytest.mark.asyncio
Expand Down
Loading