How to retrieve object IDs mentioned by the Assistant in responses

Hello everyone!

I’m building an OpenAI-based Assistant that answers questions related to a database schema represented through metadata in JSON format. Here is an example of my data:

[
   {
      "Id": 1,
      "Name": "Workspace Foo",
      "Description": "This is a test workspace",
      "Tables": [
         {
            "Id": 1,
            "Name": "Table Foo",
            "Description": "This is a test table",
            "Columns": [
               {
                  "Id": 1,
                  "Name": "Column Foo",
                  "Type": "String",
                  "Description": "This is a test column"
               }
            ]
         }
      ]
   }
]

In my system prompt, I instruct the Assistant to answer user questions in a simple and descriptive way based on this metadata.

Now, here is my problem: I would like the Assistant, in addition to answering normally, to also retrieve and include the IDs of the objects (Workspace, Table, Column) it references in its responses.

For example, if the user asks:

“Tell me about the column ‘Column Foo’”

I would like the Assistant to respond like this:

“The column ‘Column Foo’ is of type String and is described as ‘This is a test column’. (ColumnId: 1)”

Question: How can I implement this behavior? Do I need an additional function/tool? Should I modify the system prompt, or should I manage this through internal parsing of the metadata? If you could provide a small example, that would be amazing!

Thank you so much!