Understanding how to use TMSMCPCloudAIDataSet

I have an FDTable, DataSource, TMSMCPCloudAIDataSet all hooked together. I have a TMCMCPCloudAI component hooked to the CloudAIDataSet. Working with Grok at the moment, but this applies to all of the AI's I've worked with so far.

I ask "get me the value of the classpkey field". The response I can pull from the JSON under the OnExecuted event is: I've retrieved the current record from the dataset. The record contains the following information:\n\n- classpkey: 206JHE[BTTCEYMC=\n\nIf you would like to see additional fields or move to another record, please let me know!

Looking through the logs though I see a more succinct answer. Here are the logs:

20250915T104017: Nr. of tools:12
20250915T104017: {"model": "grok-3","messages": [ {"role":"user","content":""},{"role":"user","content":"What is the value of the ClassPkey field?"} ],"tools": [ {"type": "function","function":{"name":"GetFields","description":"retrieve the fields of the dataset","parameters": {}}},{"type": "function","function":{"name":"GetTableName","description":"retrieve the name of the table for the dataset","parameters": {}}},{"type": "function","function":{"name":"GetRecords","description":"retrieve all fields or a selected number of fields from all records from the dataset","parameters": { "type":"object", "properties": {"Fields": { "type":"string", "description":""}},"required": }}},{"type": "function","function":{"name":"GetRecord","description":"retrieve all fields or a selected number of fields from the current record from the dataset","parameters": { "type":"object", "properties": {"Fields": { "type":"string", "description":""}},"required": }}},{"type": "function","function":{"name":"First","description":"set the first record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Last","description":"set the last record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Next","description":"set the next record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Previous","description":"set the previous record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Move","description":"move the active record on the dataset for a number of rows","parameters": { "type":"object", "properties": {"Number": { "type":"number", "description":"sets the number of rows to move the active record forward or backward"}},"required": ["Number"]}}},{"type": "function","function":{"name":"AddRecord","description":"add a new record with specified field values to the dataset","parameters": { "type":"object", "properties": {"FieldValues": { "type":"array", "items":{"type":"object", "properties":{"Name":{"type":"string","description":"the name of the field"},"Value":{"type":"string","description":"the value to set to the field"}},"required":["Name","Value"]}, "description":"The list of fieldnames and values to set to the record"}},"required": ["FieldValues"]}}},{"type": "function","function":{"name":"ModifyRecord","description":"modify the current record with specified field values in the dataset","parameters": { "type":"object", "properties": {"FieldValues": { "type":"array", "items":{"type":"object", "properties":{"Name":{"type":"string","description":"the name of the field"},"Value":{"type":"string","description":"the value to set to the field"}},"required":["Name","Value"]}, "description":"The list of fieldnames and values to set to the record"}},"required": ["FieldValues"]}}},{"type": "function","function":{"name":"LocateRecord","description":"locate the record with specified field values in the dataset","parameters": { "type":"object", "properties": {"FieldValues": { "type":"array", "items":{"type":"object", "properties":{"Name":{"type":"string","description":"the name of the field"},"Value":{"type":"string","description":"the value to set to the field"}},"required":["Name","Value"]}, "description":"The list of fieldnames and values to find the record"}},"required": ["FieldValues"]}}} ],"stream": false,"temperature": 0,"max_tokens": null}
20250915T104017: Executing request [datasetid] with url: [https://api.x.ai/v1/chat/completions]
20250915T104019: Result from request [datasetid] is {"id":"b933a3f2-0bd4-5157-f435-5b2dd5fef6c7_us-east-1","object":"chat.completion","created":1757958018,"model":"grok-3","choices":[{"index":0,"message":{"role":"assistant","content":"","tool_calls":[{"id":"call_69236114","function":{"name":"GetRecord","arguments":"{"Fields":"ClassPkey"}"},"type":"function"}],"refusal":null},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":799,"completion_tokens":28,"total_tokens":827,"prompt_tokens_details":{"text_tokens":799,"audio_tokens":0,"image_tokens":0,"cached_tokens":3},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0},"system_fingerprint":"fp_898ae9f31c"}
20250915T104019: Result from request [datasetid] is {"id":"b933a3f2-0bd4-5157-f435-5b2dd5fef6c7_us-east-1","object":"chat.completion","created":1757958018,"model":"grok-3","choices":[{"index":0,"message":{"role":"assistant","content":"","tool_calls":[{"id":"call_69236114","function":{"name":"GetRecord","arguments":"{"Fields":"ClassPkey"}"},"type":"function"}],"refusal":null},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":799,"completion_tokens":28,"total_tokens":827,"prompt_tokens_details":{"text_tokens":799,"audio_tokens":0,"image_tokens":0,"cached_tokens":3},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0},"system_fingerprint":"fp_898ae9f31c"}
20250915T104020: {"id":"b933a3f2-0bd4-5157-f435-5b2dd5fef6c7_us-east-1","object":"chat.completion","created":1757958018,"model":"grok-3","choices":[{"index":0,"message":{"role":"assistant","content":"","tool_calls":[{"id":"call_69236114","function":{"name":"GetRecord","arguments":"{"Fields":"ClassPkey"}"},"type":"function"}],"refusal":null},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":799,"completion_tokens":28,"total_tokens":827,"prompt_tokens_details":{"text_tokens":799,"audio_tokens":0,"image_tokens":0,"cached_tokens":3},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0},"system_fingerprint":"fp_898ae9f31c"}
20250915T104020: result after tool call:{"classpkey":"206JHE[BTTCEYMC="}
20250915T104020: tools response:{"role": "assistant", "content": null, "tool_calls":[{"id":"call_69236114","function":{"name":"GetRecord","arguments":"{}"}}]},{"role":"tool","name":"GetRecord","tool_call_id":"call_69236114","content":"{"classpkey":"206JHE[BTTCEYMC="}"}
20250915T104020: Nr. of tools:12
20250915T104020: {"model": "grok-3","messages": [ {"role":"user","content":""},{"role": "assistant", "content": null, "tool_calls":[{"id":"call_69236114","function":{"name":"GetRecord","arguments":"{}"}}]},{"role":"tool","name":"GetRecord","tool_call_id":"call_69236114","content":"{"classpkey":"206JHE[BTTCEYMC="}"} ],"tools": [ {"type": "function","function":{"name":"GetFields","description":"retrieve the fields of the dataset","parameters": {}}},{"type": "function","function":{"name":"GetTableName","description":"retrieve the name of the table for the dataset","parameters": {}}},{"type": "function","function":{"name":"GetRecords","description":"retrieve all fields or a selected number of fields from all records from the dataset","parameters": { "type":"object", "properties": {"Fields": { "type":"string", "description":""}},"required": }}},{"type": "function","function":{"name":"GetRecord","description":"retrieve all fields or a selected number of fields from the current record from the dataset","parameters": { "type":"object", "properties": {"Fields": { "type":"string", "description":""}},"required": }}},{"type": "function","function":{"name":"First","description":"set the first record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Last","description":"set the last record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Next","description":"set the next record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Previous","description":"set the previous record as active record on the dataset","parameters": {}}},{"type": "function","function":{"name":"Move","description":"move the active record on the dataset for a number of rows","parameters": { "type":"object", "properties": {"Number": { "type":"number", "description":"sets the number of rows to move the active record forward or backward"}},"required": ["Number"]}}},{"type": "function","function":{"name":"AddRecord","description":"add a new record with specified field values to the dataset","parameters": { "type":"object", "properties": {"FieldValues": { "type":"array", "items":{"type":"object", "properties":{"Name":{"type":"string","description":"the name of the field"},"Value":{"type":"string","description":"the value to set to the field"}},"required":["Name","Value"]}, "description":"The list of fieldnames and values to set to the record"}},"required": ["FieldValues"]}}},{"type": "function","function":{"name":"ModifyRecord","description":"modify the current record with specified field values in the dataset","parameters": { "type":"object", "properties": {"FieldValues": { "type":"array", "items":{"type":"object", "properties":{"Name":{"type":"string","description":"the name of the field"},"Value":{"type":"string","description":"the value to set to the field"}},"required":["Name","Value"]}, "description":"The list of fieldnames and values to set to the record"}},"required": ["FieldValues"]}}},{"type": "function","function":{"name":"LocateRecord","description":"locate the record with specified field values in the dataset","parameters": { "type":"object", "properties": {"FieldValues": { "type":"array", "items":{"type":"object", "properties":{"Name":{"type":"string","description":"the name of the field"},"Value":{"type":"string","description":"the value to set to the field"}},"required":["Name","Value"]}, "description":"The list of fieldnames and values to find the record"}},"required": ["FieldValues"]}}} ],"stream": false,"temperature": 0,"max_tokens": null}
20250915T104020: Executing request [datasetid] with url: [https://api.x.ai/v1/chat/completions]
20250915T104027: Result from request [datasetid] is {"id":"08f026d3-b58e-3823-f488-c4efa06890fb_us-east-1","object":"chat.completion","created":1757958021,"model":"grok-3","choices":[{"index":0,"message":{"role":"assistant","content":"I've retrieved the current record from the dataset. The record contains the following information:\n\n- classpkey: 206JHE[BTTCEYMC=\n\nIf you would like to see additional fields or move to another record, please let me know!","refusal":null},"finish_reason":"stop"}],"usage":{"prompt_tokens":833,"completion_tokens":51,"total_tokens":884,"prompt_tokens_details":{"text_tokens":833,"audio_tokens":0,"image_tokens":0,"cached_tokens":3},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0},"system_fingerprint":"fp_898ae9f31c"}
20250915T104027: Result from request [datasetid] is {"id":"08f026d3-b58e-3823-f488-c4efa06890fb_us-east-1","object":"chat.completion","created":1757958021,"model":"grok-3","choices":[{"index":0,"message":{"role":"assistant","content":"I've retrieved the current record from the dataset. The record contains the following information:\n\n- classpkey: 206JHE[BTTCEYMC=\n\nIf you would like to see additional fields or move to another record, please let me know!","refusal":null},"finish_reason":"stop"}],"usage":{"prompt_tokens":833,"completion_tokens":51,"total_tokens":884,"prompt_tokens_details":{"text_tokens":833,"audio_tokens":0,"image_tokens":0,"cached_tokens":3},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0},"system_fingerprint":"fp_898ae9f31c"}
20250915T104027: {"id":"08f026d3-b58e-3823-f488-c4efa06890fb_us-east-1","object":"chat.completion","created":1757958021,"model":"grok-3","choices":[{"index":0,"message":{"role":"assistant","content":"I've retrieved the current record from the dataset. The record contains the following information:\n\n- classpkey: 206JHE[BTTCEYMC=\n\nIf you would like to see additional fields or move to another record, please let me know!","refusal":null},"finish_reason":"stop"}],"usage":{"prompt_tokens":833,"completion_tokens":51,"total_tokens":884,"prompt_tokens_details":{"text_tokens":833,"audio_tokens":0,"image_tokens":0,"cached_tokens":3},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0},"num_sources_used":0},"system_fingerprint":"fp_898ae9f31c"}

Notice result after tool call:{"classpkey":"206JHE[BTTCEYMC="}

That's what I really need. A succinct answer to the question.

Here's another example where the response provided in OnExecuted is completely wrong, but KNOW they got the answer. Question: What is the value of the name field?

Answer: I'm sorry, but I must adhere to the available functions provided. If you have a specific request or need assistance with something related to the dataset, please let me know, and I can help using one of the listed functions such as GetFields, GetTableName, GetRecords, GetRecord, First, Last, Next, Previous, Move, AddRecord, ModifyRecord, or LocateRecord. What would you like to do with the dataset?

Log says: result after tool call:{"name":"OTHER"} - This is the right answer.

What am I missing? Are there other events from where I can pull the result after the tool call, and not the general response?

You'll need to add to the prompt and/or the SystemRole the desired output format.
To the prompt you could add for example: "Return the response as the string value only of the field".

Otherwise, the LLM just tries to return a nicely formatted answer.