sycommon-python-lib 0.2.3a10__tar.gz → 0.2.3a11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/PKG-INFO +1 -1
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/pyproject.toml +1 -1
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/deep_agent.py +7 -6
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/summarization_utils.py +8 -7
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/LLMConfig.py +1 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/struct_token.py +2 -2
- sycommon_python_lib-0.2.3a11/src/sycommon/tests/test_summarization_config.py +463 -0
- sycommon_python_lib-0.2.3a11/src/sycommon/tests/test_summarization_real.py +329 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon_python_lib.egg-info/PKG-INFO +1 -1
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon_python_lib.egg-info/SOURCES.txt +2 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/README.md +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/setup.cfg +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/cli.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/core/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/core/console.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/core/models.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/core/project.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/core/utils.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/agent/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/agent/main_agent.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/agent/nodes/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/agent/nodes/example_node.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/agent/states/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/agent/states/agent_state.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/api/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/api/query.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/api/sse/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/api/sse/agent.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/client/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/db/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/db/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/db/model/entity.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/db/service.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/model/parse.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/tools/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/agent/tools/mq.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/.env.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/.gitignore.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/Dockerfile.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/app.yaml.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/client/FileServiceClient.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/client/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/model/file_info.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/base/requirements.txt.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/cli/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/cli/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/cli/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/cli/commands/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/cli/commands/hello.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/cli/pyproject.toml.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/cli/tools/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/README.md.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/api/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/api/echo.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/api/sse/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/api/sse/echo.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/app.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/client/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/model/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/tools/__init__.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/command/templates/web/tools/mq.py.tpl +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/nexus/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/__main__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/agents/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/agents/factory.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/agents/prompts.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/browser.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/capabilities/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/capabilities/console.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/capabilities/dom.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/capabilities/network.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/capabilities/page_errors.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/capabilities/performance.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/capabilities/screenshot.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/client.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/protocol.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cdp/repl.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/cli.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/cdp_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/chat_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/create_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/evaluate_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/init_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/memory_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/resume_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/rollback_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/commands/run_cmd.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/core/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/core/backend.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/core/config.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/core/display.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/core/git_integration.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/core/llm.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/core/state.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/evaluate/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/evaluate/api_evaluator.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/memory/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/memory/compressor.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/memory/full.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/memory/hot.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/memory/manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/memory/warm.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/mode/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/mode/create.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/mode/optimize.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/models/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/models/config_models.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/baseline_tests.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/checkpoint.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/convergence.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/diagnosis.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/engine.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/environment.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/experience.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/harness_prompts.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/history.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/optimization_logger.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/pre_validation.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/reward.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/strategy_bandit.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/strategy_generator.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/rl/strategy_prompts.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycli/skills/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/agent_manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/chat_events.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/multi_agent_team.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/sandbox/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/sandbox/file_ops.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/sandbox/http_sandbox_backend.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/sandbox/minio_sync.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/sandbox/sandbox_pool.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/sandbox/sandbox_recovery.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/sandbox/session.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/auth/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/auth/ldap_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/auth/wecom_ldap_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/Config.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/DatabaseConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/ElasticsearchConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/EmbeddingConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/LangfuseConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/MQConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/RedisConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/RerankerConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/SentryConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/XxlJobConfig.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/config/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/database/async_base_db_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/database/async_database_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/database/base_db_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/database/database_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/database/elasticsearch_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/database/redis_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/database/token_usage_db_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/health/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/health/health_check.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/health/metrics.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/health/ping.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/heartbeat_process/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/heartbeat_process/heartbeat_config.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/heartbeat_process/heartbeat_process_manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/heartbeat_process/heartbeat_process_worker.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/embedding.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/get_llm.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/llm_logger.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/llm_tokens.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/llm_with_token_tracking.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/native_with_fallback_runnable.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/output_fixing_runnable.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/sy_langfuse.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/token_usage_es_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/token_usage_mysql_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/usage_token.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/logging/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/logging/async_sql_logger.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/logging/kafka_log.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/logging/logger_levels.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/logging/logger_wrapper.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/logging/process_logger.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/logging/sql_logger.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/background_execution.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/context.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/cors.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/docs.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/exception.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/middleware.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/monitor_memory.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/mq.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/sandbox.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/timeout.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/token_tracking.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/tool_result_truncation.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/middleware/traceid.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/base_http.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/log.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/mqlistener_config.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/mqmsg_model.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/mqsend_config.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/sandbox.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/sso_user.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/token_usage.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/token_usage_mysql.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/models/xxljob_handler_config.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/notice/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/notice/uvicorn_monitor.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/notice/wecom_message.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/process_pool_consumer.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_client.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_pool.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_service_client_manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_service_connection_monitor.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_service_consumer_manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_service_core.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/rabbitmq/rabbitmq_service_producer_manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/sentry/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/sentry/sy_sentry.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/services.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/sse/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/sse/event.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/sse/sse.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/example.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/example2.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/feign.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/feign_client.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/nacos_client_base.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/nacos_config_manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/nacos_heartbeat_manager.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/nacos_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/nacos_service_discovery.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/nacos_service_registration.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/synacos/param.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tests/deep_agent_server.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tests/test_deep_agent.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tests/test_email.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tests/test_mq.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tests/test_real_summarization.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/async_utils.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/docs.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/env.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/merge_headers.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/snowflake.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/syemail.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/tools/timing.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/xxljob/__init__.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/xxljob/xxljob_service.py +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon_python_lib.egg-info/dependency_links.txt +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon_python_lib.egg-info/entry_points.txt +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon_python_lib.egg-info/requires.txt +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon_python_lib.egg-info/top_level.txt +0 -0
- {sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/tests/test_sycli.py +0 -0
{sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/agent/deep_agent.py
RENAMED
|
@@ -508,7 +508,13 @@ class DeepAgent:
|
|
|
508
508
|
max_retries: int = 3,
|
|
509
509
|
base_delay: float = 1.0,
|
|
510
510
|
) -> AsyncGenerator:
|
|
511
|
-
"""带重试机制的 astream
|
|
511
|
+
"""带重试机制的 astream
|
|
512
|
+
|
|
513
|
+
网络错误指数退避重试,BadRequestError 不重试。
|
|
514
|
+
上下文溢出由 deepagents SummarizationMiddleware 在模型调用层处理
|
|
515
|
+
(捕获 ContextOverflowError 后压缩消息并重试 LLM 调用),
|
|
516
|
+
不在此处重试整个 graph。
|
|
517
|
+
"""
|
|
512
518
|
import httpx
|
|
513
519
|
from openai import APIConnectionError, APIError, APITimeoutError
|
|
514
520
|
|
|
@@ -529,11 +535,6 @@ class DeepAgent:
|
|
|
529
535
|
return
|
|
530
536
|
except (APIConnectionError, APIError, APITimeoutError, ConnectionError, httpx.RemoteProtocolError) as e:
|
|
531
537
|
last_error = e
|
|
532
|
-
# 400 BadRequestError 不重试:请求参数有误,重试无意义
|
|
533
|
-
from openai import BadRequestError
|
|
534
|
-
if isinstance(e, BadRequestError):
|
|
535
|
-
SYLogger.error(f"[DeepAgent] API 参数错误,不重试: {e}")
|
|
536
|
-
raise
|
|
537
538
|
if attempt < max_retries - 1:
|
|
538
539
|
delay = base_delay * (2 ** attempt)
|
|
539
540
|
SYLogger.warning(
|
|
@@ -48,8 +48,8 @@ def _patched_compute_summarization_defaults(model):
|
|
|
48
48
|
except Exception:
|
|
49
49
|
max_tokens = 72000
|
|
50
50
|
|
|
51
|
-
trigger = int(max_tokens * 0.
|
|
52
|
-
keep = int(max_tokens * 0.
|
|
51
|
+
trigger = int(max_tokens * 0.85)
|
|
52
|
+
keep = int(max_tokens * 0.15)
|
|
53
53
|
return {
|
|
54
54
|
"trigger": ("tokens", trigger),
|
|
55
55
|
"keep": ("tokens", keep),
|
|
@@ -94,8 +94,8 @@ def build_summarization_middleware(
|
|
|
94
94
|
model_name: str,
|
|
95
95
|
backend: "BACKEND_TYPES",
|
|
96
96
|
*,
|
|
97
|
-
trigger_fraction: float = 0.
|
|
98
|
-
keep_fraction: float = 0.
|
|
97
|
+
trigger_fraction: float = 0.85,
|
|
98
|
+
keep_fraction: float = 0.15,
|
|
99
99
|
default_max_tokens: int = 200000,
|
|
100
100
|
) -> SummarizationToolMiddleware:
|
|
101
101
|
"""根据模型上下文窗口大小构建 compact_conversation 工具 middleware。
|
|
@@ -111,8 +111,8 @@ def build_summarization_middleware(
|
|
|
111
111
|
model: LLM 实例。
|
|
112
112
|
model_name: 模型名称(用于从 nacos 读取配置)。
|
|
113
113
|
backend: 后端实例。
|
|
114
|
-
trigger_fraction:
|
|
115
|
-
keep_fraction:
|
|
114
|
+
trigger_fraction: 触发压缩占有效输入的比例,默认 85%。
|
|
115
|
+
keep_fraction: 压缩后保留占有效输入的比例,默认 15%。
|
|
116
116
|
default_max_tokens: 无法从配置读取时的默认上下文窗口大小。
|
|
117
117
|
|
|
118
118
|
Returns:
|
|
@@ -142,7 +142,8 @@ def build_summarization_middleware(
|
|
|
142
142
|
},
|
|
143
143
|
)
|
|
144
144
|
|
|
145
|
-
print(f"[Summarization] compact_conversation 工具配置: model={model_name},
|
|
145
|
+
print(f"[Summarization] compact_conversation 工具配置: model={model_name}, "
|
|
146
|
+
f"max_tokens={max_tokens}, "
|
|
146
147
|
f"trigger={trigger_tokens} tokens ({trigger_fraction:.0%}), "
|
|
147
148
|
f"keep={keep_tokens} tokens ({keep_fraction:.0%})")
|
|
148
149
|
return SummarizationToolMiddleware(summ)
|
{sycommon_python_lib-0.2.3a10 → sycommon_python_lib-0.2.3a11}/src/sycommon/llm/struct_token.py
RENAMED
|
@@ -445,10 +445,10 @@ class StructuredRunnableWithToken(Runnable):
|
|
|
445
445
|
|
|
446
446
|
# 2. 检查并执行上下文压缩 (仅在异步模式且开启时)
|
|
447
447
|
if self.enable_compression:
|
|
448
|
-
max_tokens = self.llmConfig.maxTokens
|
|
448
|
+
max_tokens = int(self.llmConfig.maxTokens * self.threshold_ratio)
|
|
449
449
|
current_tokens = self._count_tokens(adapted_input)
|
|
450
450
|
|
|
451
|
-
if current_tokens > max_tokens
|
|
451
|
+
if current_tokens > max_tokens:
|
|
452
452
|
SYLogger.warning(
|
|
453
453
|
f"⚠️ Context limit reached: {current_tokens}/{max_tokens}")
|
|
454
454
|
# 执行压缩,替换 adapted_input
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
"""上下文压缩机制测试。
|
|
2
|
+
|
|
3
|
+
测试三个压缩阶段:
|
|
4
|
+
1. monkey-patch 是否替换了 deepagents 默认函数
|
|
5
|
+
2. build_summarization_middleware 配置是否正确
|
|
6
|
+
3. 自动压缩触发 — 消息超阈值时是否压缩
|
|
7
|
+
4. ContextOverflowError 兜底 — middleware 内部捕获并压缩
|
|
8
|
+
5. LLMConfig maxOutputTokens 兼容性
|
|
9
|
+
6. 不同 maxTokens 下的阈值比例
|
|
10
|
+
|
|
11
|
+
不依赖真实 API,使用 mock 模型。
|
|
12
|
+
"""
|
|
13
|
+
import asyncio
|
|
14
|
+
import sys
|
|
15
|
+
import os
|
|
16
|
+
import time
|
|
17
|
+
import functools
|
|
18
|
+
import pytest
|
|
19
|
+
|
|
20
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
21
|
+
|
|
22
|
+
from unittest.mock import AsyncMock, MagicMock, patch
|
|
23
|
+
from langchain_core.messages import (
|
|
24
|
+
AIMessage, HumanMessage, SystemMessage, ToolMessage,
|
|
25
|
+
)
|
|
26
|
+
from langchain_core.language_models import BaseChatModel
|
|
27
|
+
from langchain_core.outputs import ChatGeneration, ChatResult
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# ============================================================
|
|
31
|
+
# 辅助工具
|
|
32
|
+
# ============================================================
|
|
33
|
+
|
|
34
|
+
class MockModel(BaseChatModel):
|
|
35
|
+
"""记录调用次数并返回固定回复的 mock 模型。"""
|
|
36
|
+
|
|
37
|
+
call_count: int = 0
|
|
38
|
+
responses: list = []
|
|
39
|
+
|
|
40
|
+
class Config:
|
|
41
|
+
arbitrary_types_allowed = True
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def _llm_type(self) -> str:
|
|
45
|
+
return "mock"
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def model_name(self) -> str:
|
|
49
|
+
return "test-model"
|
|
50
|
+
|
|
51
|
+
def _generate(self, messages, stop=None, run_manager=None, **kwargs):
|
|
52
|
+
self.call_count += 1
|
|
53
|
+
idx = min(self.call_count - 1, len(self.responses) - 1)
|
|
54
|
+
return self.responses[idx]
|
|
55
|
+
|
|
56
|
+
async def _agenerate(self, messages, stop=None, run_manager=None, **kwargs):
|
|
57
|
+
return self._generate(messages, stop, run_manager, **kwargs)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def make_long_text(num_chars: int) -> str:
|
|
61
|
+
"""生成长文本用于快速填满 token 预算。"""
|
|
62
|
+
base = "这是一段用于测试上下文压缩机制的中文文本内容。"
|
|
63
|
+
repeat = (num_chars // len(base)) + 1
|
|
64
|
+
return (base * repeat)[:num_chars]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def count_tokens_cn(messages, **kwargs):
|
|
68
|
+
"""中文场景近似 token 计数(chars_per_token=2.0)。"""
|
|
69
|
+
from langchain_core.messages.utils import count_tokens_approximately
|
|
70
|
+
counter = functools.partial(count_tokens_approximately, chars_per_token=2.0)
|
|
71
|
+
try:
|
|
72
|
+
return counter(messages, **kwargs)
|
|
73
|
+
except TypeError:
|
|
74
|
+
return counter(messages)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# ============================================================
|
|
78
|
+
# 测试 1: monkey-patch 是否替换了 deepagents 默认函数
|
|
79
|
+
# ============================================================
|
|
80
|
+
|
|
81
|
+
def test_1_patched_defaults():
|
|
82
|
+
"""验证 monkey-patch 替换了 deepagents 的默认计算函数。"""
|
|
83
|
+
print("\n" + "=" * 60)
|
|
84
|
+
print("测试 1: _patched_compute_summarization_defaults 是否生效")
|
|
85
|
+
print("=" * 60)
|
|
86
|
+
|
|
87
|
+
from sycommon.agent.summarization_utils import _patched_compute_summarization_defaults
|
|
88
|
+
import deepagents.middleware.summarization as summ_mod
|
|
89
|
+
|
|
90
|
+
# 验证 monkey-patch 指向同一函数
|
|
91
|
+
assert summ_mod.compute_summarization_defaults is _patched_compute_summarization_defaults, \
|
|
92
|
+
"monkey-patch 未生效"
|
|
93
|
+
print(f" monkey-patch 指向同一函数: OK")
|
|
94
|
+
|
|
95
|
+
# 直接调用函数,mock 内部的 Config
|
|
96
|
+
mock_llm_cfg = {
|
|
97
|
+
"model": "test-model", "provider": "openai",
|
|
98
|
+
"baseUrl": "http://localhost/v1", "maxTokens": 200000,
|
|
99
|
+
"vision": False, "callFunction": True, "default": True,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
model = MockModel(responses=[])
|
|
103
|
+
# _patched 内部: from sycommon.config.Config import Config; Config().get_llm_config(...)
|
|
104
|
+
# 需要 mock 掉 Config 的实例化
|
|
105
|
+
mock_config_instance = MagicMock()
|
|
106
|
+
mock_config_instance.get_llm_config = MagicMock(return_value=mock_llm_cfg)
|
|
107
|
+
|
|
108
|
+
with patch("sycommon.config.Config.Config", return_value=mock_config_instance):
|
|
109
|
+
result = _patched_compute_summarization_defaults(model)
|
|
110
|
+
|
|
111
|
+
expected_trigger = int(200000 * 0.85)
|
|
112
|
+
expected_keep = int(200000 * 0.15)
|
|
113
|
+
|
|
114
|
+
assert result["trigger"] == ("tokens", expected_trigger), \
|
|
115
|
+
f"trigger 不匹配: {result['trigger']}"
|
|
116
|
+
assert result["keep"] == ("tokens", expected_keep), \
|
|
117
|
+
f"keep 不匹配: {result['keep']}"
|
|
118
|
+
assert result["truncate_args_settings"]["trigger"] == ("tokens", expected_trigger)
|
|
119
|
+
assert result["truncate_args_settings"]["keep"] == ("tokens", expected_keep)
|
|
120
|
+
|
|
121
|
+
print(f" maxTokens=200000 → trigger={expected_trigger} (85%), keep={expected_keep} (15%)")
|
|
122
|
+
print(f" 结果: PASSED")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# ============================================================
|
|
126
|
+
# 测试 2: build_summarization_middleware 配置是否正确
|
|
127
|
+
# ============================================================
|
|
128
|
+
|
|
129
|
+
def test_2_build_middleware_config():
|
|
130
|
+
"""验证 build_summarization_middleware 传入的参数正确。"""
|
|
131
|
+
print("\n" + "=" * 60)
|
|
132
|
+
print("测试 2: build_summarization_middleware 配置是否正确")
|
|
133
|
+
print("=" * 60)
|
|
134
|
+
|
|
135
|
+
from sycommon.agent.summarization_utils import build_summarization_middleware
|
|
136
|
+
from deepagents.backends.filesystem import FilesystemBackend
|
|
137
|
+
|
|
138
|
+
mock_llm_cfg = {
|
|
139
|
+
"model": "test-model", "provider": "openai",
|
|
140
|
+
"baseUrl": "http://localhost/v1", "maxTokens": 100000,
|
|
141
|
+
"vision": False, "callFunction": True, "default": True,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
model = MockModel(responses=[])
|
|
145
|
+
fs_backend = FilesystemBackend(root_dir="/tmp/test_mw", virtual_mode=True)
|
|
146
|
+
|
|
147
|
+
mock_config_instance = MagicMock()
|
|
148
|
+
mock_config_instance.get_llm_config = MagicMock(return_value=mock_llm_cfg)
|
|
149
|
+
|
|
150
|
+
with patch("sycommon.config.Config.Config", return_value=mock_config_instance):
|
|
151
|
+
tool_mw = build_summarization_middleware(model, "test-model", fs_backend)
|
|
152
|
+
|
|
153
|
+
inner = tool_mw._summarization
|
|
154
|
+
# trigger 存在 _lc_helper 内部
|
|
155
|
+
lc_helper = inner._lc_helper
|
|
156
|
+
expected_trigger = int(100000 * 0.85)
|
|
157
|
+
expected_keep = int(100000 * 0.15)
|
|
158
|
+
|
|
159
|
+
assert lc_helper.trigger == ("tokens", expected_trigger), \
|
|
160
|
+
f"trigger 不匹配: {lc_helper.trigger}"
|
|
161
|
+
assert lc_helper.keep == ("tokens", expected_keep), \
|
|
162
|
+
f"keep 不匹配: {lc_helper.keep}"
|
|
163
|
+
|
|
164
|
+
print(f" maxTokens=100000 → trigger={expected_trigger}, keep={expected_keep}")
|
|
165
|
+
print(f" 结果: PASSED")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
# ============================================================
|
|
169
|
+
# 测试 3: 自动压缩触发 — 消息超阈值时是否压缩
|
|
170
|
+
# ============================================================
|
|
171
|
+
|
|
172
|
+
@pytest.mark.asyncio
|
|
173
|
+
async def test_3_auto_summarization_trigger():
|
|
174
|
+
"""构造超阈值的消息列表,验证 middleware 自动压缩。"""
|
|
175
|
+
print("\n" + "=" * 60)
|
|
176
|
+
print("测试 3: 自动压缩触发 — 消息超阈值时是否压缩")
|
|
177
|
+
print("=" * 60)
|
|
178
|
+
|
|
179
|
+
from deepagents.middleware.summarization import (
|
|
180
|
+
SummarizationMiddleware,
|
|
181
|
+
ExtendedModelResponse,
|
|
182
|
+
)
|
|
183
|
+
from deepagents.backends.filesystem import FilesystemBackend
|
|
184
|
+
from sycommon.agent.summarization_utils import _chinese_token_counter
|
|
185
|
+
|
|
186
|
+
max_tokens = 3000
|
|
187
|
+
trigger_tokens = int(max_tokens * 0.85) # 2550
|
|
188
|
+
keep_tokens = int(max_tokens * 0.15) # 450
|
|
189
|
+
|
|
190
|
+
model = MockModel(responses=[
|
|
191
|
+
ChatResult(generations=[ChatGeneration(message=AIMessage(content="好的,我明白了。"))]),
|
|
192
|
+
])
|
|
193
|
+
|
|
194
|
+
fs_backend = FilesystemBackend(
|
|
195
|
+
root_dir=f"/tmp/test_auto_{int(time.time())}", virtual_mode=True,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
summ = SummarizationMiddleware(
|
|
199
|
+
model=model,
|
|
200
|
+
backend=fs_backend,
|
|
201
|
+
trigger=("tokens", trigger_tokens),
|
|
202
|
+
keep=("tokens", keep_tokens),
|
|
203
|
+
token_counter=_chinese_token_counter,
|
|
204
|
+
trim_tokens_to_summarize=None,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
# 构造大量消息超过 trigger
|
|
208
|
+
messages = [HumanMessage(content=make_long_text(800)) for _ in range(20)]
|
|
209
|
+
messages.append(HumanMessage(content="请总结一下"))
|
|
210
|
+
|
|
211
|
+
total_tokens = count_tokens_cn(messages)
|
|
212
|
+
should = summ._should_summarize(messages, total_tokens)
|
|
213
|
+
|
|
214
|
+
print(f" total_tokens={total_tokens}, trigger={trigger_tokens}")
|
|
215
|
+
print(f" should_summarize={should}")
|
|
216
|
+
|
|
217
|
+
assert should, f"消息应触发压缩: tokens={total_tokens} >= trigger={trigger_tokens}"
|
|
218
|
+
|
|
219
|
+
cutoff = summ._determine_cutoff_index(messages)
|
|
220
|
+
to_summarize, preserved = summ._partition_messages(messages, cutoff)
|
|
221
|
+
print(f" cutoff_index={cutoff}, to_summarize={len(to_summarize)}, preserved={len(preserved)}")
|
|
222
|
+
|
|
223
|
+
summary = await summ._acreate_summary(to_summarize)
|
|
224
|
+
print(f" summary 长度={len(summary)} 字符")
|
|
225
|
+
print(f" summary 预览: {summary[:100]}...")
|
|
226
|
+
|
|
227
|
+
assert len(summary) > 0, "摘要不应为空"
|
|
228
|
+
assert len(preserved) < len(messages), "保留消息应少于总消息数"
|
|
229
|
+
print(f" 结果: PASSED (自动压缩已触发)")
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
# ============================================================
|
|
233
|
+
# 测试 4: ContextOverflowError 兜底 — middleware 内部重试
|
|
234
|
+
# ============================================================
|
|
235
|
+
|
|
236
|
+
@pytest.mark.asyncio
|
|
237
|
+
async def test_4_context_overflow_fallback():
|
|
238
|
+
"""模拟第一次 LLM 调用超限返回 ContextOverflowError,
|
|
239
|
+
验证 middleware 捕获后压缩并重试。"""
|
|
240
|
+
print("\n" + "=" * 60)
|
|
241
|
+
print("测试 4: ContextOverflowError 兜底 — middleware 内部重试")
|
|
242
|
+
print("=" * 60)
|
|
243
|
+
|
|
244
|
+
from langchain_core.exceptions import ContextOverflowError
|
|
245
|
+
from deepagents.middleware.summarization import (
|
|
246
|
+
SummarizationMiddleware,
|
|
247
|
+
ExtendedModelResponse,
|
|
248
|
+
)
|
|
249
|
+
from deepagents.backends.filesystem import FilesystemBackend
|
|
250
|
+
from sycommon.agent.summarization_utils import _chinese_token_counter
|
|
251
|
+
|
|
252
|
+
max_tokens = 3000
|
|
253
|
+
trigger_tokens = int(max_tokens * 0.85) # 2550
|
|
254
|
+
keep_tokens = int(max_tokens * 0.15) # 450
|
|
255
|
+
|
|
256
|
+
handler_call_count = 0
|
|
257
|
+
|
|
258
|
+
class OverflowThenOkModel(BaseChatModel):
|
|
259
|
+
class Config:
|
|
260
|
+
arbitrary_types_allowed = True
|
|
261
|
+
|
|
262
|
+
@property
|
|
263
|
+
def _llm_type(self) -> str:
|
|
264
|
+
return "overflow-then-ok"
|
|
265
|
+
|
|
266
|
+
def _generate(self, messages, stop=None, run_manager=None, **kwargs):
|
|
267
|
+
return ChatResult(generations=[ChatGeneration(
|
|
268
|
+
message=AIMessage(content="这是压缩后的回复。"))])
|
|
269
|
+
|
|
270
|
+
async def _agenerate(self, messages, stop=None, run_manager=None, **kwargs):
|
|
271
|
+
return self._generate(messages, stop, run_manager, **kwargs)
|
|
272
|
+
|
|
273
|
+
model = OverflowThenOkModel()
|
|
274
|
+
fs_backend = FilesystemBackend(
|
|
275
|
+
root_dir=f"/tmp/test_overflow_{int(time.time())}", virtual_mode=True,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
summ = SummarizationMiddleware(
|
|
279
|
+
model=model,
|
|
280
|
+
backend=fs_backend,
|
|
281
|
+
trigger=("tokens", trigger_tokens),
|
|
282
|
+
keep=("tokens", keep_tokens),
|
|
283
|
+
token_counter=_chinese_token_counter,
|
|
284
|
+
trim_tokens_to_summarize=None,
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
# 构造消息:低于 trigger 阈值
|
|
288
|
+
messages = [HumanMessage(content=make_long_text(300)) for _ in range(3)]
|
|
289
|
+
messages.append(HumanMessage(content="请回答"))
|
|
290
|
+
|
|
291
|
+
request = MagicMock()
|
|
292
|
+
request.messages = messages
|
|
293
|
+
request.system_message = None
|
|
294
|
+
request.tools = None
|
|
295
|
+
request.state = {}
|
|
296
|
+
|
|
297
|
+
total_tokens = count_tokens_cn(messages)
|
|
298
|
+
should = summ._should_summarize(messages, total_tokens)
|
|
299
|
+
print(f" total_tokens={total_tokens}, trigger={trigger_tokens}, should_summarize={should}")
|
|
300
|
+
|
|
301
|
+
# handler: 第一次抛 ContextOverflowError,第二次正常
|
|
302
|
+
async def overflow_handler(req):
|
|
303
|
+
nonlocal handler_call_count
|
|
304
|
+
handler_call_count += 1
|
|
305
|
+
if handler_call_count == 1:
|
|
306
|
+
raise ContextOverflowError("context_length_exceeded")
|
|
307
|
+
return MagicMock()
|
|
308
|
+
|
|
309
|
+
try:
|
|
310
|
+
result = await summ.awrap_model_call(request, overflow_handler)
|
|
311
|
+
print(f" handler 调用次数: {handler_call_count}")
|
|
312
|
+
|
|
313
|
+
if isinstance(result, ExtendedModelResponse):
|
|
314
|
+
event = result.command.update.get("_summarization_event")
|
|
315
|
+
if event:
|
|
316
|
+
print(f" 压缩事件: cutoff_index={event['cutoff_index']}")
|
|
317
|
+
print(f" 结果: PASSED (ContextOverflow 兜底成功,自动压缩并重试)")
|
|
318
|
+
else:
|
|
319
|
+
print(f" 结果: PASSED (重试成功)")
|
|
320
|
+
except ContextOverflowError:
|
|
321
|
+
print(f" 结果: FAILED (ContextOverflowError 未被 middleware 捕获)")
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
# ============================================================
|
|
325
|
+
# 测试 5: LLMConfig maxOutputTokens 兼容性
|
|
326
|
+
# ============================================================
|
|
327
|
+
|
|
328
|
+
def test_5_llm_config_compatibility():
|
|
329
|
+
"""验证 LLMConfig 新增 maxOutputTokens 字段的兼容性。"""
|
|
330
|
+
print("\n" + "=" * 60)
|
|
331
|
+
print("测试 5: LLMConfig maxOutputTokens 兼容性")
|
|
332
|
+
print("=" * 60)
|
|
333
|
+
|
|
334
|
+
from sycommon.config.LLMConfig import LLMConfig
|
|
335
|
+
|
|
336
|
+
# 不传 maxOutputTokens
|
|
337
|
+
cfg1 = LLMConfig(
|
|
338
|
+
model="test", provider="openai", baseUrl="http://localhost/v1",
|
|
339
|
+
maxTokens=200000, vision=False, callFunction=True,
|
|
340
|
+
)
|
|
341
|
+
assert cfg1.maxOutputTokens is None
|
|
342
|
+
print(f" 不传 maxOutputTokens: {cfg1.maxOutputTokens} (OK)")
|
|
343
|
+
|
|
344
|
+
# 传 maxOutputTokens
|
|
345
|
+
cfg2 = LLMConfig(
|
|
346
|
+
model="test", provider="openai", baseUrl="http://localhost/v1",
|
|
347
|
+
maxTokens=200000, vision=False, callFunction=True,
|
|
348
|
+
maxOutputTokens=128000,
|
|
349
|
+
)
|
|
350
|
+
assert cfg2.maxOutputTokens == 128000
|
|
351
|
+
print(f" 传 maxOutputTokens=128000: {cfg2.maxOutputTokens} (OK)")
|
|
352
|
+
|
|
353
|
+
# 从 dict 构造(nacos 场景)
|
|
354
|
+
nacos_cfg = {
|
|
355
|
+
"model": "glm-5.1", "provider": "openai",
|
|
356
|
+
"baseUrl": "http://localhost/v1", "maxTokens": 200000,
|
|
357
|
+
"vision": False, "callFunction": True, "maxOutputTokens": 128000,
|
|
358
|
+
}
|
|
359
|
+
cfg3 = LLMConfig(**nacos_cfg)
|
|
360
|
+
assert cfg3.maxOutputTokens == 128000
|
|
361
|
+
print(f" 从 dict 构造: maxOutputTokens={cfg3.maxOutputTokens} (OK)")
|
|
362
|
+
|
|
363
|
+
print(f" 结果: PASSED")
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
# ============================================================
|
|
367
|
+
# 测试 6: 不同 maxTokens 下的阈值比例
|
|
368
|
+
# ============================================================
|
|
369
|
+
|
|
370
|
+
def test_6_threshold_ratios():
|
|
371
|
+
"""验证不同 maxTokens 下 trigger/keep 的计算正确性。"""
|
|
372
|
+
print("\n" + "=" * 60)
|
|
373
|
+
print("测试 6: 不同 maxTokens 下的阈值计算")
|
|
374
|
+
print("=" * 60)
|
|
375
|
+
|
|
376
|
+
from sycommon.agent.summarization_utils import _patched_compute_summarization_defaults
|
|
377
|
+
|
|
378
|
+
test_cases = [
|
|
379
|
+
(72000, "默认 fallback"),
|
|
380
|
+
(100000, "100k 模型"),
|
|
381
|
+
(200000, "200k 模型"),
|
|
382
|
+
(3000, "极小(测试用)"),
|
|
383
|
+
]
|
|
384
|
+
|
|
385
|
+
all_passed = True
|
|
386
|
+
for max_tokens, desc in test_cases:
|
|
387
|
+
mock_llm_cfg = {
|
|
388
|
+
"model": "test", "provider": "openai",
|
|
389
|
+
"baseUrl": "http://localhost/v1",
|
|
390
|
+
"maxTokens": max_tokens,
|
|
391
|
+
"vision": False, "callFunction": True, "default": True,
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
mock_config_instance = MagicMock()
|
|
395
|
+
mock_config_instance.get_llm_config = MagicMock(return_value=mock_llm_cfg)
|
|
396
|
+
|
|
397
|
+
with patch("sycommon.config.Config.Config", return_value=mock_config_instance):
|
|
398
|
+
model = MockModel(responses=[])
|
|
399
|
+
result = _patched_compute_summarization_defaults(model)
|
|
400
|
+
|
|
401
|
+
trigger_val = result["trigger"][1]
|
|
402
|
+
keep_val = result["keep"][1]
|
|
403
|
+
|
|
404
|
+
expected_trigger = int(max_tokens * 0.85)
|
|
405
|
+
expected_keep = int(max_tokens * 0.15)
|
|
406
|
+
|
|
407
|
+
ratio_ok = trigger_val == expected_trigger and keep_val == expected_keep
|
|
408
|
+
all_passed = all_passed and ratio_ok
|
|
409
|
+
|
|
410
|
+
print(f" {desc} (maxTokens={max_tokens}): "
|
|
411
|
+
f"trigger={trigger_val} ({trigger_val/max_tokens:.0%}), "
|
|
412
|
+
f"keep={keep_val} ({keep_val/max_tokens:.0%}) "
|
|
413
|
+
f"{'OK' if ratio_ok else 'FAIL'}")
|
|
414
|
+
|
|
415
|
+
assert all_passed, "部分阈值计算不正确"
|
|
416
|
+
print(f" 结果: PASSED")
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
# ============================================================
|
|
420
|
+
# 主入口
|
|
421
|
+
# ============================================================
|
|
422
|
+
|
|
423
|
+
async def main():
|
|
424
|
+
print(f"上下文压缩机制测试 - {time.strftime('%H:%M:%S')}")
|
|
425
|
+
|
|
426
|
+
results = {}
|
|
427
|
+
|
|
428
|
+
for name, fn in [
|
|
429
|
+
("1. monkey-patch 默认值", test_1_patched_defaults),
|
|
430
|
+
("2. middleware 配置", test_2_build_middleware_config),
|
|
431
|
+
("5. LLMConfig 兼容性", test_5_llm_config_compatibility),
|
|
432
|
+
("6. 阈值比例", test_6_threshold_ratios),
|
|
433
|
+
]:
|
|
434
|
+
try:
|
|
435
|
+
fn()
|
|
436
|
+
results[name] = True
|
|
437
|
+
except Exception as e:
|
|
438
|
+
print(f" FAILED: {e}")
|
|
439
|
+
results[name] = False
|
|
440
|
+
|
|
441
|
+
for name, fn in [
|
|
442
|
+
("3. 自动压缩触发", test_3_auto_summarization_trigger),
|
|
443
|
+
("4. ContextOverflow 兜底", test_4_context_overflow_fallback),
|
|
444
|
+
]:
|
|
445
|
+
try:
|
|
446
|
+
await fn()
|
|
447
|
+
results[name] = True
|
|
448
|
+
except Exception as e:
|
|
449
|
+
print(f" FAILED: {e}")
|
|
450
|
+
results[name] = False
|
|
451
|
+
|
|
452
|
+
print(f"\n{'='*60}")
|
|
453
|
+
print(f" 测试结果汇总:")
|
|
454
|
+
for name, passed in results.items():
|
|
455
|
+
print(f" {name}: {'PASSED' if passed else 'FAILED'}")
|
|
456
|
+
total = len(results)
|
|
457
|
+
passed = sum(1 for v in results.values() if v)
|
|
458
|
+
print(f" 总计: {passed}/{total} 通过")
|
|
459
|
+
print(f"{'='*60}")
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
if __name__ == "__main__":
|
|
463
|
+
asyncio.run(main())
|