Repository navigation
fix: address whole-SDK review findings for 0.2.0 - #5
Merged
Merged
Conversation
Make rules required on Policies.create and AsyncPolicies.create (and inherited Metrics/AsyncMetrics) and raise ValueError when rules is empty, matching the API which rejects omitted or empty rules with HTTP 400. BREAKING CHANGE: policies.create() and metrics.create() now require a non-empty rules sequence.
Add optional role: Role | None = None to Event.tool_call, tool_result, tool_definition, and agent so callers can override Policy direction on non-message Events without dropping down to raw Event(...).
Raise WebhookVerificationError with 'from None' instead of chaining the raw pydantic.ValidationError so webhook payload content is not leaked into formatted tracebacks. Assert __cause__ is None and formatted tracebacks omit payload values.
…ent usage and user properties Define local variables with simple literals in cookbook snippets (and type openai_tokens in docs/streaming.md), replace wrapped /api/usage in README.md with a placeholder path, document client.billing.usage() in docs/usage.md, and document client.users.properties in docs/strikes-and-webhooks.md.
Expose optional trace_id and span_id parameters from ArtifactCheckRequest on Artifacts.check and AsyncArtifacts.check.
…ect timeout
Reset _ws to None in EventStream.close and AsyncEventStream.close so
post-close append/finish/receive raise WhiteCircleError instead of
silently dropping frames; catch WebSocketInvalidTypeReceived and raise
StreamError('invalid_frame', ...); honor the client read timeout while
waiting for ready in connect().
…es in is_in/not_in Return NotImplemented when Expression.__and__ receives a non-Expression operand so Python raises TypeError instead of AttributeError, and reject bare str/bytes values in Field.is_in and Field.not_in both statically and at runtime.
Restrict Event.reference to non-reset SelectorType values (raising ValueError at runtime on 'reset') and default UserRisk.total_strike_points to 0 and UserRisk.strikes to [] to match UserRiskResponse in OpenAPI.
…and async retries
Add unit tests for country_codes/severity_level_id on create,
event_selector_list/country_codes on update, metrics delete/get/list,
shadow-only EventCheckResult.checked, client.events.stream/check_stream
wiring, AsyncCheckedStream async-generator aclose(), path_param(''), and
async GET 502/504, 429 backoff, and ConnectError retries. Avoid awaiting
sync stream()/check_stream() methods in test_events_require_an_environment.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Document that tool/arguments defaults to the user side (so role_list=[] or ['user'] judges it as is) and recommend passing role='assistant' on Event.tool_call(...) so an assistant-only Policy judges an agent's own tool calls. Update CHANGELOG.md and extend test_tool_arguments_targeting to verify the role='assistant' override live.
…fallback Only fall back to EventSelector.model_construct when field and kind are None or str, so malformed items with non-string field or kind raise ValidationError. Add parametrized tests covering malformed selector items.
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.
Stacked on
feature/policy-targeting(#4). Addresses the remaining findings from the whole-SDK review (finding 2 landed directly onfeature/policy-targetingin20d2e74).c55073arulesonpolicies.create()andmetrics.create()(sync and async) +CHANGELOG.mdbreaking-change notecd84334role=onEvent.tool_call,tool_result,tool_definition, andagent0f3c7bcWebhookVerificationErrorwithfrom NoneinWebhooks.parseso raw payload values cannot leak via__cause__tracebacks79c84d1/api/usageraw-request example inREADME.md, and documentclient.billing.usage()andclient.users.properties475527btrace_idandspan_idonartifacts.check()(sync and async)b359ca0_wson streamclose(), wrap binary WebSocket frames asStreamError("invalid_frame", ...), and honor client read timeout while waiting forreadyinconnect()d96178fBodytype alias from_types.pyde7596cNotImplementedinExpression.__and__on non-Expressionoperands and reject barestr/bytesinField.is_in/not_in252747e"reset"inEvent.referenceand defaultUserRisk.total_strike_points = 0andstrikes = []1330133checked,client.events.stream/check_streamwiring,AsyncCheckedStreamasync-generatoraclose(),path_param(""), and async retries