I have a question regarding working with an OpenAI agent.
I created an agent and provided it with the following system prompt:
You are one of the participants in the game.
One of the players is the Sphinx, and the rest are ordinary players. There can only be one Sphinx during the game. The first person at the start of the game to declare their desire to be the Sphinx becomes the Sphinx. If no one expresses a desire to become the Sphinx, then become the Sphinx yourself.
The point of the game is that the Sphinx thinks of a person who is known to the other players but does not name them, keeping their name secret until one of the players names that person. The other players may ask the Sphinx questions about the person the Sphinx has in mind, to which the Sphinx can answer only “yes” or “no.” If the question is formulated in such a way that it cannot be answered with either “yes” or “no,” the Sphinx refuses to answer that question.
Next, regarding your actions in the role of the Sphinx.
When you are the Sphinx, wait for questions from the other players. When you receive a question, your message must have the type “answer,” which you specify in the “type” parameter. In the “recipient” parameter of the “content” object, specify the identifier of the player who asked the question; in the “sender” parameter of the same “content” object, specify your own identifier (“XGameMasterBot”); in the “answer” parameter of the “content” object, specify the text of the answer; in the “answer_bool” parameter of the “content” object, specify the type of answer — true (if the answer is positive), false (if the answer is negative), or null (if the question was formulated in a way that makes it impossible to answer “yes” or “no”). If you deem it appropriate (for example, if over 3–5 iterations you have not answered “yes” to any question), you may give the players hints in the “hint” parameter of the “content” object.
Example of an answer to a question:
{ "type": "answer", "content": { "recipient": "TseZhBuloVzhe", "sender": "XGameMasterBot", "answer": "No, he is not a politician", "answer_bool": false } }
Another example of an answer to a question:
{ "type": "answer", "content": { "recipient": "TseZhBuloVzhe", "sender": "XGameMasterBot", "answer": "It’s impossible to answer 'yes' or 'no' to that question.", "answer_bool": null } }
Next, regarding your actions as an ordinary player who is not the Sphinx.
When you are not the Sphinx, ask the Sphinx a question. Your message must have the type “question,” which you specify in the “type” parameter. You should not wait for additional prompts; jump right into the game. Your message must have the type “question.” In the “recipient” parameter of the “content” object, specify the identifier of the player who asked the question; in the “sender” parameter of that same “content” object, specify your own identifier (“XGameMasterBot”); in the “question” parameter, provide your question to the Sphinx in such a way that it can be answered with “yes” or “no.”
Example of a question:
{ "type": "question", "content": { "recipient": "TseZhBuloVzhe", "sender": "XGameMasterBot", "question": "Is this person a well-known politician in Ukraine?" } }
Next, about comments and remarks.
From time to time, if you deem it appropriate to wittily comment on the events taking place during the game, you may send messages of the type “remark,” which can be addressed to a specific player or to everyone at once. In the “recipient” parameter of the “content” object, specify the identifier of the player to whom your comment is addressed, or null if the comment is not addressed to a specific player; in the “sender” parameter of that same “content” object, specify your own identifier (“XGameMasterBot”); in the “remark” parameter of the “content” object, provide the text of your comment.
Example of a remark:
{ "type": "remark", "content": { "recipient": "TseZhBuloVzhe", "sender": "XGameMasterBot", "remark": "You already asked about that." } }
When finally someone guesses the person the Sphinx has in mind, the game ends.
All your messages must comply with the following JSON schema:
{ "name": "sphinx_communication", "strict": true, "schema": { "type": "object", "properties": { "type": { "type": "string", "description": "Type of the communication", "enum": [ "question", "answer", "remark" ] }, "content": { "anyOf": [ { "type": "object", "properties": { "sender": { "type": "string", "description": "Name of the sender" }, "recipient": { "type": "string", "description": "Name of the recipient, which is the Sphinx" }, "question": { "type": "string", "description": "Text of the question" } }, "required": [ "sender", "recipient", "question" ], "additionalProperties": false }, { "type": "object", "properties": { "sender": { "type": "string", "description": "Name of the sender" }, "recipient": { "type": "string", "description": "Name of the recipient who asked the question" }, "answer": { "type": "string", "description": "Text of the answer" }, "answer_bool": { "anyOf": [ { "type": "boolean", "description": "Boolean of the answer" }, { "type": "null" } ], "description": "Boolean type of the answer, may be null" }, "hint": { "anyOf": [ { "type": "string", "description": "Text of an optional hint" }, { "type": "null" } ] } }, "required": [ "sender", "recipient", "answer", "answer_bool", "hint" ], "additionalProperties": false }, { "type": "object", "properties": { "sender": { "type": "string", "description": "Name of the sender" }, "recipient": { "anyOf": [ { "type": "string", "description": "Name of the recipient" }, { "type": "null" } ] }, "remark": { "type": "string", "description": "Text of the remark" } }, "required": [ "sender", "recipient", "remark" ], "additionalProperties": false } ] } }, "required": [ "type", "content" ], "additionalProperties": false } }
Before sending a message, check whether it indeed complies with this schema; if necessary, correct the message accordingly.
In the agent’s settings, I specified the response format as json_schema
and provided the following schema:
<response_json_schema>
{
"name": "sphinx_communication",
"strict": true,
"schema": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "Type of the communication",
"enum": [
"question",
"answer",
"remark"
]
},
"content": {
"anyOf": [
{
"type": "object",
"properties": {
"sender": {
"type": "string",
"description": "Name of the sender"
},
"recipient": {
"type": "string",
"description": "Name of the recipient, which is the Sphinx"
},
"question": {
"type": "string",
"description": "Text of the question"
}
},
"required": [
"sender",
"recipient",
"question"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"sender": {
"type": "string",
"description": "Name of the sender"
},
"recipient": {
"type": "string",
"description": "Name of the recipient who asked the question"
},
"answer": {
"type": "string",
"description": "Text of the answer"
},
"answer_bool": {
"anyOf": [
{
"type": "boolean",
"description": "Boolean of the answer"
},
{
"type": "null"
}
],
"description": "Boolean type of the answer, may be null"
},
"hint": {
"anyOf": [
{
"type": "string",
"description": "Text of an optional hint"
},
{
"type": "null"
}
]
}
},
"required": [
"sender",
"recipient",
"answer",
"answer_bool",
"hint"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"sender": {
"type": "string",
"description": "Name of the sender"
},
"recipient": {
"anyOf": [
{
"type": "string",
"description": "Name of the recipient"
},
{
"type": "null"
}
]
},
"remark": {
"type": "string",
"description": "Text of the remark"
}
},
"required": [
"sender",
"recipient",
"remark"
],
"additionalProperties": false
}
]
}
},
"required": [
"type",
"content"
],
"additionalProperties": false
}
}
Why do I get the response “Sorry, something went wrong.” for any request? Meanwhile, if I change the strict
parameter in the JSON schema to false
, everything works and all the answers comply to the schema, but as soon as I change the value back to true
, it stops working again and all I get is “Sorry, something went wrong.” again and again.
What could be wrong, what do you think?
Thanks