Follow-up from "Add custom Json encoder"
The following discussion from !37 (merged) should be addressed:
-
@mikolaj_wawrzyniak started a discussion: (+3 comments) question: Do we need also custom decoder to lead checkpoints stored in GitLab in
_convert_gitlab_checkpoint_to_checkpoint_tuple
?
I'm not seeing
json.dumps
being called in the methods calling_convert_gitlab_checkpoint_to_checkpoint_tuple
, i.eaget_tuple
andalist
so I don't think we need a custom encoder for that.I think that might be a problem. If you take a look below
Checkpoint pre save
{'plan': {'steps': []}, 'status': <WorkflowStatusEnum.PLANNING: 'Planning'>, 'conversation_history': {'planner': [SystemMessage(content="\nYou are a planner. Could you create a detailed plan that the execution agent can follow in order to fulfil the user's goal?\nOnce you are done with the plan call the `handover_tool` tool.\n"), HumanMessage(content='Your goal is: Please fix the CI pipeline the MR with id 863 in the project with id 47. git repository using this link git@gdk.test:2222/duo-workflow-test/ai-assist.git'), AIMessage(content=[{'text': "Certainly! I'll create a detailed plan for fixing the CI pipeline for the Merge Request (MR) with ID 863 in the project with ID 47. Let's break this down into steps and create a plan using the `update_plan` tool. Then, I'll use the `handover_tool` to summarize the plan for the execution agent.", 'type': 'text'}, {'id': 'toolu_01NJ3DL3jaeBJNKPoZ8hR6pt', 'input': {'tasks': [{'description': 'Clone the git repository', 'status': 'Not Started'}, {'description': 'Checkout the branch associated with MR 863', 'status': 'Not Started'}, {'description': 'Analyze the CI pipeline configuration', 'status': 'Not Started'}, {'description': 'Identify issues in the CI pipeline', 'status': 'Not Started'}, {'description': 'Make necessary changes to fix the CI pipeline', 'status': 'Not Started'}, {'description': 'Test the changes locally', 'status': 'Not Started'}, {'description': 'Commit and push the changes', 'status': 'Not Started'}, {'description': 'Monitor the CI pipeline execution', 'status': 'Not Started'}, {'description': 'Verify that the CI pipeline is fixed', 'status': 'Not Started'}, {'description': 'Update the Merge Request with the changes and results', 'status': 'Not Started'}]}, 'name': 'update_plan', 'type': 'tool_use'}], response_metadata={'id': 'msg_01WFGHep6D5PxaCng1pqTmcy', 'model': 'claude-3-5-sonnet-20240620', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 667, 'output_tokens': 422}}, id='run-b3511292-e401-40b0-a792-735e6746d1da-0', tool_calls=[{'name': 'update_plan', 'args': {'tasks': [{'description': 'Clone the git repository', 'status': 'Not Started'}, {'description': 'Checkout the branch associated with MR 863', 'status': 'Not Started'}, {'description': 'Analyze the CI pipeline configuration', 'status': 'Not Started'}, {'description': 'Identify issues in the CI pipeline', 'status': 'Not Started'}, {'description': 'Make necessary changes to fix the CI pipeline', 'status': 'Not Started'}, {'description': 'Test the changes locally', 'status': 'Not Started'}, {'description': 'Commit and push the changes', 'status': 'Not Started'}, {'description': 'Monitor the CI pipeline execution', 'status': 'Not Started'}, {'description': 'Verify that the CI pipeline is fixed', 'status': 'Not Started'}, {'description': 'Update the Merge Request with the changes and results', 'status': 'Not Started'}]}, 'id': 'toolu_01NJ3DL3jaeBJNKPoZ8hR6pt'}], usage_metadata={'input_tokens': 667, 'output_tokens': 422, 'total_tokens': 1089})]}}
Checkpoint received from GitLab post parse
CheckpointTuple(config={'configurable': {'thread_id': '2', 'thread_ts': '1ef5626a-06cc-6ede-8001-bb25d336e4d4'}}, checkpoint={'v': 1, 'id': '1ef5626a-06cc-6ede-8001-bb25d336e4d4', 'ts': '2024-08-09T08:08:57.200576+00:00', 'pending_sends': [], 'versions_seen': {'planning': {'start:planning': 2}, '__start__': {'__start__': 1}, 'execution': {}, 'update_plan': {}, 'execution_tools': {}, 'execution_handover': {}, 'planning_supervisor': {}, 'execution_supervisor': {}}, 'channel_values': {'plan': {'steps': []}, 'status': 'Planning', 'planning': 'planning', 'conversation_history': {'planner': [{'type': 'SystemMessage', 'content': "\nYou are a planner. Could you create a detailed plan that the execution agent can follow in order to fulfil the user's goal?\nOnce you are done with the plan call the `handover_tool` tool.\n"}, {'type': 'HumanMessage', 'content': 'Your goal is: Please fix the CI pipeline the MR with id 863 in the project with id 47. git repository using this link git@gdk.test:2222/duo-workflow-test/ai-assist.git'}, {'type': 'AIMessage', 'content': [{'text': "Certainly! I'll create a detailed plan for fixing the CI pipeline for the Merge Request (MR) with ID 863 in the project with ID 47. Let's break this down into steps and create a plan using the `update_plan` tool. Then, I'll use the `handover_tool` to summarize the plan for the execution agent.", 'type': 'text'}, {'id': 'toolu_01NJ3DL3jaeBJNKPoZ8hR6pt', 'name': 'update_plan', 'type': 'tool_use', 'input': {'tasks': [{'status': 'Not Started', 'description': 'Clone the git repository'}, {'status': 'Not Started', 'description': 'Checkout the branch associated with MR 863'}, {'status': 'Not Started', 'description': 'Analyze the CI pipeline configuration'}, {'status': 'Not Started', 'description': 'Identify issues in the CI pipeline'}, {'status': 'Not Started', 'description': 'Make necessary changes to fix the CI pipeline'}, {'status': 'Not Started', 'description': 'Test the changes locally'}, {'status': 'Not Started', 'description': 'Commit and push the changes'}, {'status': 'Not Started', 'description': 'Monitor the CI pipeline execution'}, {'status': 'Not Started', 'description': 'Verify that the CI pipeline is fixed'}, {'status': 'Not Started', 'description': 'Update the Merge Request with the changes and results'}]}}]}]}, 'branch:planning:condition:update_plan': 'planning'}, 'channel_versions': {'plan': 2, 'status': 3, 'planning': 3, '__start__': 2, 'start:planning': 3, 'conversation_history': 3, 'branch:planning:condition:update_plan': 3}}, metadata={'step': 1, 'source': 'loop', 'writes': {'planning': {'status': 'Planning', 'conversation_history': {'planner': [{'type': 'SystemMessage', 'content': "\nYou are a planner. Could you create a detailed plan that the execution agent can follow in order to fulfil the user's goal?\nOnce you are done with the plan call the `handover_tool` tool.\n"}, {'type': 'HumanMessage', 'content': 'Your goal is: Please fix the CI pipeline the MR with id 863 in the project with id 47. git repository using this link git@gdk.test:2222/duo-workflow-test/ai-assist.git'}, {'type': 'AIMessage', 'content': [{'text': "Certainly! I'll create a detailed plan for fixing the CI pipeline for the Merge Request (MR) with ID 863 in the project with ID 47. Let's break this down into steps and create a plan using the `update_plan` tool. Then, I'll use the `handover_tool` to summarize the plan for the execution agent.", 'type': 'text'}, {'id': 'toolu_01NJ3DL3jaeBJNKPoZ8hR6pt', 'name': 'update_plan', 'type': 'tool_use', 'input': {'tasks': [{'status': 'Not Started', 'description': 'Clone the git repository'}, {'status': 'Not Started', 'description': 'Checkout the branch associated with MR 863'}, {'status': 'Not Started', 'description': 'Analyze the CI pipeline configuration'}, {'status': 'Not Started', 'description': 'Identify issues in the CI pipeline'}, {'status': 'Not Started', 'description': 'Make necessary changes to fix the CI pipeline'}, {'status': 'Not Started', 'description': 'Test the changes locally'}, {'status': 'Not Started', 'description': 'Commit and push the changes'}, {'status': 'Not Started', 'description': 'Monitor the CI pipeline execution'}, {'status': 'Not Started', 'description': 'Verify that the CI pipeline is fixed'}, {'status': 'Not Started', 'description': 'Update the Merge Request with the changes and results'}]}}]}]}}}}, parent_config={'configurable': {'thread_id': '2', 'thread_ts': '1ef56267-732a-6f2a-8000-58a021eb4463'}})
You can notice that checkpoints before save include collections of instances of
AIMessage, HumanMessage, SystemMessage, ToolMessage
, but after they fetched from GitLab, they are still represented as dictionaries{'type': 'HumanMessage', 'content': 'Your goal is: Please fix the CI pipeline the MR with id 863 in the project with id 47. git repository using this link git@gdk.test:2222/duo-workflow-test/ai-assist.git'}
Right now it should not break anything because, there is no pause/resume mechanism, but it looks like a pitfall ready for a developer to fall into. WDYT about handling that case in the follow up MR?