Skip to content

When running a tool call (tools.py), it should accept None as the argument. (Issue with end_turn tool) #378

@thshorrock

Description

@thshorrock

Description

I am using Qwen2.5 as my llm. When calling the end_turn tool in multiagent tasks, the "end_turn" tool is called with None for the arguments, rather than an empty dictionary as is done with gpt.

This causes this error:

| ERROR | Task run 'Tool call: end_turn' - Task run failed with exception: TypeError('controlflow.orchestration.turn_strategies.get_end_turn_tool..end_turn() argument after ** must be a mapping, not NoneType') - Retries are exhausted Traceback (most recent call last): controlflow

The issue is this part of the file tools/tools.py (around line 60)

    @prefect_task(task_run_name="Tool call: {self.name}")
    def run(self, input: dict):
        
        result = self.fn(**input)

This issue is resolved if a check for None is added:


    @prefect_task(task_run_name="Tool call: {self.name}")
    def run(self, input: dict):
    
        # Set input to an empty dictionary if it is None
        input = input or {} 
        
        result = self.fn(**input)

Example Code

import controlflow as cf

model = ChatOpenAI(temperature=0.0, model="Qwen/Qwen2.5-7B-Instruct",  base_url="my-vllm-server/v1")

optimist = cf.Agent(
    name="Optimist",
    instructions="Always find the best in every situation.", 
    model=model
)

pessimist = cf.Agent(
    name="Pessimist",
    instructions="Always find the worst in every situation.",
    model=model
)

cf.run(
    f"Debate world peace",
    instructions=(
        "Mark the task successful once both agents have have spoken"
    ),
    agents=[optimist, pessimist],
)

Version Information

control flow version: 0.11.2
python 3.11.0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentationenhancementEnhance an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions