Skip to content

Commit b83d69b

Browse files
committed
more lint
1 parent 4c93671 commit b83d69b

File tree

4 files changed

+87
-18
lines changed

4 files changed

+87
-18
lines changed

examples/tutorials/run_agent_test.sh

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ CONTINUE_ON_ERROR=false
3333
SINGLE_TUTORIAL=""
3434
VIEW_LOGS=false
3535
FROM_REPO_ROOT=false
36+
BUILD_CLI=false
3637

3738
for arg in "$@"; do
3839
if [[ "$arg" == "--continue-on-error" ]]; then
@@ -41,6 +42,8 @@ for arg in "$@"; do
4142
VIEW_LOGS=true
4243
elif [[ "$arg" == "--from-repo-root" ]]; then
4344
FROM_REPO_ROOT=true
45+
elif [[ "$arg" == "--build-cli" ]]; then
46+
BUILD_CLI=true
4447
else
4548
SINGLE_TUTORIAL="$arg"
4649
fi
@@ -55,15 +58,15 @@ ALL_TUTORIALS=(
5558
# base tutorials
5659
"10_async/00_base/000_hello_acp"
5760
"10_async/00_base/010_multiturn"
58-
"10_agentic/00_base/020_streaming"
59-
"10_agentic/00_base/030_tracing"
60-
"10_agentic/00_base/040_other_sdks"
61-
"10_agentic/00_base/080_batch_events"
62-
# "10_agentic/00_base/090_multi_agent_non_temporal" This will require its own version of this
61+
"10_async/00_base/020_streaming"
62+
"10_async/00_base/030_tracing"
63+
"10_async/00_base/040_other_sdks"
64+
"10_async/00_base/080_batch_events"
65+
# "10_async/00_base/090_multi_agent_non_temporal" This will require its own version of this
6366
# temporal tutorials
64-
"10_agentic/10_temporal/000_hello_acp"
65-
"10_agentic/10_temporal/010_agent_chat"
66-
"10_agentic/10_temporal/020_state_machine"
67+
"10_async/10_temporal/000_hello_acp"
68+
"10_async/10_temporal/010_agent_chat"
69+
"10_async/10_temporal/020_state_machine"
6770
)
6871

6972
PASSED=0
@@ -92,7 +95,7 @@ check_prerequisites() {
9295
wait_for_agent_ready() {
9396
local name=$1
9497
local logfile="/tmp/agentex-${name}.log"
95-
local timeout=30 # seconds
98+
local timeout=45 # seconds
9699
local elapsed=0
97100

98101
echo -e "${YELLOW}⏳ Waiting for ${name} agent to be ready...${NC}"
@@ -132,6 +135,18 @@ start_agent() {
132135
return 1
133136
fi
134137

138+
if [ "$BUILD_CLI" = true ]; then
139+
# Use wheel from dist directory at repo root
140+
local wheel_file=$(ls /home/runner/work/*/*/dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
141+
if [[ -z "$wheel_file" ]]; then
142+
echo -e "${RED}❌ No built wheel found in dist/agentex_sdk-*.whl${NC}"
143+
echo -e "${YELLOW}💡 Please build the local SDK first by running: uv build${NC}"
144+
echo -e "${YELLOW}💡 From the repo root directory${NC}"
145+
cd "$original_dir"
146+
return 1
147+
fi
148+
fi
149+
135150
# Determine how to run the agent
136151
local pid
137152
if [[ "$FROM_REPO_ROOT" == "true" ]]; then
@@ -141,14 +156,26 @@ start_agent() {
141156

142157
local original_dir="$PWD"
143158
cd "$repo_root" || return 1
144-
uv run agentex agents run --manifest "$abs_manifest" > "$logfile" 2>&1 &
159+
if [ "$BUILD_CLI" = true ]; then
160+
local wheel_file=$(ls /home/runner/work/*/*/dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
161+
# Use the built wheel
162+
uv run --with "$wheel_file" agentex agents run --manifest "$manifest_path" > "$logfile" 2>&1 &
163+
else
164+
uv run agentex agents run --manifest "$abs_manifest" > "$logfile" 2>&1 &
165+
fi
145166
pid=$!
146167
cd "$original_dir" # Return to examples/tutorials
147168
else
148169
# Traditional mode: cd into tutorial and run
149170
local original_dir="$PWD"
150171
cd "$tutorial_path" || return 1
151-
uv run agentex agents run --manifest manifest.yaml > "$logfile" 2>&1 &
172+
if [ "$BUILD_CLI" = true ]; then
173+
local wheel_file=$(ls /home/runner/work/*/*/dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
174+
# Use the built wheel
175+
uv run --with "$wheel_file" agentex agents run --manifest "$manifest_path" > "$logfile" 2>&1 &
176+
else
177+
uv run agentex agents run --manifest "$abs_manifest" > "$logfile" 2>&1 &
178+
fi
152179
pid=$!
153180
cd "$original_dir"
154181
fi
@@ -341,6 +368,38 @@ execute_tutorial_test() {
341368
fi
342369
}
343370

371+
# Function to check if built wheel is available
372+
check_built_wheel() {
373+
374+
# Navigate to the repo root (two levels up from examples/tutorials)
375+
local repo_root="../../"
376+
local original_dir="$PWD"
377+
378+
cd "$repo_root" || {
379+
echo -e "${RED}❌ Failed to navigate to repo root${NC}"
380+
return 1
381+
}
382+
383+
# Check if wheel exists in dist directory at repo root
384+
local wheel_file=$(ls /home/runner/work/*/*/dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
385+
if [[ -z "$wheel_file" ]]; then
386+
echo -e "${RED}❌ No built wheel found in dist/agentex_sdk-*.whl${NC}"
387+
echo -e "${YELLOW}💡 Please build the local SDK first by running: uv build${NC}"
388+
echo -e "${YELLOW}💡 From the repo root directory${NC}"
389+
cd "$original_dir"
390+
return 1
391+
fi
392+
393+
# Test the wheel by running agentex --help
394+
if ! uv run --with "$wheel_file" agentex --help >/dev/null 2>&1; then
395+
echo -e "${RED}❌ Failed to run agentex with built wheel${NC}"
396+
cd "$original_dir"
397+
return 1
398+
fi
399+
cd "$original_dir"
400+
return 0
401+
}
402+
344403
# Main execution function
345404
main() {
346405
# Handle --view-logs flag
@@ -367,6 +426,15 @@ main() {
367426

368427
# Check prerequisites
369428
check_prerequisites
429+
430+
# Check built wheel if requested
431+
if [ "$BUILD_CLI" = true ]; then
432+
if ! check_built_wheel; then
433+
echo -e "${RED}❌ Failed to find or verify built wheel${NC}"
434+
exit 1
435+
fi
436+
echo ""
437+
fi
370438

371439
echo ""
372440

src/agentex/lib/testing/retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def with_async_retry(func): # type: ignore[no-untyped-def]
7878
"""
7979

8080
@wraps(func)
81-
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
81+
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> object:
8282
last_exception = None
8383
delay = config.api_retry_delay
8484

src/agentex/lib/testing/sessions/sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ def send_message_streaming(self, content: str):
147147
first_chunk = next(response_generator, None)
148148
if first_chunk and hasattr(first_chunk, 'result'):
149149
result = first_chunk.result
150-
if hasattr(result, 'task_id') and result.task_id:
151-
self.task_id = result.task_id
150+
if hasattr(result, 'task_id') and getattr(result, 'task_id'):
151+
self.task_id = getattr(result, 'task_id')
152152
logger.debug(f"Task auto-created from stream: {self.task_id}")
153153
# Check if result has parent_task_message with task_id
154154
elif hasattr(result, 'parent_task_message') and result.parent_task_message:

src/agentex/lib/testing/type_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ def extract_agent_response(response, agent_id: str): # type: ignore[no-untyped-
6464

6565
# SendMessageResponse: result.content
6666
if hasattr(result, "content"):
67-
content = result.content
67+
content = getattr(result, "content")
6868
if isinstance(content, TextContent):
6969
return content
7070

7171
# SendEventResponse: result.message.content
72-
if hasattr(result, "message") and result.message:
73-
if hasattr(result.message, "content"):
74-
content = result.message.content
72+
if hasattr(result, "message") and getattr(result, "message"):
73+
message = getattr(result, "message")
74+
if hasattr(message, "content"):
75+
content = getattr(message, "content")
7576
if isinstance(content, TextContent):
7677
return content
7778

0 commit comments

Comments
 (0)