Skip to content

Python: TypeError: Kernel.create_new_context() takes 1 positional argument but 2 were given #3219

Closed

Description

Describe the bug
In the python sdk (0.3.12.dev0), when running Plan.run_next_step_async the method throws a TypeError. Inside the method, there's a call to Kernel.create_new_context. The create_new_context method does not take any arguments, but ContextVariables are passed in.

Here's the implementation of Plan.run_next_step_async:

async def run_next_step_async(
        self,
        kernel: Kernel,
        variables: ContextVariables,
    ) -> "Plan":
        context = kernel.create_new_context(variables)
        return await self.invoke_next_step(context)

and here's the implementation of Kernel.create_new_context:

def create_new_context(self) -> SKContext:
        return SKContext(
            ContextVariables(),
            self._memory,
            self.skills,
            self._log,
        )

To Reproduce
Steps to reproduce the behavior:

  1. instantiate a kernel
  2. create a plan
  3. run plan.run_next_async(kernel, ContextVariables())
import semantic_kernel as sk
from semantic_kernel.planning.plan import Plan
from semantic_kernel.orchestration.context_variables import ContextVariables

kernel = sk.Kernel()
plan = Plan()
plan = await plan.run_next_step_async(kernel, ContextVariables())

Expected behavior
The method should not raise a TypeError

Screenshots
If applicable, add screenshots to help explain your problem.

Platform

  • OS: Mac
  • IDE: Intellij
  • Language: Python
  • Source: 0.3.12.dev0

Additional context
The fix seems to be one of the two options:

  1. instantiate SKContext directly instead of using the kernel
  2. create another method on Kernel to create the SKContext while passing in ContextVariables

I'm happy to submit a PR to resolve this, but need some help in the overall direction of the fix.

Activity

  1. changed the title [-]TypeError: Kernel.create_new_context() takes 1 positional argument but 2 were given[/-] [+]Python: TypeError: Kernel.create_new_context() takes 1 positional argument but 2 were given[/+] on Oct 17, 2023
  2. added a commit that references this issue on Oct 19, 2023
    965c23d
  3. added a commit that references this issue on Nov 1, 2023
    d4e7a32
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

    pythonPull requests for the Python Semantic Kerneltriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions