Moving from httpx to aiohttp - dev branch#729
Draft
alice-cohere wants to merge 4 commits intomainfrom
Draft
Conversation
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.
Worked on this with Sonnet 4.5 in Cursor. My prompt
Model plan:
name: Refactor validator return values
overview: Extend ValidationDecision to capture all information from validator LLM calls, ensuring both should_trigger_tool and is_compliant (plus detailed labels) are always populated when available, minimizing redundant validator calls.
todos:
content: Extend ValidationDecision dataclass with semantic fields (should_trigger_tool, is_compliant, is_refusal, abuse_areas, severities)
status: completed
content: Modify _get_decision_from_llm_judge to return metadata dict with all computed values
status: completed
content: Update all validator methods (should_call_safety_content, content_tool_oracle, evaluate_completion_compliance, evaluate_is_refusal) to populate new fields
status: completed
content: Update oracle functions to store and reuse all validator outputs from ValidationDecision
status: completed
content: Update tool_validation.py functions to leverage cached values
status: completed
content: Update conversation_validation.py to use new semantic fields
status: completed
isProject: false
Refactor Validator to Return Complete Information
Overview
Currently, validator methods discard valuable information computed during LLM calls. When calling the validator LLM for safety classification, we get
predict_safety_related,predict_abuse_areas, andpredict_severities, but different methods only return subsets of this data. This refactor ensures all available information is captured and returned.1. Extend ValidationDecision Dataclass
File:
[bee/comb/comb/envs/safety/validator/safety_validator.py](bee/comb/comb/envs/safety/validator/safety_validator.py)Add optional semantic fields to
ValidationDecision(lines 32-42):2. Modify
_get_decision_from_llm_judgeto Return All InformationFile:
[bee/comb/comb/envs/safety/validator/safety_validator.py](bee/comb/comb/envs/safety/validator/safety_validator.py)Update the return signature (line 337) from:
To:
The new dict will contain:
should_trigger_tool: bool | Noneis_compliant: bool | Noneis_refusal: bool | Noneabuse_areas: list | Noneseverities: list | NoneModify the method to:
predict_safety_related,predict_abuse_areas,predict_severitiesthroughout3. Update Validator Methods to Populate All Fields
File:
[bee/comb/comb/envs/safety/validator/safety_validator.py](bee/comb/comb/envs/safety/validator/safety_validator.py)should_call_safety_content(lines 162-205)_get_decision_from_llm_judgeshould_trigger_tool,is_compliant,abuse_areas,severitiesdecisionasshould_trigger_toolfor backward compatibilitycontent_tool_oracle(lines 298-326)_get_decision_from_llm_judgeshould_trigger_tool,is_compliant,abuse_areas,severitiesdecisionasis_compliantfor backward compatibilityevaluate_completion_compliance(lines 207-244)should_trigger_tool,is_compliant,abuse_areas,severitiesdecisionasis_compliantevaluate_is_refusal(lines 246-262)is_refusal, and alsoshould_trigger_tool/abuse_areas/severitiesif computeddecisionasis_refusalevaluate_is_reasoning_consistent(lines 264-296)decision(no additional semantic fields applicable)4. Update Oracle Functions to Use New Fields
File:
[bee/comb/comb/envs/safety/agent_env/rollout_validation/oracles.py](bee/comb/comb/envs/safety/agent_env/rollout_validation/oracles.py)Update functions that retrieve and store validator outputs:
tool_call_decision_oracle(lines 369-493)should_trigger_toolANDis_compliantstate.validator_outputsas separate keys or nested structuretool_result_oracle(lines 496-559)is_compliantis already available from previous callsshould_trigger_toolandis_compliantshould_be_refusal_oracle(lines 281-332)completion_safety_compliance(lines 192-278)5. Update Tool Validation Functions
File:
[bee/comb/comb/envs/safety/agent_env/rollout_validation/tool_validation.py](bee/comb/comb/envs/safety/agent_env/rollout_validation/tool_validation.py)postprocess_first_tool_turn(lines 298-427)postprocess_tool_results_on_the_fly(lines 221-295)postprocess_all_tool_calls(lines 15-218)6. Update Conversation Validation
File:
[bee/comb/comb/envs/safety/agent_env/rollout_validation/conversation_validation.py](bee/comb/comb/envs/safety/agent_env/rollout_validation/conversation_validation.py)postprocess_overall_conversation(lines 13-124)Key Implementation Details
decisionfield unchanged so existing code continues to workstate.validator_outputswith clear keys_get_decision_from_llm_judge, compute all derivable values before returningpredict_safety_related,predict_abuse_areas, andpredict_severities, we can computeis_compliantusing the same logic currently in the compliance query pathTesting Considerations
main()function in safety_validator.py (lines 495-661) should be updated to verify all fields are populatedstate.validator_outputsstructure properly stores and retrieves all semantic fields