Skip to content
Merged
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
59 changes: 59 additions & 0 deletions pipeline_test/patch_llm_call.sh
Original file line number Diff line number Diff line change
@@ -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", "<unknown>")
before = kwargs.get("enable_thinking", "<unset>")
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', '<not-stored>')!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)."
17 changes: 17 additions & 0 deletions pipeline_test/requirements-ecosystem.txt
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions pipeline_test/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
128 changes: 128 additions & 0 deletions pipeline_test/run_agent_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/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"
"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=(
"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
41 changes: 41 additions & 0 deletions pipeline_test/run_ecosystem_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

export DISABLE_TRPC_AGENT_REPORT=true

set -e

pip3 install -r pipeline_test/requirements-ecosystem.txt

# 启动A2A服务端(后台运行)
echo "启动A2A服务端..."
python3 examples/a2a/trpc_main.py &
SERVER_PID=$!

# 等待服务端启动
sleep 5

# 运行A2A客户端测试
echo "运行A2A客户端测试..."
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服务端..."
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
14 changes: 14 additions & 0 deletions pipeline_test/run_evaluation_examples.sh
Original file line number Diff line number Diff line change
@@ -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 -
33 changes: 33 additions & 0 deletions pipeline_test/run_other_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/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
python3 examples/mcp_tools/run_agent.py
Loading