From adb0c41f05966d826a1a237c499c8bafe04d4707 Mon Sep 17 00:00:00 2001 From: congkechen Date: Tue, 7 Jul 2026 14:55:16 +0800 Subject: [PATCH 1/5] 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/5] 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/5] 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/5] 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/5] 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