# Function-call included in content, not in \`function\_call\` response param

**URL:** <https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373>\
**Category:** API\
**Created:** [June 20, 2023, 2:18pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373 "2023-06-20T14:18:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlite](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dlite/32/154928_2.png) [@dlite](https://community.openai.com/u/dlite)\
**Post date:** [June 20, 2023, 2:18pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/1 "2023-06-20T14:18:56Z")

</div>

Since late yesterday, I’ve noticed that `gpt-4-0613` is returning the function\_call within the mention content frequently (and NOT the `function_call`) response param. Example response in message content:

```json
{
  "functions.aws_command": {
    "question": "What is the CPU utilization of my EC2 instances?"
  }
}

```

The function name (aws\_command) and the function param (question) are in the correct format. I’ve tried multiple prompt variations without success. I did not see this last week. Curious if anyone else has seen this?

---

<div class="post-metadata">

**Author:** ![Foxalabs](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/foxalabs/32/738355_2.png) [@Foxalabs](https://community.openai.com/u/Foxalabs)\
**Post date:** [June 20, 2023, 4:56pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/2 "2023-06-20T16:56:15Z")

</div>

Can you show your code where you define the function? Could well be a incorrect function definition text causing it.

---

<div class="post-metadata">

**Author:** ![dlite](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dlite/32/154928_2.png) [@dlite](https://community.openai.com/u/dlite)\
**Post date:** [June 20, 2023, 5:10pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/3 "2023-06-20T17:10:17Z")

</div>

Sure:

```json
functions : [
{
      "name": "aws_command",
      "description": "Get information from your AWS account by executing a single AWS CLI command. For example: list of EC2 instances, list of S3 buckets, list of CloudWatch log groups, etc.",
      "parameters": {
        "type": "object",
        "properties": {
          "question": {
            "type": "string",
            "description": "A natural language description of the question to answer by running AWS CLI command(s)."
          },
          "context": {
            "type": "string",
            "description": "Any additional context that the AWS CLI may need to answer the question, like instance ids, bucket names, etc."
          }
        },
        "required": ["question"]
      }
    }
  ]
]

```

---

<div class="post-metadata">

**Author:** ![dlite](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dlite/32/154928_2.png) [@dlite](https://community.openai.com/u/dlite)\
**Post date:** [June 20, 2023, 5:10pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/4 "2023-06-20T17:10:55Z")

</div>

PS - it seems like this only happens if I include the following in my prompt:

```auto
Before providing a final answer or executing a function call, think about a plan to answer the question.

```

---

<div class="post-metadata">

**Author:** ![Foxalabs](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/foxalabs/32/738355_2.png) [@Foxalabs](https://community.openai.com/u/Foxalabs)\
**Post date:** [June 20, 2023, 5:16pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/5 "2023-06-20T17:16:02Z")

</div>

the function description says “A natural language description…” that is what you are telling the AI it needs to create for the function to work. You don’t want a natural language description, you want an AWS command, from a natural language description, no?

---

<div class="post-metadata">

**Author:** ![dlite](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dlite/32/154928_2.png) [@dlite](https://community.openai.com/u/dlite)\
**Post date:** [June 20, 2023, 6:29pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/6 "2023-06-20T18:29:22Z")

</div>

That is the description for the `question` argument, not the function. Given a natural language description of a question, the function (which is actually a separate prompt that gets executed) generates an AWS CLI command.

Anyway, after removing the line I mentioned above, everything has worked as expected.

---

<div class="post-metadata">

**Author:** ![Foxalabs](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/foxalabs/32/738355_2.png) [@Foxalabs](https://community.openai.com/u/Foxalabs)\
**Post date:** [June 20, 2023, 6:31pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/7 "2023-06-20T18:31:32Z")

</div>

Yes, but it’s still in the function definition, just try omitting that line and see what the results are like.

---

<div class="post-metadata">

**Author:** ![AIRobin](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/airobin/32/159856_2.png) [@AIRobin](https://community.openai.com/u/AIRobin)\
**Post date:** [June 21, 2023, 6:51am UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/8 "2023-06-21T06:51:41Z")

</div>

i think we’re having the same issue

 ![image](https://us1.discourse-cdn.com/openai1/original/3X/b/e/be94f9fe3bc78cb3321bfc77f4e5c95da453005e.png)

Did you find a solution to this yet? Any certainties of a cause? Are you asking your bot to ‘reason’?

---

<div class="post-metadata">

**Author:** ![dlite](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/dlite/32/154928_2.png) [@dlite](https://community.openai.com/u/dlite)\
**Post date:** [June 21, 2023, 12:37pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/9 "2023-06-21T12:37:39Z")

</div>

Odd … I am building an agent application, so I am asking it to reason. After changing the line below in my prompt, I haven’t seen the issue (probably 100+ API calls):

```auto
Before providing a final answer or executing a function call, think about a plan to answer the question.

```

To:

```auto
When sharing a plan or observation, limit to 2 sentences, manager-level description (no command names or references to arguments).

```

---

<div class="post-metadata">

**Author:** ![AIRobin](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/airobin/32/159856_2.png) [@AIRobin](https://community.openai.com/u/AIRobin)\
**Post date:** [June 23, 2023, 1:52am UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/10 "2023-06-23T01:52:30Z")

</div>

Removing the part that its need to reason helped for me too, clean calls in the last 200+ api calls.  
I suppose its already reasoning a bit thanks to the function calls.  
I still advice it to use function calls though

---

<div class="post-metadata">

**Author:** ![yuvadm](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/yuvadm/32/159347_2.png) [@yuvadm](https://community.openai.com/u/yuvadm)\
**Post date:** [June 26, 2023, 9:10am UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/11 "2023-06-26T09:10:36Z")

</div>

I’m seeing this exact same behavior on very basic prompts that have no instructions for “reasoning” as mentioned earlier in the thread.

Curious if anyone else sees this issue and has a good way of working around it.

---

<div class="post-metadata">

**Author:** ![Foxalabs](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/foxalabs/32/738355_2.png) [@Foxalabs](https://community.openai.com/u/Foxalabs)\
**Post date:** [June 26, 2023, 10:14am UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/12 "2023-06-26T10:14:33Z")

</div>

Welcome to the forum, yuvadm.

If you have examples of this, please create a new post and if you can, please list some example prompts and responses.

Thank you.

---

<div class="post-metadata">

**Author:** ![yuvadm](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/yuvadm/32/159347_2.png) [@yuvadm](https://community.openai.com/u/yuvadm)\
**Post date:** [June 26, 2023, 10:20am UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/13 "2023-06-26T10:20:41Z")

</div>

Thanks @Foxalabs! Will clean up my prompt and post a reproducible example shortly.

---

<div class="post-metadata">

**Author:** ![p.biermann](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@p.biermann](https://community.openai.com/u/p.biermann)\
**Post date:** [August 4, 2023, 7:58am UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/14 "2023-08-04T07:58:09Z")

</div>

don’t know if that is very reasonable but putting this into the system message helped:

Never print the function\_call in the chat. Always use the function\_call attribute to call a function.

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [August 4, 2023, 10:57am UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/15 "2023-08-04T10:57:46Z")

</div>

The AI doesn’t “use the function\_call attribute” to put a function call in the right place. The AI generates language of a function in a particular style, and the backend is supposed to pick that up and encapsulate it in the 'function call" message content.

It needs to be the only line, or the last line separated by carriage returns.

One of the best ways to break function calling is by referring to the functions themself. The AI must decide _on its own_ that a function is appropriate to be used to answer a question. If the user input could directly say “pass these parameters to the `write_database` function”, there would be chaos.

* * *

**For all the single output below, I’ve mind-bent the AI into hallucinating things that aren’t the actual form of function calls, simply by telling it the steps it should do:** (as shown earlier in this topic)

* * *

Sure! Here’s an explanation of the API calls AI will use for each function, followed by the API function calls for all three functions:

1. Python Calculation to Calculate the 200th Digit of Pi:

2. Python Calculation to Generate Fibonacci Sequence up to 100:

3. Python Calculation to Calculate the Sine of 3388 Radians:

Now, let’s make the API function calls for all three functions:

```python
# Calculate the 200th digit of Pi
pi_script = '''
import math

pi = str(math.pi)
digit = pi[201]
digit
'''

# Generate Fibonacci sequence up to 100
fibonacci_script = '''
def fibonacci(n):
    if n <= 0:
        return []
    elif n == 1:
        return [0]
    elif n == 2:
        return [0, 1]
    else:
        sequence = [0, 1]
        while len(sequence) < n:
            next_number = sequence[-1] + sequence[-2]
            sequence.append(next_number)
        return sequence
fibonacci(100)
'''

# Calculate the sine of 3388 radians
sine_script = '''
import math

sine = math.sin(3388)
sine
'''

# API function calls
[
  {"python": {"program": pi_script}},
  {"python": {"program": fibonacci_script}},
  {"python": {"program": sine_script}}
]

```

Please note that the response may take a few seconds as the calculations are performed."

---

<div class="post-metadata">

**Author:** ![anon-dev-72](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/anon-dev-72/32/427056_2.png) [@anon-dev-72](https://community.openai.com/u/anon-dev-72)\
**Post date:** [July 19, 2024, 5:05pm UTC](https://community.openai.com/t/function-call-included-in-content-not-in-function-call-response-param/272373/16 "2024-07-19T17:05:32Z")

</div>

> [@\_j](#):
>
> planation of the API calls AI will use for each function, followed by the API function calls for all three functions:
> 
> 1. Python Calculation to Calculate the 200th Digit of Pi:
> 
> - AI will use the `python` API call to execute a Python script that calculates the 200th digit of Pi using a mathematical algorithm.
> 
> 1. Python Calculation to Generate Fibonacci Sequence up to 100:
> 
> - AI will use the `python` API call to execute a Python script that generates the Fibonacci sequence up to the 100th number.
> 
> 1. Python Calculation to Calculate the Sine of 3388 Radians:
> 
> - AI will use the `python` API call to execute a Python script that calculates the sine of 3388 radians using the math library in Python.
> 
> Now, let’s make the API function calls for all three functions:

Anyone has found a reliable solution to this one? So far I’ve seen stuff like this:

`multi_tool_use.parallel({\n tool_uses: [\n {\n recipient_name: \"functions.navigate_to_section\",\n parameters: {\n section: \"recipe_search\",\n search_terms: \"apples\"\n }\n }\n]\n})\n`

and this:

`javascript\nnavigate_to_section('recipe_search', 'lemons')\n`

in the response stream instead of a function call.

Thanks
