Facing citation issue in summary

I have an internal API where the input is a query, and it returns an ID, chunk, and URL. I wrote a function around this API that returns the output as a dictionary, which I use as a tool in an agent. The agent uses this information to return a summary with citations in the form [1][2].

I already instructed well in the prompt.

However, sometimes the model cites the wrong ID in the answer. How should I handle such scenarios? Which tool output format would be best for the agent to ensure correct citations? Can anyone suggest a good output format for the tool call so that citation issues can be avoided?

Can you give more insights? I’d always go with json. like:

{
  "results": [
    {
      "ref": "[1]",
      "id": "abc123",
      "url": "https://example.com/doc1",
      "chunk": "This is the relevant extracted text from document 1."
    },
    {
      "ref": "[2]",
      "id": "def456",
      "url": "https://example.com/doc2",
      "chunk": "Another relevant passage from document 2."
    }
  ]
}