Repository: langchain
Issue: ValueError: `my_func_tool` is not strict. Only `strict` function tools can be auto-parsed (after `openai` upgrade)
Labels: 🤖:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [X] I am sure that this is a bug in LangGraph/LangChain rather than my code.
- [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question.

### Example Code

```python
from enum import Enum

from langchain_core.tools import tool
from langchain_openai import ChatOpenAI

class MyEnum(Enum):
    ...
    

@tool("my_func_tool")
def my_func_tool(s: str, category: MyEnum) -> dict:
    # do some stuff ...
    return {'a': True}


llm = ChatOpenAI()
prompt = ChatPromptTemplate.from_messages(
    [
        ("system", formatted_primary_assistant_prompt),
        ("placeholder", "{messages}"),
    ]
)
runnable = prompt | llm.bind_tools([my_func_tool])

state: ...
runnable.invoke(state)
```


### Error Message and Stack Trace (if applicable)

```shell
[2024-10-16 13:25:29,690: ERROR/ForkPoolWorker-8] Task app.main.func[8db70515-f08a-47b7-9ae3-abdc3bd6f6ef] raised unexpected: ValueError('`my_func_tool` is not strict. Only `strict` function tools can be auto-parsed')
Traceback (most recent call last):
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1720, in runner
    return sentry_patched_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/sentry_sdk/integrations/celery/__init__.py", line 406, in _inner
    reraise(*exc_info)
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1649, in reraise
    raise value
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/sentry_sdk/integrations/celery/__init__.py", line 401, in _inner
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/celery/app/trace.py", line 736, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/Desktop/projects/work/my_api_v3/app/main.py", line 114, in process_chat_message_task
    return asyncio.run(process_chat_message(chat_request_dict))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/shneor/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/shneor/Desktop/projects/work/my_api_v3/app/main.py", line 270, in process_chat_message
    for index, event in enumerate(events):
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 1285, in stream
    for _ in runner.tick(
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langgraph/pregel/runner.py", line 56, in tick
    run_with_retry(t, retry_policy)
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langgraph/pregel/retry.py", line 29, in run_with_retry
    task.proc.invoke(task.input, config)
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langgraph/utils/runnable.py", line 410, in invoke
    input = context.run(step.invoke, input, config, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langgraph/utils/runnable.py", line 184, in invoke
    ret = context.run(self.func, input, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/Desktop/projects/work/my_api_v3/app/graph/assistant.py", line 132, in __call__
    raise e
  File "/home/shneor/Desktop/projects/work/my_api_v3/app/graph/assistant.py", line 96, in __call__
    result = runnable.invoke(state)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 3024, in invoke
    input = context.run(step.invoke, input, config)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 5354, in invoke
    return self.bound.invoke(
           ^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 286, in invoke
    self.generate_prompt(
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 786, in generate_prompt
    return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 643, in generate
    raise e
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 633, in generate
    self._generate_with_cache(
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 851, in _generate_with_cache
    result = self._generate(
             ^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/langchain_openai/chat_models/base.py", line 677, in _generate
    response = self.root_client.beta.chat.completions.parse(**payload)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/openai/resources/beta/chat/completions.py", line 105, in parse
    _validate_input_tools(tools)
  File "/home/shneor/.cache/pypoetry/virtualenvs/my-api-v3-xF5Uu3dv-py3.11/lib/python3.11/site-packages/openai/lib/_parsing/_completions.py", line 53, in validate_input_tools
    raise ValueError(
ValueError: `my_func_tool` is not strict. Only `strict` function tools can be auto-parsed
```


### Description

Hey, I hope this example is enough to understand the issue. I'm not able to make an actual reproducible example cuz the codebase is massive and too many nested function calls.

So basically everything was working fine, until I updated the `openai` library from `1.38.0` to `1.40.0`.
I don't understand the `strict` error as the function has type annotations.

Also as a disclaimer I'm pretty new to the langchain/langgraph ecosystem, so I have no idea whats going on.

### System Info

System Information
------------------
> OS:  Linux
> OS Version:  langchain-ai/langgraph#40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2
> Python Version:  3.11.4 (main, Jun 18 2023, 17:04:26) [GCC 11.3.0]

Package Information
-------------------
> langchain_core: 0.3.10
> langchain: 0.3.3
> langchain_community: 0.3.2
> langsmith: 0.1.135
> langchain_anthropic: 0.2.3
> langchain_groq: 0.2.0
> langchain_openai: 0.2.2
> langchain_text_splitters: 0.3.0
> langchain_together: 0.2.0
> langgraph: 0.2.36

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> langgraph-checkpoint: 2.0.1
> langgraph-sdk: 0.1.33
> openai: 1.40.0
> pydantic: 2.9.2