fix: widen generation function specs to match Context.normalize/2#441
Merged
mikehostetler merged 2 commits intoagentjido:mainfrom Feb 20, 2026
Merged
Conversation
The @SPEC for all 8 generation functions declared the messages parameter as `String.t() | list()`, but Context.normalize/2 accepts Context.t(), Message.t(), and map() as well. This caused Dialyzer false-positive warnings in downstream apps using Context structs (the recommended pattern). Adds a `Context.prompt()` type alias matching normalize/2's input types, and references it from all 8 specs in Generation. Closes agentjido#434
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.
Summary
Context.prompt()type alias that matches all types accepted byContext.normalize/2@specon all 8 generation functions to useContext.prompt()instead of the overly narrowString.t() | list()Context.t()structs (the recommended usage pattern)Affected functions
All 8 specs in
ReqLLM.Generation:generate_text/3,generate_text!/3stream_text/3,stream_text!/3generate_object/4,generate_object!/4stream_object/4,stream_object!/4The
Context.prompt()typeThis exactly mirrors the spec on
Context.normalize/2(lines 103-110 of context.ex).Precedent
Same class of fix as PR #301 which widened the
object_schemaparameter spec forgenerate_object.Test plan
mix compile --warnings-as-errorspasses (zero warnings)Context.prompt()type matchesContext.normalize/2spec exactlyCloses #434