#10529·dspy

[Bug] Signature.insert/prepend/append silently drops a field whose name exists in the other section

Author: jayzuccarelliCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbug

What happened?

dspy.ChainOfThought("reasoning, question -> answer") ends up with the signature question -> reasoning, answer: the user's reasoning input is gone. At call time it only logs that reasoning isn't in the signature and is ignored, so the LM never sees it. Same with Signature("question -> answer").append("answer", InputField()), which silently drops the new input.

String signatures already reject this (Signature("reasoning, question -> reasoning, answer") raises "distinct names", added in #9432), but insert() merges both sections through a dict, so a name from the other section just collapses. Reproduced on 3.4.0 with DummyLM.

I have a small fix (raise the same error in insert() when the name exists in the other section; same-section replacement unchanged) and will open a PR.

Steps to reproduce

  1. dspy.ChainOfThought("reasoning, question -> answer") and inspect its signature: it is question -> reasoning, answer (the reasoning input is gone).
  2. dspy.Signature("question -> answer").append("answer", dspy.InputField()): the new input is silently dropped instead of raising.
  3. For comparison, dspy.Signature("reasoning, question -> reasoning, answer") raises "distinct names".

DSPy version

3.4.0

Found with AI assistance (Claude Code); I verified the repro.