Skip to content

Commit 3f0d67c

Browse files
CongkeChenraychen911
authored andcommitted
Add internal pipeline test
1 parent cbb6979 commit 3f0d67c

7 files changed

Lines changed: 299 additions & 0 deletions

pipeline_test/patch_llm_call.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
_PS_DIR="${TMPDIR:-/tmp}/trpc_agent_patch_llm_call.$$"
2+
mkdir -p "$_PS_DIR"
3+
4+
cat > "$_PS_DIR/sitecustomize.py" <<'PYEOF'
5+
import sys
6+
7+
_TAG = "[patch_llm_call]"
8+
9+
10+
def _log(msg):
11+
print(f"{_TAG} {msg}", file=sys.stdout, flush=True)
12+
13+
14+
try:
15+
from trpc_agent_sdk.models._openai_model import OpenAIModel
16+
except Exception as e:
17+
_log(f"patch SKIPPED: failed to import OpenAIModel ({type(e).__name__}: {e})")
18+
else:
19+
_orig_init = OpenAIModel.__init__
20+
21+
def _patched_init(self, *args, **kwargs):
22+
model_name = args[0] if args else kwargs.get("model_name", "<unknown>")
23+
before = kwargs.get("enable_thinking", "<unset>")
24+
kwargs.setdefault("enable_thinking", False)
25+
_orig_init(self, *args, **kwargs)
26+
_log(
27+
f"OpenAIModel(model_name={model_name!r}) init patched "
28+
f"(caller enable_thinking={before!r}; "
29+
f"final kwarg={kwargs.get('enable_thinking')!r}; "
30+
f"self.enable_thinking={getattr(self, 'enable_thinking', '<not-stored>')!r})"
31+
)
32+
33+
OpenAIModel.__init__ = _patched_init
34+
35+
_orig_extract = OpenAIModel._extract_http_options
36+
37+
def _patched_extract(self, config):
38+
http_opts = _orig_extract(self, config) or {}
39+
extra_headers = http_opts.setdefault("extra_headers", {})
40+
extra_headers.setdefault("X-SMG-Routing-Key", "minchangwei")
41+
extra_headers.setdefault("X-SMG-Agent-Name", "trpc-python-agent-pipeline")
42+
extra_body = http_opts.setdefault("extra_body", {})
43+
chat_template_kwargs = extra_body.setdefault("chat_template_kwargs", {})
44+
chat_template_kwargs.setdefault("enable_thinking", False)
45+
return http_opts
46+
47+
OpenAIModel._extract_http_options = _patched_extract
48+
49+
_log(
50+
f"patch INSTALLED on {OpenAIModel.__module__}.{OpenAIModel.__qualname__} "
51+
f"(layers: __init__ + _extract_http_options; "
52+
f"forces extra_body.chat_template_kwargs.enable_thinking=False; "
53+
f"injects X-SMG-Routing-Key and X-SMG-Agent-Name headers)"
54+
)
55+
PYEOF
56+
57+
export PYTHONPATH="$_PS_DIR${PYTHONPATH:+:$PYTHONPATH}"
58+
unset _PS_DIR
59+
echo "[patch_llm_call] OpenAIModel thinking mode will be disabled and SMG headers will be injected (PYTHONPATH updated)."
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# proxy pypi
2+
--index-url https://mirrors.cloud.tencent.com/pypi/simple/
3+
# private pypi
4+
--extra-index-url https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/
5+
6+
trpc_redis==0.2.0a0
7+
trpc_a2a[redis]>=0.2.7
8+
trpc_mcp==0.2.1a0
9+
10+
a2a-sdk<1.0.0,>=0.3.22
11+
claude-agent-sdk>=0.1.3,<0.1.64
12+
cloudpickle>=2.0.0
13+
ag-ui-protocol>=0.1.8
14+
aiofiles
15+
mem0ai>=1.0.3
16+
fastapi
17+
mempalace==3.3.4

pipeline_test/requirements.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# proxy pypi
2+
--index-url https://mirrors.cloud.tencent.com/pypi/simple/
3+
# private pypi
4+
--extra-index-url https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple/
5+
6+
a2a-sdk<1.0.0,>=0.3.22
7+
claude-agent-sdk>=0.1.3,<0.1.64
8+
cloudpickle>=2.0.0
9+
ag-ui-protocol>=0.1.8
10+
aiofiles
11+
mem0ai>=1.0.3
12+
fastapi
13+
mempalace==3.3.4
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
3+
export DISABLE_TRPC_AGENT_REPORT=true
4+
5+
set -e
6+
7+
pip3 install -r pipeline_test/requirements.txt
8+
9+
# Define example categories
10+
LLM_AGENT_EXAMPLES=(
11+
"examples/quickstart/"
12+
"examples/llmagent/"
13+
"examples/llmagent_with_cancel/"
14+
"examples/llmagent_with_model_create_fn/"
15+
"examples/llmagent_with_parallal_tools/"
16+
"examples/llmagent_with_schema/"
17+
"examples/llmagent_with_thinking/"
18+
"examples/llmagent_with_tool_prompt/"
19+
"examples/llmagent_with_streaming_progress_tool/"
20+
# "examples/memory_service_with_mempalace/"
21+
"examples/webfetch_tool/"
22+
"examples/websearch_tool/"
23+
"examples/code_executors/"
24+
"examples/litellm/"
25+
"examples/graph/"
26+
"examples/graph_multi_turns/"
27+
"examples/graph_with_interrupt/"
28+
"examples/agents/human_in_the_loop/llm_agent.py"
29+
"examples/agents/history_control/max_history_messages.py"
30+
"examples/agents/history_control/timeline_filtering.py"
31+
"examples/agents/history_control/branch_filtering.py"
32+
)
33+
34+
MULTI_AGENT_EXAMPLES=(
35+
"examples/multi_agent_chain/"
36+
"examples/multi_agent_compose/"
37+
"examples/multi_agent_cycle/"
38+
"examples/multi_agent_parallel/"
39+
"examples/multi_agent_start_from_last/"
40+
"examples/multi_agent_subagent/"
41+
)
42+
43+
TEAM_AGENT_EXAMPLES=(
44+
"examples/team/"
45+
"examples/team_as_sub_agent/"
46+
"examples/team_human_in_the_loop/"
47+
"examples/team_member_agent_langgraph/"
48+
"examples/team_member_agent_team/"
49+
"examples/team_member_message_filter/"
50+
"examples/team_parallel_execution/"
51+
"examples/team_with_cancel/"
52+
)
53+
54+
run_examples() {
55+
local examples=("$@")
56+
for example in "${examples[@]}"; do
57+
echo "Running $example..."
58+
if [[ "$example" == *.py ]]; then
59+
python3 "$example"
60+
else
61+
cd "$example"
62+
python3 run_agent.py
63+
cd -
64+
fi
65+
done
66+
}
67+
68+
run_llm_agent() {
69+
echo "=== Running LLM Agent Examples ==="
70+
run_examples "${LLM_AGENT_EXAMPLES[@]}"
71+
}
72+
73+
run_multi_agent() {
74+
echo "=== Running Multi Agent Examples ==="
75+
run_examples "${MULTI_AGENT_EXAMPLES[@]}"
76+
}
77+
78+
run_team_agent() {
79+
echo "=== Running Team Agent Examples ==="
80+
run_examples "${TEAM_AGENT_EXAMPLES[@]}"
81+
}
82+
83+
run_all() {
84+
run_llm_agent
85+
run_multi_agent
86+
run_team_agent
87+
}
88+
89+
show_usage() {
90+
echo "Usage: $0 [llm_agent|multi_agent|team_agent]"
91+
echo ""
92+
echo "Parameters:"
93+
echo " llm_agent - Run LLM agent examples (quickstart, llmagent_*, history_control, etc.)"
94+
echo " multi_agent - Run multi agent examples (multi_agent_*)"
95+
echo " team_agent - Run team agent examples (team_*)"
96+
echo ""
97+
echo "If no parameter is provided, all examples will be run."
98+
}
99+
100+
# Main logic
101+
if [ $# -eq 0 ]; then
102+
run_all
103+
else
104+
case "$1" in
105+
llm_agent)
106+
run_llm_agent
107+
;;
108+
multi_agent)
109+
run_multi_agent
110+
;;
111+
team_agent)
112+
run_team_agent
113+
;;
114+
-h|--help)
115+
show_usage
116+
exit 0
117+
;;
118+
*)
119+
echo "Error: Unknown parameter '$1'"
120+
show_usage
121+
exit 1
122+
;;
123+
esac
124+
fi
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
export DISABLE_TRPC_AGENT_REPORT=true
4+
5+
set -e
6+
7+
pip3 install -r pipeline_test/requirements-ecosystem.txt
8+
9+
# 启动A2A服务端(后台运行)
10+
echo "启动A2A服务端..."
11+
python3 examples/trpc_a2a/trpc_main.py &
12+
SERVER_PID=$!
13+
14+
# 等待服务端启动
15+
sleep 5
16+
17+
# 运行A2A客户端测试
18+
echo "运行A2A客户端测试..."
19+
python3 examples/trpc_a2a/raw_client.py
20+
python3 examples/trpc_a2a/client.py
21+
22+
# TeamAgent with Remote A2A Member
23+
echo "运行 TeamAgent with Remote A2A Member..."
24+
cd examples/team_member_agent_remote_a2a/
25+
python3 run_agent.py
26+
cd -
27+
28+
# 停止服务端
29+
echo "停止A2A服务端..."
30+
kill $SERVER_PID 2>/dev/null || true
31+
32+
# TeamAgent with Claude Member
33+
echo "运行 TeamAgent with Claude Member..."
34+
cd examples/team_member_agent_claude/
35+
python3 run_agent.py
36+
cd -
37+
38+
# python3 examples/ecosystem/langchain_knowledge/custom_document_loader.py
39+
# python3 examples/ecosystem/langchain_knowledge/custom_retriever.py
40+
# python3 examples/ecosystem/langchain_knowledge/custom_text_splitter.py
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
export DISABLE_TRPC_AGENT_REPORT=true
4+
5+
set -e
6+
7+
# Evaluation
8+
cd examples/evaluation/quickstart && pytest test_quickstart.py -v -s && cd -
9+
cd examples/evaluation/webui && pytest test_book_finder.py -v -s && cd -
10+
cd examples/evaluation/callbacks && pytest test_callbacks.py -v -s && cd -
11+
cd examples/evaluation/custom_runner && pytest test_custom_runner.py -v -s && cd -
12+
cd examples/evaluation/context_messages && pytest test_context_messages.py -v -s && cd -
13+
cd examples/evaluation/trace_mode && pytest test_trace_mode.py -v -s && cd -
14+
cd examples/evaluation/pass_at_k && pytest test_pass_at_k.py -v -s && cd -
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
export DISABLE_TRPC_AGENT_REPORT=true
4+
5+
set -e
6+
7+
# File Tools
8+
cd examples/file_tools/
9+
python3 run_agent.py
10+
cd -
11+
12+
# Filter with Agent
13+
cd examples/filter_with_agent/
14+
python3 run_agent.py
15+
cd -
16+
17+
# Filter with Model
18+
cd examples/filter_with_model/
19+
python3 run_agent.py
20+
cd -
21+
22+
# Filter with Tool
23+
cd examples/filter_with_tool/
24+
python3 run_agent.py
25+
cd -
26+
27+
# Session&Memory
28+
python3 examples/session_state/run_agent.py
29+
python3 examples/session_summarizer/run_agent.py
30+
31+
# Tools
32+
python3 examples/tools/mcp_tools/mcp_tools.py

0 commit comments

Comments
 (0)