fix(agno): remove pydantic runtime dependency#221
Conversation
f4b9505 to
3ac94d8
Compare
ralf0131
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Removes the hard pydantic runtime dependency from loongsuite-instrumentation-agno by replacing the isinstance(value, BaseModel) type check with duck-typing via getattr(value, "model_dump", None). Includes a CHANGELOG entry and a focused regression test.
Findings
- [Info]
utils.py— The duck-typing approach is the right call: it avoids pullingpydantic-corewheels into environments where Agno itself is not installed, while still serializing Pydantic-style objects correctly viamodel_dump(mode="json")with aTypeErrorfallback for older Pydantic versions that lack themodeparameter. - [Info]
pyproject.toml— Clean removal; movingpydantictotestdeps (already present) is correct.
Tests
Comprehensive coverage: content_capture_mode_does_not_gate_span_creation proves span creation works without content capture, and the test_convert_value_with_pydantic_model_dump test verifies the duck-typing serialization path.
LGTM. Clean dependency-isolation fix with good test coverage.
Automated review by github-manager-bot
|
Thanks for the review. I checked the failing CI. Both failures are from
Both are I also reproduced the same failure locally with
I plan to keep this PR scoped to Agno dependency isolation. If maintainers require a fully green PR despite this pre-existing repo-wide typecheck failure, I can prepare a separate VertexAI cleanup or follow up after that fix lands. |
Description
This PR removes the direct
pydanticruntime dependency fromloongsuite-instrumentation-agnoand adds an Agno-side regression test proving that message-content capture mode does not gate span creation.origin/mainalready has the Agno 2.x instrumentation migrated toopentelemetry-util-genaiind741321e feat(agno): adapt instrumentation for Agno 2. This PR is the remaining dependency-isolation and regression-test follow-up on top of that migration. The residual issue is that the Agno instrumentation package still declarespydanticas a normal dependency and directly importsBaseModel, which can make probe installation or pre-cache environments pull Python-ABI-specificpydantic-corewheels even when the target application has not installed Agno.The change keeps support for Pydantic-style objects by using
model_dump()duck typing instead of importingpydantic.BaseModel, and adds a focused test for that conversion path.Fixes # (N/A; no public issue)
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
python3 <loongsuite-github-pipeline>/scripts/check_loongsuite_pr_readiness.py --repo .tox -e precommittox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-agnotox -c tox-loongsuite.ini -e lint-loongsuite-instrumentation-agnotox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-agno -- -k content_capture_mode_does_not_gate_span_creationMETADATA; normal runtime dependencies no longer includepydantic,pydantic-core, oragno.Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
Validation Evidence
Spec and Scope
opentelemetry-util-genaionorigin/mainviad741321e feat(agno): adapt instrumentation for Agno 2.loongsuite-instrumentation-agnodependency metadata, Agno serialization utility, and focused tests.origin/mainat PR preparation time.Local Checks
python3 <loongsuite-github-pipeline>/scripts/check_loongsuite_pr_readiness.py --repo .tox -e precommittox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-agno -- -k content_capture_mode_does_not_gate_span_creationNO_CONTENTstill create AGENT/LLM spans while omitting message content attributes.tox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-agnotox -c tox-loongsuite.ini -e lint-loongsuite-instrumentation-agnouv build --wheel --out-dir <tmpdir>/loongsuite-agno-rebased-dist instrumentation-loongsuite/loongsuite-instrumentation-agnoRequires-Distcontains OTel/util-genai/wrapt only; Agno remains in extras.agno,pydantic, andpydantic_corewere absent; Agno instrumentor import andmodel_dump()duck typing succeeded.CI