Function signature halluciations

This is a persistent problem, and doesn’t seem tied to any particular model.

I find that Cursor often rather just guesses at the right signature for a function call. This happens in multiple overarching contexts, with the same results every time. I try to use prompts to preempt the problem, and it still consistently fails.

I can tell it to consult the documentation for a public API, document the result of the research, and then build calls to that API based on the documentation, and it will still use incorrectly constructed calls.

I can tell it to consult the part of my own codebase where a function is defined, it will claim to have done so, and yet it will still get the function call incorrect.

The worst is when it does a refactoring, so in a single process flow it creates the underlying function and the call to that function, yet it STILL gets the function signature wrong.

This should not be some exotic thing. That it even gets it wrong when it is also creating the function tells me there is some specific mismatch internally.

Cumulatively, this is a persistent drain on productivity, since I end up playing whack-a-mole with the resultant errors.

Hey @jposner!

Sorry this has been such a frustrating experience.

I had a look in the backend, and one thing jumped out: it looks like you have a single chat that reaches all the way back to May 3rd.

That’s likely a big part of what you’re seeing. When a conversation runs that long, the agent has to keep summarizing and compressing the earlier context, and the first things to get lost tend to be exactly the details you’re describing (the precise function signatures, argument order, and types). So even when the agent reads the right file or doc, that precision can degrade as it gets folded into summary after summary.

A few things I’d suggest trying:

  1. Start new chats regularly. This is the big one. Try not to let a single conversation pile up weeks of history. Kick off a fresh chat whenever you switch tasks, or as soon as you notice the output getting subtly wrong. We really do recommend this one.

  2. Avoid switching models mid-chat. Changing models within the same agent can also hurt output quality, since each model handles the accumulated and summarized context a bit differently. Starting a fresh agent is better than swapping models in place.

  3. Use Plan mode for the bigger tasks. Especially for refactors, having the agent build a plan first and then execute it keeps the function definitions and call sites aligned, since the structure gets worked out up front instead of drifting across a long flow.

So I have tried a lot of those strategies, but even when I have one model plan a bigger task, creating detailed phased implementation plans, and then have a fresh chat session start fresh on the implementation of each of those plans, the agent will still arbitrarily skip non-optional elements of the plan document arbitrarily – and this is after I am giving it just one plan that covers a subset of the much larger scope, which will often include these very kinds of function signature mismatches.

I’m not entirely clear on how to get higher fidelity to the plan document. The document is clear. The chat session is fresh. The model does not change. The agent will just arbitrarily ignore some details while giving me a checklist showing they have implemented all the elements of the plan.