style(delegation): metadata typing, helper banner, otel coercion note#208
Merged
Conversation
… coercion note - RoutingDecision.metadata typed as dict[str, Any] instead of Mapping; lets callers like FallbackStrategy do dict(decision.metadata) without a cast. Input-side params that accept user-supplied mappings keep Mapping. - _coerce_otel_value gets its own section banner so it doesn't read as part of WeightedStrategy. - Docstring on _coerce_otel_value notes that nested containers are not recursed element-wise — they fall through to json.dumps once.
ancongui
pushed a commit
that referenced
this pull request
May 31, 2026
style(delegation): metadata typing, helper banner, otel coercion note
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small style nits surfaced during review of #195:
RoutingDecision.metadatatyped asdict[str, Any]instead ofMapping[str, Any].FallbackStrategyalready callsdict(decision.metadata)to nest it; the concrete type lets that drop without a cast and matches whatRoutingDecision.emptyactually builds. Input-side params that accept user-supplied mappings keepMapping._coerce_otel_valuelifted to its own# -- Helpers --section so it doesn't read as part ofWeightedStrategyabove it._coerce_otel_valuedocstring notes that nested containers are not recursed element-wise — the whole value falls through tojson.dumpsonce. Documenting the limit prevents future maintainers from trying to "fix" it.No behavior change.
Test plan
pytest tests/unit/agents/test_delegation.py -q— 39 passed.ruff format --check— clean.Note: this stacks logically with #207 (which adds
Candidate.metadata); after #207 merges,Candidate.metadatashould follow the samedict[str, Any]typing — easy follow-up rebase.