Skip to content

FunctionTool raises TypeError for positional-only parameters after successful schema validation #8319

Description

@fhgffy

FunctionTool builds a valid argument schema for an annotated Python function with positional-only parameters, but run_json() passes those parameters as keywords and raises TypeError.

import asyncio
from autogen_core import CancellationToken
from autogen_core.tools import FunctionTool

def scale(value: int, /, *, factor: int = 2) -> int:
    return value * factor

async def main() -> None:
    tool = FunctionTool(scale, description="Scale a value.")
    print(tool.schema)
    print(await tool.run_json({"value": 3}, CancellationToken()))

asyncio.run(main())

Expected result: 6. Actual result: TypeError: scale() got some positional-only arguments passed as keyword arguments: 'value'.

The same problem affects async functions and functions whose cancellation_token is positional-only. It occurs after argument validation, in FunctionTool.run.

Reproduced on main at 027ecf0a379bcc1d09956d46d12d44a3ad9cee14 (autogen-core 0.7.5), Windows, Python 3.12.2. Eight regression cases fail on the unchanged implementation, covering sync/async execution, positional defaults, partial, and cancellation-token injection. No model credentials or network calls are involved.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions