mirror of
https://github.com/langchain-ai/langgraph-codeact.git
synced 2026-07-25 21:25:26 -04:00
Serialization Error with Checkpointer - Unsupported Type #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @eddiehex on GitHub (Mar 30, 2025).
Problem:
I'm encountering a serialization error when attempting to compile a CodeAct graph with a checkpointer parameter. The error occurs because the default serializer in LangGraph doesn't support certain object types (specifically
Modulein my case).Environment:
Error:
@vbarda commented on GitHub (Mar 31, 2025):
@eddiehex what is your use case? are you passing python modules somehow in your graph state? please provide a code example that reproduces the issue
@kivy0 commented on GitHub (Apr 3, 2025):
Hi, I have a similar problem. I ran the code in Google colab. Copied the code from README.md and only replaced the model to
I get the following log:
`---answer---
{'messages': [HumanMessage(content='A batter hits a baseball at 45.847 m/s at an angle of 23.474° above the horizontal. The outfielder, who starts facing the batter, picks up the baseball as it lands, then throws it back towards the batter at 24.12 m/s at an angle of 39.12 degrees. How far is the baseball from where the batter originally hit it? Assume zero air resistance.', additional_kwargs={}, response_metadata={}, id='9619b533-622c-4214-b34f-365073aa9b79')]}
To solve this problem, we need to calculate the horizontal and vertical components of both the baseball's and the outfielder's throw, and then determine the distance at which the baseball lands.
Step 1: Calculate the horizontal and vertical components of the baseball's velocity
The components can be calculated using trigonometric functions:
Step 2: Calculate the time of flight for the baseball
The time of flight until the baseball lands can be determined using the vertical motion equations.
Step 3: Calculate the range of the baseball
The horizontal range can be calculated by multiplying the horizontal component of the baseball's velocity by the time of flight.
Step 4: Calculate the horizontal component of the outfielder's throw
Similar to step 1, calculate the horizontal component of the outfielder's throw.
Step 5: Calculate total distance from the batter
The total distance from where the batter hit the ball to where the outfielder catches it would be the sum of the baseball's range and the distance the outfielder throws the ball.
Let's compute this using Python code:
Now, let's execute this code to find the total distance.
---answer---
{'messages': [HumanMessage(content='A batter hits a baseball at 45.847 m/s at an angle of 23.474° above the horizontal. The outfielder, who starts facing the batter, picks up the baseball as it lands, then throws it back towards the batter at 24.12 m/s at an angle of 39.12 degrees. How far is the baseball from where the batter originally hit it? Assume zero air resistance.', additional_kwargs={}, response_metadata={}, id='9619b533-622c-4214-b34f-365073aa9b79'), AIMessage(content="To solve this problem, we need to calculate the horizontal and vertical components of both the baseball's and the outfielder's throw, and then determine the distance at which the baseball lands.\n\n### Step 1: Calculate the horizontal and vertical components of the baseball's velocity\nThe components can be calculated using trigonometric functions:\n- Horizontal component: \( V_{x} = V \cdot \cos(\theta) \)\n- Vertical component: \( V_{y} = V \cdot \sin(\theta) \)\n\n### Step 2: Calculate the time of flight for the baseball\nThe time of flight until the baseball lands can be determined using the vertical motion equations.\n\n### Step 3: Calculate the range of the baseball\nThe horizontal range can be calculated by multiplying the horizontal component of the baseball's velocity by the time of flight.\n\n### Step 4: Calculate the horizontal component of the outfielder's throw\nSimilar to step 1, calculate the horizontal component of the outfielder's throw.\n\n### Step 5: Calculate total distance from the batter\nThe total distance from where the batter hit the ball to where the outfielder catches it would be the sum of the baseball's range and the distance the outfielder throws the ball.\n\nLet's compute this using Python code:\n\n
python\nimport math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * (time_of_flight)\n\ntotal_distance\n\n\nNow, let's execute this code to find the total distance.", additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_b376dfbbd5'}, id='run-d118bbcf-28b7-46da-9e0f-31b13e5ac01e')], 'script': "import math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * (time_of_flight)\n\ntotal_distance"}---answer---
{'messages': [HumanMessage(content='A batter hits a baseball at 45.847 m/s at an angle of 23.474° above the horizontal. The outfielder, who starts facing the batter, picks up the baseball as it lands, then throws it back towards the batter at 24.12 m/s at an angle of 39.12 degrees. How far is the baseball from where the batter originally hit it? Assume zero air resistance.', additional_kwargs={}, response_metadata={}, id='9619b533-622c-4214-b34f-365073aa9b79'), AIMessage(content="To solve this problem, we need to calculate the horizontal and vertical components of both the baseball's and the outfielder's throw, and then determine the distance at which the baseball lands.\n\n### Step 1: Calculate the horizontal and vertical components of the baseball's velocity\nThe components can be calculated using trigonometric functions:\n- Horizontal component: \( V_{x} = V \cdot \cos(\theta) \)\n- Vertical component: \( V_{y} = V \cdot \sin(\theta) \)\n\n### Step 2: Calculate the time of flight for the baseball\nThe time of flight until the baseball lands can be determined using the vertical motion equations.\n\n### Step 3: Calculate the range of the baseball\nThe horizontal range can be calculated by multiplying the horizontal component of the baseball's velocity by the time of flight.\n\n### Step 4: Calculate the horizontal component of the outfielder's throw\nSimilar to step 1, calculate the horizontal component of the outfielder's throw.\n\n### Step 5: Calculate total distance from the batter\nThe total distance from where the batter hit the ball to where the outfielder catches it would be the sum of the baseball's range and the distance the outfielder throws the ball.\n\nLet's compute this using Python code:\n\n
python\nimport math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * (time_of_flight)\n\ntotal_distance\n\n\nNow, let's execute this code to find the total distance.", additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_b376dfbbd5'}, id='run-d118bbcf-28b7-46da-9e0f-31b13e5ac01e'), HumanMessage(content='<code ran, no output printed to stdout>', additional_kwargs={}, response_metadata={}, id='27f21c96-3266-40d0-aec1-24c3a9c3246e')], 'script': "import math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * (time_of_flight)\n\ntotal_distance", 'context': {'angle_baseball': 23.474, 'math': <module 'math' (built-in)>, 'Vx_baseball': 42.05274475933024, 'total_distance': 226.2436396720552, 'Vx_outfielder': 18.71292824319701, 'Vy_baseball': 18.262367513732254, 'angle_outfielder': 39.12, 'time_of_flight': 3.7232145797619274, 'angle_outfielder_rad': 0.6827728033801816, 'angle_baseball_rad': 0.4096985886131489, 'initial_velocity_baseball': 45.847, 'g': 9.81, 'initial_velocity_outfielder': 24.12, 'range_baseball': 156.57139240694534}}It seems the code ran successfully but did not produce any output. Let's modify it slightly to ensure we print the total distance calculated. Here's the updated code snippet:
Let's run this updated code to print the total distance.
---answer---
{'messages': [HumanMessage(content='A batter hits a baseball at 45.847 m/s at an angle of 23.474° above the horizontal. The outfielder, who starts facing the batter, picks up the baseball as it lands, then throws it back towards the batter at 24.12 m/s at an angle of 39.12 degrees. How far is the baseball from where the batter originally hit it? Assume zero air resistance.', additional_kwargs={}, response_metadata={}, id='9619b533-622c-4214-b34f-365073aa9b79'), AIMessage(content="To solve this problem, we need to calculate the horizontal and vertical components of both the baseball's and the outfielder's throw, and then determine the distance at which the baseball lands.\n\n### Step 1: Calculate the horizontal and vertical components of the baseball's velocity\nThe components can be calculated using trigonometric functions:\n- Horizontal component: \( V_{x} = V \cdot \cos(\theta) \)\n- Vertical component: \( V_{y} = V \cdot \sin(\theta) \)\n\n### Step 2: Calculate the time of flight for the baseball\nThe time of flight until the baseball lands can be determined using the vertical motion equations.\n\n### Step 3: Calculate the range of the baseball\nThe horizontal range can be calculated by multiplying the horizontal component of the baseball's velocity by the time of flight.\n\n### Step 4: Calculate the horizontal component of the outfielder's throw\nSimilar to step 1, calculate the horizontal component of the outfielder's throw.\n\n### Step 5: Calculate total distance from the batter\nThe total distance from where the batter hit the ball to where the outfielder catches it would be the sum of the baseball's range and the distance the outfielder throws the ball.\n\nLet's compute this using Python code:\n\n
python\nimport math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * (time_of_flight)\n\ntotal_distance\n\n\nNow, let's execute this code to find the total distance.", additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_b376dfbbd5'}, id='run-d118bbcf-28b7-46da-9e0f-31b13e5ac01e'), HumanMessage(content='<code ran, no output printed to stdout>', additional_kwargs={}, response_metadata={}, id='27f21c96-3266-40d0-aec1-24c3a9c3246e'), AIMessage(content='It seems the code ran successfully but did not produce any output. Let's modify it slightly to ensure we print the total distance calculated. Here's the updated code snippet:\n\npython\nimport math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder\'s throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * time_of_flight\n\n# Print the total distance\nprint(f"Total distance from the batter: {total_distance:.2f} meters")\n\n\nLet's run this updated code to print the total distance.', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_b376dfbbd5'}, id='run-4997829d-c293-4abd-906a-fb79752bed10')], 'script': 'import math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * time_of_flight\n\n# Print the total distance\nprint(f"Total distance from the batter: {total_distance:.2f} meters")', 'context': {'angle_baseball': 23.474, 'math': <module 'math' (built-in)>, 'Vx_baseball': 42.05274475933024, 'total_distance': 226.2436396720552, 'Vx_outfielder': 18.71292824319701, 'Vy_baseball': 18.262367513732254, 'angle_outfielder': 39.12, 'time_of_flight': 3.7232145797619274, 'angle_outfielder_rad': 0.6827728033801816, 'angle_baseball_rad': 0.4096985886131489, 'initial_velocity_baseball': 45.847, 'g': 9.81, 'initial_velocity_outfielder': 24.12, 'range_baseball': 156.57139240694534}}---answer---
{'messages': [HumanMessage(content='A batter hits a baseball at 45.847 m/s at an angle of 23.474° above the horizontal. The outfielder, who starts facing the batter, picks up the baseball as it lands, then throws it back towards the batter at 24.12 m/s at an angle of 39.12 degrees. How far is the baseball from where the batter originally hit it? Assume zero air resistance.', additional_kwargs={}, response_metadata={}, id='9619b533-622c-4214-b34f-365073aa9b79'), AIMessage(content="To solve this problem, we need to calculate the horizontal and vertical components of both the baseball's and the outfielder's throw, and then determine the distance at which the baseball lands.\n\n### Step 1: Calculate the horizontal and vertical components of the baseball's velocity\nThe components can be calculated using trigonometric functions:\n- Horizontal component: \( V_{x} = V \cdot \cos(\theta) \)\n- Vertical component: \( V_{y} = V \cdot \sin(\theta) \)\n\n### Step 2: Calculate the time of flight for the baseball\nThe time of flight until the baseball lands can be determined using the vertical motion equations.\n\n### Step 3: Calculate the range of the baseball\nThe horizontal range can be calculated by multiplying the horizontal component of the baseball's velocity by the time of flight.\n\n### Step 4: Calculate the horizontal component of the outfielder's throw\nSimilar to step 1, calculate the horizontal component of the outfielder's throw.\n\n### Step 5: Calculate total distance from the batter\nThe total distance from where the batter hit the ball to where the outfielder catches it would be the sum of the baseball's range and the distance the outfielder throws the ball.\n\nLet's compute this using Python code:\n\n
python\nimport math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * (time_of_flight)\n\ntotal_distance\n\n\nNow, let's execute this code to find the total distance.", additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_b376dfbbd5'}, id='run-d118bbcf-28b7-46da-9e0f-31b13e5ac01e'), HumanMessage(content='<code ran, no output printed to stdout>', additional_kwargs={}, response_metadata={}, id='27f21c96-3266-40d0-aec1-24c3a9c3246e'), AIMessage(content='It seems the code ran successfully but did not produce any output. Let's modify it slightly to ensure we print the total distance calculated. Here's the updated code snippet:\n\npython\nimport math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder\'s throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * time_of_flight\n\n# Print the total distance\nprint(f"Total distance from the batter: {total_distance:.2f} meters")\n\n\nLet's run this updated code to print the total distance.', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_b376dfbbd5'}, id='run-4997829d-c293-4abd-906a-fb79752bed10'), HumanMessage(content='Total distance from the batter: 226.24 meters\n', additional_kwargs={}, response_metadata={}, id='74f30d3e-eb91-44c8-898e-517d5652f1c4')], 'script': 'import math\n\n# Given data\ninitial_velocity_baseball = 45.847 # m/s\nangle_baseball = 23.474 # degrees\ninitial_velocity_outfielder = 24.12 # m/s\nangle_outfielder = 39.12 # degrees\n\n# Convert angles to radians\nangle_baseball_rad = math.radians(angle_baseball)\nangle_outfielder_rad = math.radians(angle_outfielder)\n\n# Calculate the components for the baseball\nVx_baseball = initial_velocity_baseball * math.cos(angle_baseball_rad)\nVy_baseball = initial_velocity_baseball * math.sin(angle_baseball_rad)\n\n# Calculate time of flight for the baseball (using formula: t = (2 * Vy) / g)\ng = 9.81 # acceleration due to gravity in m/s^2\ntime_of_flight = (2 * Vy_baseball) / g\n\n# Calculate the horizontal range of the baseball\nrange_baseball = Vx_baseball * time_of_flight\n\n# Calculate the horizontal component of the outfielder's throw\nVx_outfielder = initial_velocity_outfielder * math.cos(angle_outfielder_rad)\n\n# Total distance from where the batter originally hit it\ntotal_distance = range_baseball + Vx_outfielder * time_of_flight\n\n# Print the total distance\nprint(f"Total distance from the batter: {total_distance:.2f} meters")', 'context': {'angle_baseball': 23.474, 'math': <module 'math' (built-in)>, 'Vx_baseball': 42.05274475933024, 'total_distance': 226.2436396720552, 'Vx_outfielder': 18.71292824319701, 'Vy_baseball': 18.262367513732254, 'angle_outfielder': 39.12, 'time_of_flight': 3.7232145797619274, 'angle_outfielder_rad': 0.6827728033801816, 'angle_baseball_rad': 0.4096985886131489, 'initial_velocity_baseball': 45.847, 'g': 9.81, 'initial_velocity_outfielder': 24.12, 'range_baseball': 156.57139240694534}}The total distance from where the batter originally hit the baseball to where the outfielder catches it is approximately 226.24 meters.
TypeError Traceback (most recent call last)
in <cell line: 0>()
6 "content": "A batter hits a baseball at 45.847 m/s at an angle of 23.474° above the horizontal. The outfielder, who starts facing the batter, picks up the baseball as it lands, then throws it back towards the batter at 24.12 m/s at an angle of 39.12 degrees. How far is the baseball from where the batter originally hit it? Assume zero air resistance."
7 }]
----> 8 for typ, chunk in agent.stream(
9 {"messages": messages},
10 stream_mode=["values", "messages"],
14 frames
/usr/local/lib/python3.11/dist-packages/langgraph/pregel/__init__.py in stream(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug, subgraphs)
2277 ((), "custom", c)
2278 )
-> 2279 with SyncPregelLoop(
2280 input,
2281 input_model=self.input_model,
/usr/local/lib/python3.11/dist-packages/langgraph/pregel/loop.py in exit(self, exc_type, exc_value, traceback)
1032 ) -> Optional[bool]:
1033 # unwind stack
-> 1034 return self.stack.exit(exc_type, exc_value, traceback)
1035
1036
/usr/lib/python3.11/contextlib.py in exit(self, *exc_details)
599 # set-up context
600 fixed_ctx = exc_details[1].context
--> 601 raise exc_details[1]
602 except BaseException:
603 exc_details[1].context = fixed_ctx
/usr/lib/python3.11/contextlib.py in exit(self, *exc_details)
584 assert is_sync
585 try:
--> 586 if cb(*exc_details):
587 suppressed_exc = True
588 pending_raise = False
/usr/local/lib/python3.11/dist-packages/langgraph/pregel/executor.py in exit(self, exc_type, exc_value, traceback)
118 continue
119 try:
--> 120 task.result()
121 except concurrent.futures.CancelledError:
122 pass
/usr/lib/python3.11/concurrent/futures/_base.py in result(self, timeout)
447 raise CancelledError()
448 elif self._state == FINISHED:
--> 449 return self.__get_result()
450
451 self._condition.wait(timeout)
/usr/lib/python3.11/concurrent/futures/_base.py in __get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
/usr/local/lib/python3.11/dist-packages/langgraph/pregel/executor.py in done(self, task)
81 """Remove the task from the tasks dict when it's done."""
82 try:
---> 83 task.result()
84 except GraphBubbleUp:
85 # This exception is an interruption signal, not an error
/usr/lib/python3.11/concurrent/futures/_base.py in result(self, timeout)
447 raise CancelledError()
448 elif self._state == FINISHED:
--> 449 return self.__get_result()
450
451 self._condition.wait(timeout)
/usr/lib/python3.11/concurrent/futures/_base.py in __get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
/usr/lib/python3.11/concurrent/futures/thread.py in run(self)
56
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)
/usr/local/lib/python3.11/dist-packages/langgraph/checkpoint/memory/__init__.py in put_writes(self, config, writes, task_id, task_path)
446 task_id,
447 c,
--> 448 self.serde.dumps_typed(v),
449 task_path,
450 )
/usr/local/lib/python3.11/dist-packages/langgraph/checkpoint/serde/jsonplus.py in dumps_typed(self, obj)
208 if "valid UTF-8" in str(exc):
209 return "json", self.dumps(obj)
--> 210 raise exc
211
212 def loads(self, data: bytes) -> Any:
/usr/local/lib/python3.11/dist-packages/langgraph/checkpoint/serde/jsonplus.py in dumps_typed(self, obj)
204 else:
205 try:
--> 206 return "msgpack", _msgpack_enc(obj)
207 except ormsgpack.MsgpackEncodeError as exc:
208 if "valid UTF-8" in str(exc):
/usr/local/lib/python3.11/dist-packages/langgraph/checkpoint/serde/jsonplus.py in _msgpack_enc(data)
626
627 def _msgpack_enc(data: Any) -> bytes:
--> 628 return ormsgpack.packb(data, default=_msgpack_default, option=_option)
TypeError: Type is not msgpack serializable: module`
@vbarda commented on GitHub (Apr 4, 2025):
could you please update to the latest version of
langgraphandlanggraph-checkpointand try again?@eddiehex commented on GitHub (Apr 6, 2025):
my solution is adding a try and except module:
@Symbolk commented on GitHub (Jun 19, 2025):
Actually this should be a common problem when langgraph try to serialize non-primitive objects, especially in langgraph-codeact (like VideoFileClip object in moviepy code).
Now I bypass it by prompting the model to close resources in code: