Skip to content

GenAI config labels loss#2005

Merged
jxnl merged 2 commits intomainfrom
cursor/567-269-genai-config-labels-loss-0687
Jan 16, 2026
Merged

GenAI config labels loss#2005
jxnl merged 2 commits intomainfrom
cursor/567-269-genai-config-labels-loss-0687

Conversation

@jxnl
Copy link
Collaborator

@jxnl jxnl commented Jan 16, 2026

fix(genai): preserve config labels from dict config

Describe your changes

This PR resolves an issue where GCP billing/monitoring labels and cached_content were discarded or incorrectly handled when the config parameter was provided as a dictionary in Google GenAI provider functions. This was blocking enterprise usage due to tracking issues.

The changes update update_genai_kwargs, handle_genai_structured_outputs, and handle_genai_tools to correctly merge labels, cached_content, automatic_function_calling, and thinking_config from both dictionary-style and object-style config parameters. This ensures all relevant configuration fields are preserved and applied as intended, and cached_content correctly suppresses system_instruction and tool definitions when active.

New regression tests have been added to verify label preservation and cached content behavior for dictionary-style configs.

Issue ticket number and link

Linear: 567-269
GitHub: #1759

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • If it is a core feature, I have added documentation.

Linear Issue: 567-269

Open in Cursor Open in Web


Important

Fixes GenAI config handling to preserve labels and cached_content when provided as a dictionary, ensuring correct merging of configuration fields.

  • Behavior:
    • Fixes issue where labels and cached_content were discarded when config was a dictionary in update_genai_kwargs, handle_genai_structured_outputs, and handle_genai_tools.
    • Ensures labels, cached_content, automatic_function_calling, and thinking_config are merged from both dictionary and object-style config.
    • cached_content suppresses system_instruction and tool definitions when active.
  • Tests:
    • Adds regression tests in test_genai_config_merging.py to verify label preservation and cached content behavior for dictionary-style configs.
    • Tests ensure thinking_config, automatic_function_calling, and labels are correctly extracted and do not override existing base config values.

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

cursoragent and others added 2 commits January 16, 2026 17:25
Co-authored-by: jason <jason@jxnl.co>
Co-authored-by: jason <jason@jxnl.co>
@cursor
Copy link

cursor bot commented Jan 16, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
instructor eb5f85a Commit Preview URL

Branch Preview URL
Jan 16 2026, 05:28 PM

@github-actions github-actions bot added bug Something isn't working enhancement New feature or request python Pull requests that update python code labels Jan 16, 2026
@jxnl jxnl marked this pull request as ready for review January 16, 2026 17:37
@jxnl jxnl merged commit b31ffee into main Jan 16, 2026
17 checks passed
@jxnl jxnl deleted the cursor/567-269-genai-config-labels-loss-0687 branch January 16, 2026 17:37
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 eb5f85a in 1 minute and 14 seconds. Click for details.
  • Reviewed 221 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 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:332
  • Draft comment:
    Good change: the extraction of thinking_config now supports both dicts and objects. Consider abstracting this extraction (and similar extraction for labels and cached_content) into a helper to reduce duplication.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 85% None
2. instructor/providers/gemini/utils.py:355
  • Draft comment:
    The merging logic for 'automatic_function_calling', 'labels', and 'cached_content' now properly handles both dict and object styles. Consider DRYing up the repeated extraction by using a helper function.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 85% None
3. instructor/providers/gemini/utils.py:890
  • Draft comment:
    In handle_genai_structured_outputs, extraction of thinking_config and cached_content now handles dict inputs correctly. The updated comments are clear.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None
4. instructor/providers/gemini/utils.py:970
  • Draft comment:
    Similarly, handle_genai_tools now correctly extracts config fields from dict or object. Consider refactoring this common logic into a shared helper to keep the code DRY.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 85% None
5. tests/test_genai_config_merging.py:402
  • Draft comment:
    Excellent and comprehensive tests covering both object and dict configs, including labels, cached_content, and thinking_config. They clearly validate the merged configuration behavior (issue #1759).
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 85% None

Workflow ID: wflow_SGnig1h19DTyKTZY

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

cursor bot pushed a commit that referenced this pull request Jan 16, 2026
Update CHANGELOG for PRs #2000, #2002, #2005, #2007, and #2011.

Co-authored-by: jason <jason@jxnl.co>
@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

bug Something isn't working enhancement New feature or request python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants