Skip to content

Conversation

@michaelonjack
Copy link
Contributor

Description

Commit 8c9821f updated llama_index.core.tools.FunctionTool's call and acall functions to no longer list ctx as a named parameter meaning the ctx parameter is included in kwargs.

Because the context parameter is included in kwargs, it gets passed to ToolOutput's raw_input attribute which is part of the workflow's context. Since an instance of Context is included within the Context itself, the following error occurs when you attempt to serialize the workflow context using to_dict

Traceback (most recent call last):
  File "/Users/*/Development/Python/*/venv/lib/python3.12/site-packages/llama_index/core/workflow/context_serializers.py", line 50, in serialize
    return json.dumps(serialized_value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Context is not JSON serializable

This update will prevent an instance of Context from being included within the ToolOutput's raw_input attribute.

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • [ x] Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • [x ] No

Type of Change

Please delete options that are not relevant.

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • [x ] I believe this change is already covered by existing unit tests

Suggested Checklist:

  • [x ] I have performed a self-review of my own code
  • [x ] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • [x ] My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 28, 2025
@logan-markewich
Copy link
Collaborator

Ah good catch

@logan-markewich logan-markewich self-requested a review May 28, 2025 16:57
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 28, 2025
@logan-markewich logan-markewich enabled auto-merge (squash) May 28, 2025 17:15
@logan-markewich logan-markewich disabled auto-merge May 28, 2025 18:02
@logan-markewich logan-markewich merged commit 89e1069 into run-llama:main May 28, 2025
8 of 10 checks passed
@colca colca mentioned this pull request Jun 9, 2025
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants