From adb0c41f05966d826a1a237c499c8bafe04d4707 Mon Sep 17 00:00:00 2001 From: congkechen Date: Tue, 7 Jul 2026 14:55:16 +0800 Subject: [PATCH 1/8] Add internal pipeline test --- pipeline_test/patch_llm_call.sh | 59 +++++++++++ pipeline_test/requirements-ecosystem.txt | 17 ++++ pipeline_test/requirements.txt | 13 +++ pipeline_test/run_agent_examples.sh | 124 +++++++++++++++++++++++ pipeline_test/run_ecosystem_examples.sh | 40 ++++++++ pipeline_test/run_evaluation_examples.sh | 14 +++ pipeline_test/run_other_examples.sh | 32 ++++++ 7 files changed, 299 insertions(+) create mode 100644 pipeline_test/patch_llm_call.sh create mode 100644 pipeline_test/requirements-ecosystem.txt create mode 100644 pipeline_test/requirements.txt create mode 100644 pipeline_test/run_agent_examples.sh create mode 100644 pipeline_test/run_ecosystem_examples.sh create mode 100644 pipeline_test/run_evaluation_examples.sh create mode 100644 pipeline_test/run_other_examples.sh diff --git a/pipeline_test/patch_llm_call.sh b/pipeline_test/patch_llm_call.sh new file mode 100644 index 00000000..8fc61fdb --- /dev/null +++ b/pipeline_test/patch_llm_call.sh @@ -0,0 +1,59 @@ +_PS_DIR="${TMPDIR:-/tmp}/trpc_agent_patch_llm_call.$$" +mkdir -p "$_PS_DIR" + +cat > "$_PS_DIR/sitecustomize.py" <<'PYEOF' +import sys + +_TAG = "[patch_llm_call]" + + +def _log(msg): + print(f"{_TAG} {msg}", file=sys.stdout, flush=True) + + +try: + from trpc_agent_sdk.models._openai_model import OpenAIModel +except Exception as e: + _log(f"patch SKIPPED: failed to import OpenAIModel ({type(e).__name__}: {e})") +else: + _orig_init = OpenAIModel.__init__ + + def _patched_init(self, *args, **kwargs): + model_name = args[0] if args else kwargs.get("model_name", "") + before = kwargs.get("enable_thinking", "") + kwargs.setdefault("enable_thinking", False) + _orig_init(self, *args, **kwargs) + _log( + f"OpenAIModel(model_name={model_name!r}) init patched " + f"(caller enable_thinking={before!r}; " + f"final kwarg={kwargs.get('enable_thinking')!r}; " + f"self.enable_thinking={getattr(self, 'enable_thinking', '')!r})" + ) + + OpenAIModel.__init__ = _patched_init + + _orig_extract = OpenAIModel._extract_http_options + + def _patched_extract(self, config): + http_opts = _orig_extract(self, config) or {} + extra_headers = http_opts.setdefault("extra_headers", {}) + extra_headers.setdefault("X-SMG-Routing-Key", "minchangwei") + extra_headers.setdefault("X-SMG-Agent-Name", "trpc-python-agent-pipeline") + extra_body = http_opts.setdefault("extra_body", {}) + chat_template_kwargs = extra_body.setdefault("chat_template_kwargs", {}) + chat_template_kwargs.setdefault("enable_thinking", False) + return http_opts + + OpenAIModel._extract_http_options = _patched_extract + + _log( + f"patch INSTALLED on {OpenAIModel.__module__}.{OpenAIModel.__qualname__} " + f"(layers: __init__ + _extract_http_options; " + f"forces extra_body.chat_template_kwargs.enable_thinking=False; " + f"injects X-SMG-Routing-Key and X-SMG-Agent-Name headers)" + ) +PYEOF + +export PYTHONPATH="$_PS_DIR${PYTHONPATH:+:$PYTHONPATH}" +unset _PS_DIR +echo "[patch_llm_call] OpenAIModel thinking mode will be disabled and SMG headers will be injected (PYTHONPATH updated)." \ No newline at end of file diff --git a/pipeline_test/requirements-ecosystem.txt b/pipeline_test/requirements-ecosystem.txt new file mode 100644 index 00000000..b748a2b1 --- /dev/null +++ b/pipeline_test/requirements-ecosystem.txt @@ -0,0 +1,17 @@ +# proxy pypi +--index-url https://mirrors.cloud.tencent.com/pypi/simple/ +# private pypi +--extra-index-url https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/ + +trpc_redis==0.2.0a0 +trpc_a2a[redis]>=0.2.7 +trpc_mcp==0.2.1a0 + +a2a-sdk<1.0.0,>=0.3.22 +claude-agent-sdk>=0.1.3,<0.1.64 +cloudpickle>=2.0.0 +ag-ui-protocol>=0.1.8 +aiofiles +mem0ai>=1.0.3 +fastapi +mempalace==3.3.4 \ No newline at end of file diff --git a/pipeline_test/requirements.txt b/pipeline_test/requirements.txt new file mode 100644 index 00000000..e1c03a7d --- /dev/null +++ b/pipeline_test/requirements.txt @@ -0,0 +1,13 @@ +# proxy pypi +--index-url https://mirrors.cloud.tencent.com/pypi/simple/ +# private pypi +--extra-index-url https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/ + +a2a-sdk<1.0.0,>=0.3.22 +claude-agent-sdk>=0.1.3,<0.1.64 +cloudpickle>=2.0.0 +ag-ui-protocol>=0.1.8 +aiofiles +mem0ai>=1.0.3 +fastapi +mempalace==3.3.4 \ No newline at end of file diff --git a/pipeline_test/run_agent_examples.sh b/pipeline_test/run_agent_examples.sh new file mode 100644 index 00000000..b3973767 --- /dev/null +++ b/pipeline_test/run_agent_examples.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +export DISABLE_TRPC_AGENT_REPORT=true + +set -e + +pip3 install -r pipeline_test/requirements.txt + +# Define example categories +LLM_AGENT_EXAMPLES=( + "examples/quickstart/" + "examples/llmagent/" + "examples/llmagent_with_cancel/" + "examples/llmagent_with_model_create_fn/" + "examples/llmagent_with_parallal_tools/" + "examples/llmagent_with_schema/" + "examples/llmagent_with_thinking/" + "examples/llmagent_with_tool_prompt/" + "examples/llmagent_with_streaming_progress_tool/" + # "examples/memory_service_with_mempalace/" + "examples/webfetch_tool/" + "examples/websearch_tool/" + "examples/code_executors/" + "examples/litellm/" + "examples/graph/" + "examples/graph_multi_turns/" + "examples/graph_with_interrupt/" + "examples/agents/human_in_the_loop/llm_agent.py" + "examples/agents/history_control/max_history_messages.py" + "examples/agents/history_control/timeline_filtering.py" + "examples/agents/history_control/branch_filtering.py" +) + +MULTI_AGENT_EXAMPLES=( + "examples/multi_agent_chain/" + "examples/multi_agent_compose/" + "examples/multi_agent_cycle/" + "examples/multi_agent_parallel/" + "examples/multi_agent_start_from_last/" + "examples/multi_agent_subagent/" +) + +TEAM_AGENT_EXAMPLES=( + "examples/team/" + "examples/team_as_sub_agent/" + "examples/team_human_in_the_loop/" + "examples/team_member_agent_langgraph/" + "examples/team_member_agent_team/" + "examples/team_member_message_filter/" + "examples/team_parallel_execution/" + "examples/team_with_cancel/" +) + +run_examples() { + local examples=("$@") + for example in "${examples[@]}"; do + echo "Running $example..." + if [[ "$example" == *.py ]]; then + python3 "$example" + else + cd "$example" + python3 run_agent.py + cd - + fi + done +} + +run_llm_agent() { + echo "=== Running LLM Agent Examples ===" + run_examples "${LLM_AGENT_EXAMPLES[@]}" +} + +run_multi_agent() { + echo "=== Running Multi Agent Examples ===" + run_examples "${MULTI_AGENT_EXAMPLES[@]}" +} + +run_team_agent() { + echo "=== Running Team Agent Examples ===" + run_examples "${TEAM_AGENT_EXAMPLES[@]}" +} + +run_all() { + run_llm_agent + run_multi_agent + run_team_agent +} + +show_usage() { + echo "Usage: $0 [llm_agent|multi_agent|team_agent]" + echo "" + echo "Parameters:" + echo " llm_agent - Run LLM agent examples (quickstart, llmagent_*, history_control, etc.)" + echo " multi_agent - Run multi agent examples (multi_agent_*)" + echo " team_agent - Run team agent examples (team_*)" + echo "" + echo "If no parameter is provided, all examples will be run." +} + +# Main logic +if [ $# -eq 0 ]; then + run_all +else + case "$1" in + llm_agent) + run_llm_agent + ;; + multi_agent) + run_multi_agent + ;; + team_agent) + run_team_agent + ;; + -h|--help) + show_usage + exit 0 + ;; + *) + echo "Error: Unknown parameter '$1'" + show_usage + exit 1 + ;; + esac +fi \ No newline at end of file diff --git a/pipeline_test/run_ecosystem_examples.sh b/pipeline_test/run_ecosystem_examples.sh new file mode 100644 index 00000000..63711b56 --- /dev/null +++ b/pipeline_test/run_ecosystem_examples.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +export DISABLE_TRPC_AGENT_REPORT=true + +set -e + +pip3 install -r pipeline_test/requirements-ecosystem.txt + +# 启动A2A服务端(后台运行) +echo "启动A2A服务端..." +python3 examples/trpc_a2a/trpc_main.py & +SERVER_PID=$! + +# 等待服务端启动 +sleep 5 + +# 运行A2A客户端测试 +echo "运行A2A客户端测试..." +python3 examples/trpc_a2a/raw_client.py +python3 examples/trpc_a2a/client.py + +# TeamAgent with Remote A2A Member +echo "运行 TeamAgent with Remote A2A Member..." +cd examples/team_member_agent_remote_a2a/ +python3 run_agent.py +cd - + +# 停止服务端 +echo "停止A2A服务端..." +kill $SERVER_PID 2>/dev/null || true + +# TeamAgent with Claude Member +echo "运行 TeamAgent with Claude Member..." +cd examples/team_member_agent_claude/ +python3 run_agent.py +cd - + +# python3 examples/ecosystem/langchain_knowledge/custom_document_loader.py +# python3 examples/ecosystem/langchain_knowledge/custom_retriever.py +# python3 examples/ecosystem/langchain_knowledge/custom_text_splitter.py \ No newline at end of file diff --git a/pipeline_test/run_evaluation_examples.sh b/pipeline_test/run_evaluation_examples.sh new file mode 100644 index 00000000..8d32b6ca --- /dev/null +++ b/pipeline_test/run_evaluation_examples.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +export DISABLE_TRPC_AGENT_REPORT=true + +set -e + +# Evaluation +cd examples/evaluation/quickstart && pytest test_quickstart.py -v -s && cd - +cd examples/evaluation/webui && pytest test_book_finder.py -v -s && cd - +cd examples/evaluation/callbacks && pytest test_callbacks.py -v -s && cd - +cd examples/evaluation/custom_runner && pytest test_custom_runner.py -v -s && cd - +cd examples/evaluation/context_messages && pytest test_context_messages.py -v -s && cd - +cd examples/evaluation/trace_mode && pytest test_trace_mode.py -v -s && cd - +cd examples/evaluation/pass_at_k && pytest test_pass_at_k.py -v -s && cd - \ No newline at end of file diff --git a/pipeline_test/run_other_examples.sh b/pipeline_test/run_other_examples.sh new file mode 100644 index 00000000..c40211fe --- /dev/null +++ b/pipeline_test/run_other_examples.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +export DISABLE_TRPC_AGENT_REPORT=true + +set -e + +# File Tools +cd examples/file_tools/ +python3 run_agent.py +cd - + +# Filter with Agent +cd examples/filter_with_agent/ +python3 run_agent.py +cd - + +# Filter with Model +cd examples/filter_with_model/ +python3 run_agent.py +cd - + +# Filter with Tool +cd examples/filter_with_tool/ +python3 run_agent.py +cd - + +# Session&Memory +python3 examples/session_state/run_agent.py +python3 examples/session_summarizer/run_agent.py + +# Tools +python3 examples/tools/mcp_tools/mcp_tools.py \ No newline at end of file From c6018e258cdf0fc9d99640e4927f9045fae84447 Mon Sep 17 00:00:00 2001 From: congkechen Date: Tue, 7 Jul 2026 16:55:11 +0800 Subject: [PATCH 2/8] fix pipeline example paths --- pipeline_test/run_agent_examples.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pipeline_test/run_agent_examples.sh b/pipeline_test/run_agent_examples.sh index b3973767..cc20c867 100644 --- a/pipeline_test/run_agent_examples.sh +++ b/pipeline_test/run_agent_examples.sh @@ -25,10 +25,14 @@ LLM_AGENT_EXAMPLES=( "examples/graph/" "examples/graph_multi_turns/" "examples/graph_with_interrupt/" - "examples/agents/human_in_the_loop/llm_agent.py" - "examples/agents/history_control/max_history_messages.py" - "examples/agents/history_control/timeline_filtering.py" - "examples/agents/history_control/branch_filtering.py" + # "examples/agents/human_in_the_loop/llm_agent.py" + # "examples/agents/history_control/max_history_messages.py" + # "examples/agents/history_control/timeline_filtering.py" + # "examples/agents/history_control/branch_filtering.py" + "examples/llmagent_with_human_in_the_loop/" + "examples/llmagent_with_max_history_messages/" + "examples/llmagent_with_timeline_filtering/" + "examples/llmagent_with_branch_filtering/" ) MULTI_AGENT_EXAMPLES=( From 9b2d5042032373c04fd38fa254ae5b468b01d1e0 Mon Sep 17 00:00:00 2001 From: congkechen Date: Tue, 7 Jul 2026 17:02:22 +0800 Subject: [PATCH 3/8] test internal pipeline trigger --- pipeline_test/internal_pipeline_test_trigger.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 pipeline_test/internal_pipeline_test_trigger.txt diff --git a/pipeline_test/internal_pipeline_test_trigger.txt b/pipeline_test/internal_pipeline_test_trigger.txt new file mode 100644 index 00000000..437e5a71 --- /dev/null +++ b/pipeline_test/internal_pipeline_test_trigger.txt @@ -0,0 +1 @@ +trigger internal pipeline test From 7f6b7b00f0235decf0fb923550d58c4d6f3f6fd3 Mon Sep 17 00:00:00 2001 From: CongkeChen Date: Tue, 7 Jul 2026 17:41:12 +0800 Subject: [PATCH 4/8] Update internal_pipeline_test_trigger.txt --- pipeline_test/internal_pipeline_test_trigger.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline_test/internal_pipeline_test_trigger.txt b/pipeline_test/internal_pipeline_test_trigger.txt index 437e5a71..8b137891 100644 --- a/pipeline_test/internal_pipeline_test_trigger.txt +++ b/pipeline_test/internal_pipeline_test_trigger.txt @@ -1 +1 @@ -trigger internal pipeline test + From 0521faaa54e93576d73cd8fe3e23f32b0ce85eb8 Mon Sep 17 00:00:00 2001 From: congkechen Date: Wed, 8 Jul 2026 10:59:22 +0800 Subject: [PATCH 5/8] fix internal pipeline example scripts --- .../internal_pipeline_test_trigger.txt | 1 - pipeline_test/run_ecosystem_examples.sh | 19 ++++++++++--------- pipeline_test/run_other_examples.sh | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) delete mode 100644 pipeline_test/internal_pipeline_test_trigger.txt diff --git a/pipeline_test/internal_pipeline_test_trigger.txt b/pipeline_test/internal_pipeline_test_trigger.txt deleted file mode 100644 index 8b137891..00000000 --- a/pipeline_test/internal_pipeline_test_trigger.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pipeline_test/run_ecosystem_examples.sh b/pipeline_test/run_ecosystem_examples.sh index 63711b56..8636ee3b 100644 --- a/pipeline_test/run_ecosystem_examples.sh +++ b/pipeline_test/run_ecosystem_examples.sh @@ -8,7 +8,7 @@ pip3 install -r pipeline_test/requirements-ecosystem.txt # 启动A2A服务端(后台运行) echo "启动A2A服务端..." -python3 examples/trpc_a2a/trpc_main.py & +python3 examples/a2a/trpc_main.py & SERVER_PID=$! # 等待服务端启动 @@ -16,14 +16,15 @@ sleep 5 # 运行A2A客户端测试 echo "运行A2A客户端测试..." -python3 examples/trpc_a2a/raw_client.py -python3 examples/trpc_a2a/client.py - -# TeamAgent with Remote A2A Member -echo "运行 TeamAgent with Remote A2A Member..." -cd examples/team_member_agent_remote_a2a/ -python3 run_agent.py -cd - +python3 examples/a2a/test_a2a.py +# python3 examples/a2a/raw_client.py +# python3 examples/a2a/client.py + +# # TeamAgent with Remote A2A Member +# echo "运行 TeamAgent with Remote A2A Member..." +# cd examples/team_member_agent_remote_a2a/ +# python3 run_agent.py +# cd - # 停止服务端 echo "停止A2A服务端..." diff --git a/pipeline_test/run_other_examples.sh b/pipeline_test/run_other_examples.sh index c40211fe..90ffab22 100644 --- a/pipeline_test/run_other_examples.sh +++ b/pipeline_test/run_other_examples.sh @@ -29,4 +29,5 @@ python3 examples/session_state/run_agent.py python3 examples/session_summarizer/run_agent.py # Tools -python3 examples/tools/mcp_tools/mcp_tools.py \ No newline at end of file +# python3 examples/tools/mcp_tools/mcp_tools.py +python3 examples/mcp_tools/run_agent.py \ No newline at end of file From 671c6b9f53124f1fdbf1f578f9c4966bc0c0c28e Mon Sep 17 00:00:00 2001 From: congkechen Date: Thu, 9 Jul 2026 16:07:12 +0800 Subject: [PATCH 6/8] fix langgraph example model config and mem0 import --- examples/langgraph_agent/agent/agent.py | 3 ++- examples/langgraph_agent_with_cancel/agent/agent.py | 3 ++- examples/langgraphagent_with_human_in_the_loop/agent/agent.py | 3 ++- examples/mem0_tools/agent/agent.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/langgraph_agent/agent/agent.py b/examples/langgraph_agent/agent/agent.py index dfe7e128..cb7c34ec 100644 --- a/examples/langgraph_agent/agent/agent.py +++ b/examples/langgraph_agent/agent/agent.py @@ -39,8 +39,9 @@ def build_calculator_subgraph(): api_key, url, model_name = get_model_config() model = init_chat_model( model_name, + model_provider="openai", api_key=api_key, - api_base=url, + base_url=url, ) tools = [calculate] diff --git a/examples/langgraph_agent_with_cancel/agent/agent.py b/examples/langgraph_agent_with_cancel/agent/agent.py index 5ec88381..99a57136 100644 --- a/examples/langgraph_agent_with_cancel/agent/agent.py +++ b/examples/langgraph_agent_with_cancel/agent/agent.py @@ -44,8 +44,9 @@ def build_graph(): api_key, url, model_name = get_model_config() model = init_chat_model( model_name, + model_provider="openai", api_key=api_key, - api_base=url, + base_url=url, ) tools = [calculate, analyze_data] diff --git a/examples/langgraphagent_with_human_in_the_loop/agent/agent.py b/examples/langgraphagent_with_human_in_the_loop/agent/agent.py index baf750aa..5a3f7fe1 100644 --- a/examples/langgraphagent_with_human_in_the_loop/agent/agent.py +++ b/examples/langgraphagent_with_human_in_the_loop/agent/agent.py @@ -53,8 +53,9 @@ def _build_graph(): api_key, url, model_name = get_model_config() model = init_chat_model( model_name, + model_provider="openai", api_key=api_key, - api_base=url, + base_url=url, ) tools = [execute_database_operation] llm_with_tools = model.bind_tools(tools) diff --git a/examples/mem0_tools/agent/agent.py b/examples/mem0_tools/agent/agent.py index af69d341..3457f447 100644 --- a/examples/mem0_tools/agent/agent.py +++ b/examples/mem0_tools/agent/agent.py @@ -10,8 +10,8 @@ from trpc_agent_sdk.agents import LlmAgent from trpc_agent_sdk.models import LLMModel from trpc_agent_sdk.models import OpenAIModel -from trpc_agent_sdk.tools.mem0_tools import SaveMemoryTool -from trpc_agent_sdk.tools.mem0_tools import SearchMemoryTool +from trpc_agent_sdk.tools.mem0_tool import SaveMemoryTool +from trpc_agent_sdk.tools.mem0_tool import SearchMemoryTool from .config import get_mem0_platform_config from .config import get_memory_config From 708ea07a7b600333dc02f6368bf67dba3c6f627c Mon Sep 17 00:00:00 2001 From: congkechen Date: Fri, 10 Jul 2026 10:19:03 +0800 Subject: [PATCH 7/8] fix example pipeline execution --- examples/langgraph_agent/agent/agent.py | 6 +- pipeline_test/run_all_examples.sh | 393 ++++++++++++++++++++++++ 2 files changed, 397 insertions(+), 2 deletions(-) create mode 100755 pipeline_test/run_all_examples.sh diff --git a/examples/langgraph_agent/agent/agent.py b/examples/langgraph_agent/agent/agent.py index cb7c34ec..31abe342 100644 --- a/examples/langgraph_agent/agent/agent.py +++ b/examples/langgraph_agent/agent/agent.py @@ -80,8 +80,9 @@ def build_graph_with_subgraph(): api_key, url, model_name = get_model_config() model = init_chat_model( model_name, + model_provider="openai", api_key=api_key, - api_base=url, + base_url=url, ) # Build calculator subgraph @@ -127,8 +128,9 @@ def build_graph(): api_key, url, model_name = get_model_config() model = init_chat_model( model_name, + model_provider="openai", api_key=api_key, - api_base=url, + base_url=url, ) tools = [calculate] diff --git a/pipeline_test/run_all_examples.sh b/pipeline_test/run_all_examples.sh new file mode 100755 index 00000000..5c7a597d --- /dev/null +++ b/pipeline_test/run_all_examples.sh @@ -0,0 +1,393 @@ +#!/bin/bash + +export DISABLE_TRPC_AGENT_REPORT=true + +set -u +set -o pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +RUN_MODE="all" +FAIL_FAST=false +INCLUDE_MANUAL=false +EXAMPLE_TIMEOUT_SECONDS="${EXAMPLE_TIMEOUT_SECONDS:-300}" + +PASSED=() +FAILED=() +SKIPPED=() +RUN_AGENT_EXAMPLES=() +EVALUATION_TESTS=() + +TOTAL_TASKS=0 +CURRENT_TASK=0 + +SKIPPED_EXAMPLES=( + "examples/claude_agent_with_travel_planner/run_agent.py" + "examples/dsl/classifier_mcp/run_agent.py" + "examples/evaluation/llm_final_response/test_llm_final_response.py" + "examples/evaluation/llm_judge_tools/test_llm_judge_tools.py" + "examples/evaluation/llm_rubric_knowledge_recall/test_llm_rubric_knowledge_recall.py" + "examples/evaluation/llm_rubric_response/test_llm_rubric_response.py" + "examples/evaluation/pass_at_k/test_pass_at_k.py" + "examples/evaluation/webui/test_book_finder.py" + "examples/knowledge_with_vectorstore/run_agent.py" + "examples/mem0_tools/run_agent.py" + "examples/memory_service_with_mem0/run_agent.py" + "examples/memory_service_with_mempalace/run_agent.py" + "examples/memory_service_with_redis/run_agent.py" + "examples/memory_service_with_sql/run_agent.py" + "examples/mempalace_tools/run_agent.py" + "examples/session_service_with_redis/run_agent.py" + "examples/session_service_with_sql/run_agent.py" + "examples/skills_hub/run_agent.py" + "examples/skills_with_cube/run_agent.py" +) + +show_usage() { + cat < 0)); then + percent=$((current * 100 / total)) + fi + + echo + printf '[%d/%d] %3d%% %s\n' "$current" "$total" "$percent" "$name" +} + +skip_example() { + local name="$1" + local reason="$2" + + CURRENT_TASK=$((CURRENT_TASK + 1)) + show_progress "$CURRENT_TASK" "$TOTAL_TASKS" "Skipping: ${name}" + echo "Skipping ${name}: ${reason}" + record_result skip "$name" +} + +should_skip() { + local name="$1" + shift + + if [[ "$INCLUDE_MANUAL" != true ]] && is_in_list "$name" "${SKIPPED_EXAMPLES[@]}"; then + SKIP_REASON="skipped by default" + return 0 + fi + + if (($# > 0)) && is_in_list "$name" "$@"; then + SKIP_REASON="listed in EXTRA_SKIP_EXAMPLES" + return 0 + fi + + return 1 +} + +run_command() { + local name="$1" + shift + local exit_code + + CURRENT_TASK=$((CURRENT_TASK + 1)) + show_progress "$CURRENT_TASK" "$TOTAL_TASKS" "Running: ${name}" + echo "============================================================" + echo "Running: ${name}" + echo "============================================================" + + "$@" + exit_code=$? + + if [[ "$exit_code" -eq 0 ]]; then + record_result pass "$name" + return 0 + else + echo "FAILED: ${name} (exit code: ${exit_code})" + record_result fail "$name" + + if [[ "$FAIL_FAST" == true ]]; then + print_summary + exit "$exit_code" + fi + + return "$exit_code" + fi +} + +run_python_file_from_dir() { + local file_path="$1" + local work_dir + local file_name + + work_dir="$(dirname "$file_path")" + file_name="$(basename "$file_path")" + + ( + cd "${REPO_ROOT}/${work_dir}" + timeout "$EXAMPLE_TIMEOUT_SECONDS" python3 "$file_name" + ) +} + +run_pytest_file_from_dir() { + local file_path="$1" + local work_dir + local file_name + + work_dir="$(dirname "$file_path")" + file_name="$(basename "$file_path")" + + ( + cd "${REPO_ROOT}/${work_dir}" + timeout "$EXAMPLE_TIMEOUT_SECONDS" pytest "$file_name" -v -s + ) +} + +run_discovered_agents() { + local extra_skip=() + local example + if [[ -n "${EXTRA_SKIP_EXAMPLES:-}" ]]; then + read -r -a extra_skip <<< "${EXTRA_SKIP_EXAMPLES}" + fi + + for example in "${RUN_AGENT_EXAMPLES[@]}"; do + if should_skip "$example" "${extra_skip[@]}"; then + skip_example "$example" "$SKIP_REASON" + continue + fi + + run_command "$example" run_python_file_from_dir "$example" + done +} + +run_evaluation_tests() { + local test_file + for test_file in "${EVALUATION_TESTS[@]}"; do + if should_skip "$test_file"; then + skip_example "$test_file" "$SKIP_REASON" + continue + fi + + run_command "$test_file" run_pytest_file_from_dir "$test_file" + done +} + +wait_for_port() { + local host="$1" + local port="$2" + local timeout_seconds="$3" + + python3 - "$host" "$port" "$timeout_seconds" <<'PY' +import socket +import sys +import time + +host = sys.argv[1] +port = int(sys.argv[2]) +deadline = time.time() + int(sys.argv[3]) + +while time.time() < deadline: + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: + sock.settimeout(1) + if sock.connect_ex((host, port)) == 0: + sys.exit(0) + time.sleep(1) + +sys.exit(1) +PY +} + +run_a2a_example() { + local server_pid="" + local test_status=0 + + ( + cd "${REPO_ROOT}/examples/a2a" + exec python3 run_server.py + ) & + server_pid=$! + + cleanup_a2a() { + if [[ -n "$server_pid" ]]; then + pkill -TERM -P "$server_pid" 2>/dev/null || true + kill "$server_pid" 2>/dev/null || true + wait "$server_pid" 2>/dev/null || true + pkill -KILL -P "$server_pid" 2>/dev/null || true + kill -KILL "$server_pid" 2>/dev/null || true + fi + } + + if ! wait_for_port "127.0.0.1" "18081" "30"; then + echo "FAILED: examples/a2a server did not start on 127.0.0.1:18081" + cleanup_a2a + return 1 + fi + + ( + cd "${REPO_ROOT}/examples/a2a" + timeout "$EXAMPLE_TIMEOUT_SECONDS" python3 test_a2a.py + ) + test_status=$? + cleanup_a2a + return "$test_status" +} + +discover_run_agent_examples() { + mapfile -t RUN_AGENT_EXAMPLES < <( + cd "$REPO_ROOT" + find examples -path "*/run_agent.py" -type f | sort + ) +} + +discover_evaluation_tests() { + mapfile -t EVALUATION_TESTS < <( + cd "$REPO_ROOT" + find examples/evaluation -name "test_*.py" -type f | sort + ) +} + +prepare_tasks() { + case "$RUN_MODE" in + all) + discover_run_agent_examples + discover_evaluation_tests + TOTAL_TASKS=$((${#RUN_AGENT_EXAMPLES[@]} + ${#EVALUATION_TESTS[@]} + 1)) + ;; + run-agent) + discover_run_agent_examples + TOTAL_TASKS=${#RUN_AGENT_EXAMPLES[@]} + ;; + evaluation) + discover_evaluation_tests + TOTAL_TASKS=${#EVALUATION_TESTS[@]} + ;; + a2a) + TOTAL_TASKS=1 + ;; + esac +} + +print_summary() { + echo + echo "==================== Example Run Summary ====================" + echo "Passed : ${#PASSED[@]}" + echo "Failed : ${#FAILED[@]}" + echo "Skipped: ${#SKIPPED[@]}" + + if ((${#FAILED[@]} > 0)); then + echo + echo "Failed examples:" + printf ' - %s\n' "${FAILED[@]}" + fi + + if ((${#SKIPPED[@]} > 0)); then + echo + echo "Skipped examples:" + printf ' - %s\n' "${SKIPPED[@]}" + fi +} + +while (($# > 0)); do + case "$1" in + all|run-agent|evaluation|a2a) + RUN_MODE="$1" + ;; + --fail-fast) + FAIL_FAST=true + ;; + --include-manual) + INCLUDE_MANUAL=true + ;; + -h|--help) + show_usage + exit 0 + ;; + *) + echo "Error: unknown argument '$1'" + show_usage + exit 1 + ;; + esac + shift +done + +cd "$REPO_ROOT" +prepare_tasks + +case "$RUN_MODE" in + all) + run_discovered_agents + run_evaluation_tests + run_command "examples/a2a" run_a2a_example + ;; + run-agent) + run_discovered_agents + ;; + evaluation) + run_evaluation_tests + ;; + a2a) + run_command "examples/a2a" run_a2a_example + ;; +esac + +print_summary + +if ((${#FAILED[@]} > 0)); then + exit 1 +fi From c093b3dcd0b7daef969920cbcccf7db1bff8b2c3 Mon Sep 17 00:00:00 2001 From: congkechen Date: Fri, 10 Jul 2026 11:53:50 +0800 Subject: [PATCH 8/8] update run_all_examples --- pipeline_test/run_all_examples.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pipeline_test/run_all_examples.sh b/pipeline_test/run_all_examples.sh index 5c7a597d..5a4d221d 100755 --- a/pipeline_test/run_all_examples.sh +++ b/pipeline_test/run_all_examples.sh @@ -25,12 +25,6 @@ CURRENT_TASK=0 SKIPPED_EXAMPLES=( "examples/claude_agent_with_travel_planner/run_agent.py" "examples/dsl/classifier_mcp/run_agent.py" - "examples/evaluation/llm_final_response/test_llm_final_response.py" - "examples/evaluation/llm_judge_tools/test_llm_judge_tools.py" - "examples/evaluation/llm_rubric_knowledge_recall/test_llm_rubric_knowledge_recall.py" - "examples/evaluation/llm_rubric_response/test_llm_rubric_response.py" - "examples/evaluation/pass_at_k/test_pass_at_k.py" - "examples/evaluation/webui/test_book_finder.py" "examples/knowledge_with_vectorstore/run_agent.py" "examples/mem0_tools/run_agent.py" "examples/memory_service_with_mem0/run_agent.py" @@ -41,6 +35,7 @@ SKIPPED_EXAMPLES=( "examples/session_service_with_redis/run_agent.py" "examples/session_service_with_sql/run_agent.py" "examples/skills_hub/run_agent.py" + "examples/skills_with_container/run_agent.py" "examples/skills_with_cube/run_agent.py" )