Fix instruction_first kwarg silently dropped in (a)run_instructor_with_payload - #827
Draft
Osamaali313 wants to merge 1 commit into
Draft
Conversation
`run_instructor_with_payload` and `arun_instructor_with_payload` construct
a `MessagesBuilder` with `instructions_first=instructions_first`, but
`MessagesBuilder`'s field is named `instruction_first` (no trailing "s"):
# utils/message_builder.py
instruction_first: bool = Field(default=True)
...
if self.instruction_first:
`MessagesBuilder` is a pydantic model, so under the default `extra="ignore"`
the misspelled `instructions_first=` kwarg is silently discarded and
`instruction_first` stays at its default `True`. The caller's value never
takes effect — e.g. `LiteLLMChatRuntime.record_to_record`
(runtimes/_litellm.py) passes `instructions_first=False`, but the
instruction/system message is still placed first.
The two sibling functions in the same module,
`run_instructor_with_payloads` and `arun_instructor_with_payloads`, already
use the correct field name `instruction_first=instructions_first`. Align
the two singular functions with them.
robot-ci-heartex
marked this pull request as draft
July 17, 2026 07:42
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.
Problem
run_instructor_with_payloadandarun_instructor_with_payload(adala/utils/llm_utils.py) build aMessagesBuilderwith the kwarginstructions_first=:But
MessagesBuilder's field isinstruction_first(no trailing "s"):MessagesBuilderis a pydantic model, so under pydantic's defaultextra="ignore"the misspelledinstructions_first=kwarg is silently discarded, andinstruction_firstkeeps its defaultTrue. The caller's value has no effect.Impact
run_instructor_with_payloadis called byLiteLLMChatRuntime.record_to_record(adala/runtimes/_litellm.py), which forwardsinstructions_first(its own default isFalse). Because the kwarg is dropped, the instruction/system message is always placed first regardless of what the runtime requests.arun_instructor_with_payloadis an exported async util with the same defect.Evidence (sibling proves intent)
The two plural siblings in the same module already pass the correct field name:
Only the two singular functions use the typo.
Reproduction
Caller requests
instructions_first=False; observe message roles:instructions_first=)['system', 'user']— instruction forced first ❌instruction_first=)['user']— request honored ✅Fix
Use the correct field name in both functions: