agent-zero/tests/AGENTS.md
Alessandro b91384f4fb Upgrade LiteLLM and OpenAI with framework startup migration
Update LiteLLM to 1.104.0, OpenAI to 2.54.0, and python-dotenv to 1.2.2.
Raise shared security floors for aiohttp, anyio, urllib3, filelock, fsspec,
and multidict while retaining the compatible OpenAI 2.x SDK line.

Use the existing startup_migration hook to apply the same requirements to
v2.x Docker instances updating to v2.14. Read versions from requirements.txt,
install only when requirements are unmet, and reuse restart_process() to
load the upgraded SDKs before serving requests. Skip current and non-Docker
environments, bound installation time, and propagate installation failures.

Add installed-SDK HTTP tests for Chat Completions, Responses, streaming,
tools, state, usage, fallback, embeddings, and Anthropic cache markers.
Cover dependency migration, restart behavior, and installation failures.

Validation:
- 70 focused dependency, SDK, and self-update tests passed.
- Docker startup upgraded the v2.0-v2.13 SDK pins and became healthy in
  24 seconds, with exactly one dependency installation and process restart.
- An already-current startup performed no installation or extra restart.
- pip check passed; live Codex Responses and Moonshot Chat Completions
  tasks and follow-ups validated the upgraded SDK versions.
2026-10-07 14:50:32 +02:00

2.2 KiB

Tests DOX

Purpose

  • Own pytest regression, security, integration, and contract tests.
  • Keep tests focused on behavior that should remain stable across framework changes.

Ownership

  • Test files live directly under tests/ and are named for the behavior or subsystem they cover.
  • Shared fixtures should be added only when multiple tests need them.
  • Runtime artifacts created during tests should use pytest temporary directories or existing isolated test helpers.

Local Contracts

  • Tests must not require real API keys, network-only services, private user data, or local usr/ runtime state. Manual provider demos must guard model creation and requests behind their executable entry point so collection never runs them.
  • Keep tests deterministic and isolated from existing chats, uploads, downloads, plugin state, and settings.
  • Prefer exercising public helper/API contracts over fragile implementation details when practical.
  • Security regression tests should assert the protected behavior directly.
  • Launcher gateway tests must cover feature negotiation, authenticated and CSRF-protected control, acknowledgement timeout, identity lifecycle, context-bound CLI routing precedence, duplicate/multiple-host behavior, scope-driven availability, and emergency disconnect without a live host.

Work Guidance

  • Add focused tests near the affected subsystem's existing tests.
  • Use descriptive test names that state the regression or contract.
  • Avoid broad sleeps or real-time dependencies; use monkeypatching or controlled clocks where possible.

Verification

  • Run pytest for broad changes.
  • Run pytest tests/test_name.py for narrow changes and mention any broader test gaps at closeout.
  • Run pytest tests/test_litellm_sdk.py -q for LiteLLM/OpenAI upgrades. Its loopback provider exercises the installed SDK's sync/async calls, streaming, tool/state preservation, fallback, embeddings, and Anthropic cache markers without real keys or external requests.
  • Run pytest tests/test_framework_dependencies.py -q for dependency migration changes; verify stale self-update environments, process restart, and already-current image installs.

Child DOX Index

No child DOX files.