Skip to content

[Bug] XMLAdapter inserting wrong markers #8875

@enitrat

Description

@enitrat

What happened?

The XMLAdapter inserts a [[ ## completed ## ]] instead of having no completion tag at all (or a tag)
Also, the User message: is formatted using ChatAdapter format for the input fields instead of XML format.

Reading the full prompt when using XMLAdapter, we see the wrong tags used:


[2025-09-30T23:08:40.684097]

System message:

Your input fields are:
1. `query` (str):
Your output fields are:
1. `answer` (str):
All interactions will be structured in the following way, with the appropriate values filled in.

<query>
{query}
</query>

<answer>
{answer}
</answer>

[[ ## completed ## ]]
In adhering to this structure, your objective is:
        Given the fields `query`, produce the fields `answer`.


User message:

[[ ## query ## ]]
when was Marie Curie born

Respond with the corresponding output fields wrapped in XML tags`<answer>`, and then end with the `<completed>` tag.


Response:

<query>
when was Marie Curie born
</query>

<answer>
Marie Curie was born on November 7, 1867.
</answer>

[[ ## completed ## ]]

Although it says Respond with the corresponding output fields wrapped in XML tags, and then end with the tag., there's no <completed> tag, instead there's a [[ ## completed ## ]] inherited from the base ChatAdapter.

Steps to reproduce

from dspy.adapters import XMLAdapter

dspy.configure(lm=dspy.LM("gemini/gemini-flash-latest", max_tokens=30000, cache=False), adapter=XMLAdapter())
prog2 = dspy.Predict("query: str -> answer: str")
prog2(query="when was Marie Curie born")
dspy.inspect_history(n=1)

output:

DSPy version

3.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions