# M3\_UGL\_1 local run error

**URL:** <https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554>\
**Category:** Agentic AI\
**Tags:** week-module-3, dl-ai-learning-platform\
**Created:** [December 23, 2025, 11:28am UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554 "2025-12-23T11:28:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuangxia](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@shuangxia](https://community.deeplearning.ai/u/shuangxia)\
**Post date:** [December 23, 2025, 11:28am UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/1 "2025-12-23T11:28:31Z")

</div>

I downloaded all the files to run locally. However for the “ **3.4 Manually defining tools** ”, the response I got always have `"function_call": null` as if it just can’t detect the tools I passed on. The in-class notebook run without this issue.

I don’t know how to debug this. Can you help? thanks!

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [December 23, 2025, 11:48am UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/2 "2025-12-23T11:48:30Z")

</div>

can post screenshot of the output you got

---

<div class="post-metadata">

**Author:** ![shuangxia](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@shuangxia](https://community.deeplearning.ai/u/shuangxia)\
**Post date:** [December 23, 2025, 2:10pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/3 "2025-12-23T14:10:26Z")

</div>

![image](https://global.discourse-cdn.com/dlai/original/3X/1/d/1d7cc7248a353fa9329b703da0fe027a0d053e20.png)

there is just no tools detected. I’m using my own OpenAI API key that has no other issue.

If I run with `max_turns` set, I do get the result.

I didn’t modify the notebook otherwise, just passed in my API key.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [December 23, 2025, 2:51pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/4 "2025-12-23T14:51:45Z")

</div>

Did you define the function you want the agent to use locally.

you probably need to modify some of part of the codes when running locally.

Also did you get also download research\_tools.py file?? this has the two tools defined used in the notebook, tavily and arxiv search tool.

---

<div class="post-metadata">

**Author:** ![shuangxia](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@shuangxia](https://community.deeplearning.ai/u/shuangxia)\
**Post date:** [December 23, 2025, 3:24pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/5 "2025-12-23T15:24:46Z")

</div>

this is the one uses `get_current_time()` and yes I did define the tool.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [December 23, 2025, 3:31pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/6 "2025-12-23T15:31:11Z")

</div>

if you want you can send me the link to the notebook you working by personal DM..

i am guessing or hoping this doesn’t! requires tools to saved/downloaded locally.

---

<div class="post-metadata">

**Author:** ![reinoudbosch](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@reinoudbosch](https://community.deeplearning.ai/u/reinoudbosch)\
**Post date:** [December 23, 2025, 5:59pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/7 "2025-12-23T17:59:42Z")

</div>

Hi shuangxia,

Looking at the aisuite code [here](https://github.com/andrewyng/aisuite/blob/main/aisuite/client.py), I get the impression that unless max\_turns is set, the tools are not passed to the model call. This may be due to some modification to the current aisuite package, compared to the version used in the lab (maybe popping the kwargs?)

```auto
        # Check environment variable before allowing multi-turn tool execution
        if max_turns is not None and tools is not None:
            return self._tool_runner(
                provider,
                model_name,
                messages.copy(),
                tools,
                max_turns,
                **kwargs,
            )

        # Default behavior without tool execution
        # Delegate the chat completion to the correct provider's implementation
        response = provider.chat_completions_create(model_name, messages, **kwargs)
        return self._extract_thinking_content(response)

```

So if I were to implement this locally, I would just always set max\_turns (e.g. to 1). But maybe there is some other explanation.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [December 23, 2025, 6:15pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/8 "2025-12-23T18:15:58Z")

</div>

he did set the max\_turns as the assignment at the end mentions it clearly. He is able to execute the codes. only function call are null, I think he needs to explicitly add those two agents tools to be recalled separately in the codes notebook he is running locally.

---

<div class="post-metadata">

**Author:** ![reinoudbosch](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@reinoudbosch](https://community.deeplearning.ai/u/reinoudbosch)\
**Post date:** [December 23, 2025, 7:06pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/9 "2025-12-23T19:06:17Z")

</div>

As shuangxia states, the exact same notebook is run locally. When max\_turns is excluded, as in 3.4 in the notebook, the model does not detect the tool. The only tool in [tools] is get\_current\_time which was included, as shuangxia states in a previous comment. So there is something about the packages / local environment (I don’t believe the mcp package is required, though this is used in aisuite). When I check the code in aisuite, it appears no tool is passed to the model when max\_turns is None. Given that the version of aisuite installed by shuangxia may not be the same as the one used in the lab, and given that the kwargs are popped rather than simply used, this could explain why no tool is passed to the model (as they are not passed explicitly through a tools variable, and neither through the kwargs). Anyway, so much for my two cents. As stated, I would simply always set max\_turns if using this version of aisuite. But let’s see what shuangxia reports.

---

<div class="post-metadata">

**Author:** ![harijay](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/harijay/32/140256_2.png) [@harijay](https://community.deeplearning.ai/u/harijay)\
**Post date:** [January 21, 2026, 12:31pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/10 "2026-01-21T12:31:32Z")

</div>

I cannot get the manual calls to work no matter what I try with aisuite 0.1.14 . I know the course uses 0.1.11. I have posted my Not working Notebook to gist here. I tried a few times by myself to get the manual schema definition to work , including using tools\_choice = “required” and other Gemini AI suggested workarounds. But no matter what I tried aisuite 0.1.14 strips out the tool.

I also had to use PR 262 in aisuite 0.1.14 since there was a bug that called _is_mcp\_config.

My Gist example is : [M3UngradedLab\_tool\_hjlearn.ipynb · GitHub](https://gist.github.com/harijay/d5b6b0ce704e5149c22c4f335bff91a1)

Would it be posible to get help with manual tool calls with later versions of aisuite?  
Loving the course

Thanks

Hari

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 21, 2026, 1:25pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/14 "2026-01-21T13:25:49Z")

</div>

@harijay

Add response\_manual results of an api call in the cell where you got response\_manual not defined. It should work.

```auto
import json

response2 = None

# --- ASsign'response_manual' the result of an API call ---
# Example placeholder in the cell for which you got response_manual not defined at the beginning.
# response_manual = myaisuite_client.chat.completions.create(
# model="openai:gpt-4o",
# messages=messages,
# tools=tools,
# )

# Create a condition in case tool_calls is in response object
if response_manual.choices[0].message.tool_calls:
    # Pull out the specific tool metadata from the response
    tool_call = response_manual.choices[0].message.tool_calls[0]
    args = json.loads(tool_call.function.arguments)

    # Run the tool locally (ensure 'get_current_time' function is defined)
    tool_result = get_current_time(args['timezone_str']) 

    # Append the result to the messages list
    # Note: 'response' variable is also undefined in the original snippet, 
    # assuming you meant 'response_manual' or another defined variable.
    messages.append(response_manual.choices[0].message) 
    messages.append({
        "role": "tool",
        "tool_call_id": tool_call.id,
        "content": str(tool_result)
    })

    # Send the list of messages with the newly appended results back to the LLM
    response2 = myaisuite_client.chat.completions.create(
        model="openai:gpt-4o",
        messages=messages,
        tools=tools,
    )
    print(response2.choices[0].message.content)
else:
    # Handle the case where no tool calls were made in the first response
    print(response_manual.choices[0].message.content)

```

---

<div class="post-metadata">

**Author:** ![harijay](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/harijay/32/140256_2.png) [@harijay](https://community.deeplearning.ai/u/harijay)\
**Post date:** [January 21, 2026, 2:53pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/15 "2026-01-21T14:53:49Z")

</div>

I tried repeatedly with a manual complete schema , not matter what aisuite 0.1.14 strips the function call. Using max\_turns and forcing newer implementation makes it work.

I updated the gist with the non-working schema and it does not give a tool\_calls schema. For now I am going to not try to get the manual tool calling to work with 0.1.14  
json obtained with attempt at manual tool call.

Updated gist: [M3UngradedLab\_tool\_hjlearn.ipynb · GitHub](https://gist.github.com/harijay/d5b6b0ce704e5149c22c4f335bff91a1)  
{  
“id”: “chatcmpl-D0TiTfNR1V1cWvXQhweufaIhVRDxi”,  
“choices”: [  
{  
“finish\_reason”: “stop”,  
“index”: 0,  
“logprobs”: null,  
“message”: {  
“content”: “I’m unable to provide real-time information or current time updates. However, you can easily find the current time in Boston, MA, by checking a world clock website, using a smartphone, or searching online. Boston is in the Eastern Time Zone (ET), which is UTC-5 hours during Standard Time or UTC-4 hours during Daylight Saving Time, depending on the time of year. Daylight Saving Time usually starts on the second Sunday in March and ends on the first Sunday in November.”,  
“refusal”: null,  
“role”: “assistant”,  
“annotations”: [],  
“audio”: null,  
“function\_call”: null,  
“tool\_calls”: null  
}  
}  
],  
“created”: 1769006601,  
“model”: “gpt-4o-2024-08-06”,  
“object”: “chat.completion”,  
“service\_tier”: “default”,  
“system\_fingerprint”: “fp\_deacdd5f6f”,  
“usage”: {  
“completion\_tokens”: 99,  
“prompt\_tokens”: 17,  
“total\_tokens”: 116,  
“completion\_tokens\_details”: {  
“accepted\_prediction\_tokens”: 0,  
“audio\_tokens”: 0,  
“reasoning\_tokens”: 0,  
“rejected\_prediction\_tokens”: 0  
},  
“prompt\_tokens\_details”: {  
“audio\_tokens”: 0,  
“cached\_tokens”: 0  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 21, 2026, 3:21pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/16 "2026-01-21T15:21:37Z")

</div>

@harijay hari

o 😃 great

---

<div class="post-metadata">

**Author:** ![harijay](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/harijay/32/140256_2.png) [@harijay](https://community.deeplearning.ai/u/harijay)\
**Post date:** [January 21, 2026, 9:09pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/17 "2026-01-21T21:09:00Z")

</div>

Hi , I could reproduce the code in the course with aisuite 0.1.11 , exactly as recommended. The manual tool call Notebook where I fixed my requirement for max\_turns is here below.

> <https://gist.github.com/harijay/9e757bc8fa9e5a801389a173bd46a21b>

Thanks for your help

---

<div class="post-metadata">

**Author:** ![harijay](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/harijay/32/140256_2.png) [@harijay](https://community.deeplearning.ai/u/harijay)\
**Post date:** [January 21, 2026, 10:14pm UTC](https://community.deeplearning.ai/t/m3-ugl-1-local-run-error/885554/18 "2026-01-21T22:14:08Z")

</div>

I created a PR#266 so aisuite 0.1.14 also works with code from the lab.

> <https://github.com/andrewyng/aisuite/pull/266>
>
> \## Problem
> 
> Manual tool calling broke in v0.1.14. When passing tool schemas with…out \`max\_turns\`, the LLM doesn't see the available tools and responds normally instead of making tool calls.
> 
> \### Root Cause
> In \`client.py\` line 330, the code uses \`kwargs.pop("tools")\` which removes tools from kwargs. When \`max\_turns\` is None (manual tool calling mode), execution reaches line 355 which calls the provider \*\*without tools\*\* in kwargs, causing the LLM to not see the tool schemas.
> 
> \### Reproduction
> \`\`\`python
> import aisuite as ai
> 
> \# Manual tool schema
> tools = \[{
> "type": "function",
> "function": {
> "name": "get\_time",
> "description": "Get current time",
> "parameters": {}
> }
> }\]
> 
> client = ai.Client()
> response = client.chat.completions.create(
> model="openai:gpt-4o",
> messages=\[{"role": "user", "content": "What time is it?"}\],
> tools=tools, # Tools schema is lost!
> )
> 
> \# Result: LLM doesn't see tools, responds normally
> \# Expected: LLM makes a tool\_call
> \`\`\`
> 
> \## Solution
> 
> 1. \*\*Line 330\*\*: Changed from \`kwargs.pop("tools")\` to \`kwargs.get("tools")\` to preserve tools in kwargs
> 2. \*\*Line 345\*\*: Added explicit \`kwargs.pop("tools")\` when using max\_turns, since \`\_tool\_runner\` handles them separately
> 3. \*\*Added tests\*\*: Comprehensive test coverage to prevent future regressions
> 
> \## Changes
> \- \`aisuite/client.py\`: 3 lines changed
> \- \`tests/client/test\_manual\_tool\_calling.py\`: New test file
> 
> \## Impact
> ✅ \*\*Manual tool calling\*\* (no max\_turns): Now works correctly  
> ✅ \*\*Automatic tool execution\*\* (with max\_turns): Continues to work as expected  
> ✅ \*\*No breaking changes\*\* to existing functionality
> 
> \## Testing
> Added unit tests that verify:
> \- Tools are passed to provider in manual mode
> \- Tools are not duplicated in automatic mode
> \- MCP config processing continues to work
> 
> All tests pass:
> \`\`\`bash
> pytest tests/client/test\_manual\_tool\_calling.py -v
> \`\`\`
> 
> \## Related
> \- Fixes the documented workflow at https://github.com/andrewyng/aisuite#manual-tool-calling-no-max\_turns
> \- Regression introduced in v0.1.14 (worked in v0.1.11)
> 
> Co-Authored-By: Warp \<agent@warp.dev\>

Thanks for your help in troubleshooting this

Hari
