# How can I force Function calling then AgentFinish?

**URL:** <https://community.openai.com/t/how-can-i-force-function-calling-then-agentfinish/721854>\
**Category:** API\
**Tags:** langchain, function-calling\
**Created:** [April 19, 2024, 1:48am UTC](https://community.openai.com/t/how-can-i-force-function-calling-then-agentfinish/721854 "2024-04-19T01:48:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alchemine](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/alchemine/32/312183_2.png) [@alchemine](https://community.openai.com/u/alchemine)\
**Post date:** [April 19, 2024, 1:48am UTC](https://community.openai.com/t/how-can-i-force-function-calling-then-agentfinish/721854/1 "2024-04-19T01:48:59Z")

</div>

I implemented chatbot by referring to `langchain.agents.agent.AgentExecutor` like this,

```python
prompt = ...
model = model.bind_tools([tool], tool_choice=tool_name)
parser = OpenAIToolsAgentOutputParser()
chain = prompt | model | parser

while self._should_continue(params):
    response = invoke_chain(...)
    if isinstance(response, AgentFinish):
        # final response
        ...
    else:
        # function calling invoked
        ...

```

```auto
model = model.bind_tools([tool], tool_choice=tool_name)

```

Here, this syntax(`tool_choice`) always invokes function calling, but I want to get final response(AgentFinish) after forcing function calling(OpenAIToolAgentAction).

Is there anything to do it?  
If not, is it the best way to use separate models/chains(binded one and not binded one)?
