Skip to content

Conversation

@drdraad
Copy link

@drdraad drdraad commented Jan 15, 2026

Describe your changes
Preserve GenAI response metadata (e.g. thought_signature) across validation retries in GENAI_TOOLS by replaying the model Content and then adding a tool function_response with validation errors.
Add targeted tests covering the GENAI reask path (unit) and a minimal end-to-end validation retry check (LLM-gated).

Issue ticket number and link
N/A

Checklist before requesting a review
[x] I have performed a self-review of my code
[x] If it is a core feature, I have added thorough tests.
[x] If it is a core feature, I have added documentation.

Test plan:
test_genai_reask.py
test_reask.py


Important

Enhances reask_genai_tools to preserve thought_signature during validation retries and adds tests for comprehensive coverage.

  • Behavior:
    • reask_genai_tools in utils.py now preserves thought_signature by replaying model content and adding tool function responses with validation errors.
    • Handles cases where function calls are absent or not the first part.
  • Tests:
    • Adds test_reask.py to test reask_genai_tools for preserving thought_signature, handling absent function calls, and processing None responses.
    • Adds test_genai_reask.py for end-to-end validation retry checks in GENAI_TOOLS mode.
  • Misc:
    • Removes unused imports from audit_patterns.py, check_links.py, and validate_meta_tags.py.

This description was created by Ellipsis for f10c1a1. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to f10c1a1 in 1 minute and 5 seconds. Click for details.
  • Reviewed 271 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. instructor/providers/gemini/utils.py:681
  • Draft comment:
    The shallow copying of the 'contents' list is clear, but consider if a deep copy might be needed for nested mutable objects in future modifications.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 85% None
2. instructor/providers/gemini/utils.py:693
  • Draft comment:
    Inside the loop iterating over candidates, the selection of 'function_call' and 'function_call_content' is clear. Adding a brief inline comment to explain the selection logic could improve future maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 85% None
3. instructor/providers/gemini/utils.py:718
  • Draft comment:
    In the branch where no function_call is found, the code appends the model content (if available) and a user message with the error. A comment explaining why this fallback is chosen would benefit future readers.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 85% None
4. instructor/providers/gemini/utils.py:730
  • Draft comment:
    When a function_call is found, the tool response is appended while preserving the original thought_signature. This behavior is validated by tests; ensure that any future changes maintain this preservation.
  • Reason this comment was not posted:
    Confidence changes required: 20% <= threshold 85% None
5. scripts/audit_patterns.py:15
  • Draft comment:
    Removed the unused 'Set' import from typing. This cleanup improves code clarity.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None
6. scripts/check_links.py:12
  • Draft comment:
    The removal of 'defaultdict' from the imports is appropriate since it's not used in this file.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None
7. scripts/fix_old_patterns.py:14
  • Draft comment:
    Simplified type hints by removing unused types (e.g. Dict) from the imports. This reduces clutter in the code.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None
8. scripts/validate_meta_tags.py:15
  • Draft comment:
    Removed the unused 'Set' import from typing to keep the import list clean.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None
9. tests/llm/test_genai/test_reask.py:7
  • Draft comment:
    The test for GENAI_TOOLS validation retry is well-structured and clearly verifies that the retry mechanism triggers the expected InstructorRetryException with the correct number of attempts.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None
10. tests/test_genai_reask.py:12
  • Draft comment:
    The newly added tests effectively validate reask_genai_tools behavior, including preservation of thought_signature, proper fallback when response is None, and handling cases with no function call. This provides comprehensive coverage.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None

Workflow ID: wflow_vSPZ3odDPSOVjFeD

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@jxnl
Copy link
Collaborator

jxnl commented Jan 16, 2026

@cursoragent can you update the change log and review this

@jxnl jxnl mentioned this pull request Jan 16, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants