Repository navigation
Conversation
A ReAct loop that ends with submit and whose tools the provider holds natively parses nothing from the text the model writes, yet its system message carried DSPy's full layout: field lists, a [[ ## name ## ]] template with placeholders ending [[ ## completed ## ]], and "In adhering to this structure, your objective is:". Some models read that scaffold as the harness of a graded test. The Chat adapter now gives that loop the program's instructions first, as written; the parts of each message with their descriptions; that text the model writes is not sent and stays as its own note; how to finish, with each output's description; and the tools. A host's agent_line follows the instructions; the default line is left out. Demos and stored turns show the thought as plain text. Written-call loops, finish: :tools loops, plain-text-answer loops and the JSON and XML adapters are unchanged.
This branch has not been deployed
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.
What
Imp.Adapter.Chatnow gives a ReAct loop that ends withsubmit, and whose tools the provider holds natively, a plain system message in place of DSPy's layout.The condition is exact: the loop's guidance names a finish tool (
submit_toolset, nofinish_tools), and the step's tool-calls output was taken out of the request because the LM calls tools natively (Imp.Predict), so the step's only output is its text field. Unchanged: loops whose model writes its tool calls as text (their reply is parsed from the markers),finish: :toolsloops, plain-text-answer loops, and the JSON and XML adapters.Why
In that loop nothing is parsed from the text the model writes: the reply is read whole as the step's text output (
metadata[:text_field]), and the answer is whatsubmitcarries. Yet the system message carried the input and output field lists, a[[ ## name ## ]]template with{placeholders}ending[[ ## completed ## ]], and "In adhering to this structure, your objective is:" with the instructions indented under it. Some models read that scaffold as the harness of a graded test and said so in their reasoning, quoting those lines as the graders' instructions.Before and after
For
Imp.react("intent -> answer, confidence: float", [look]):Before:
After:
Details:
Imp.Adapter.Instructions.plain_text/1).agent_linestring follows the instructions;nilleaves it out as before.[[ ## next_thought ## ]]and[[ ## completed ## ]]markers, as the native history already does. A system message that describes no markers should not be followed by demos that use them.submit, a step's text is recorded and replayed as the model's own message, and a thought-only step is followed by the existing unsent note.Measurement
A single-step A/B on 41 real first requests of a deployed application built on Imp, across 10 model families on OpenRouter. Only the system message differed; the new one was rendered by this branch from the same signature (the parsed signature rendered on
mainreproduces each original system message byte for byte). One completion per request per arm, two samples per arm, no tools executed.Tests
test/react_v2_request_shape_test.exs: the exact new layout; the agent line override andnil; a written-call loop keeps DSPy's layout and words.test/react_v2_step_contract_test.exs: withsubmit, a demo and a stored step are replayed as plain text.test/react_v2_plain_text_answer_test.exs: updated for the submit case.main. The adapter, ReAct, history, GEPA and documentation test files pass.Docs:
docs/diving-deeper/react.md,docs/diving-deeper/adapters.md, CHANGELOG (Unreleased).