-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(qa): prevent grader truncation #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,10 @@ | |
| from api.services.workflow.dto import QANodeData | ||
|
|
||
| QA_USAGE_CONTEXT = "qa_analysis" | ||
| # Explicit output ceiling for QA grader inference. Google/Anthropic default to | ||
| # 4096 output tokens (shared with dynamic thinking on Gemini), truncating long | ||
| # grading JSON. A generous ceiling + bounded thinking lets a full grade complete. | ||
| QA_MAX_OUTPUT_TOKENS = 16384 | ||
|
|
||
|
|
||
| async def create_qa_llm_service( | ||
|
|
@@ -47,6 +51,7 @@ async def create_qa_llm_service( | |
| api_key, | ||
| correlation_id=correlation_id, | ||
| usage_context=QA_USAGE_CONTEXT, | ||
| max_tokens=QA_MAX_OUTPUT_TOKENS, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: max_tokens is threaded unconditionally from the QA path for every provider, but create_llm_service_from_provider only honors it in the GOOGLE branch (service_factory.py ~1005). The GOOGLE_VERTEX and Anthropic branches accept the new parameter and silently ignore it. The comment added next to QA_MAX_OUTPUT_TOKENS explicitly notes that Anthropic also defaults to 4096 output tokens, so an Anthropic (or Vertex) QA grader will still hit the same mid-object truncation that this PR is fixing, while the caller believes a generous ceiling was requested. Consider applying the output ceiling on the Anthropic branch (and Vertex if it shares the same cap) or scoping the QA flag to the provider actually covered, so the fix is not silently ineffective for other providers. Prompt for AI agents |
||
| **kwargs, | ||
| ) | ||
| return llm, model | ||
|
|
@@ -75,6 +80,7 @@ async def create_qa_llm_service( | |
| model_override, | ||
| correlation_id=correlation_id, | ||
| usage_context=QA_USAGE_CONTEXT, | ||
| max_tokens=QA_MAX_OUTPUT_TOKENS, | ||
| ) | ||
| return llm, model | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.