[PR #1363] [MERGED] Include exception traceback in run_with_retry logging #2041

Closed
opened 2026-02-20 17:46:09 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraph/pull/1363
Author: @Glavin001
Created: 8/15/2024
Status: Merged
Merged: 8/15/2024
Merged by: @nfcampos

Base: mainHead: patch-1


📝 Commits (3)

📊 Changes

2 files changed (+7 additions, -3 deletions)

View changed files

📝 libs/langgraph/langgraph/pregel/retry.py (+4 -2)
📝 libs/langgraph/tests/test_pregel.py (+3 -1)

📄 Description

About

  • LangGraph Studio 0.0.12 (0.0.12)
  • langgraph 0.2.3

Real Example Logs

This is a real example from running my graph with a bug in one of the nodes.

Before - Logs are not useful for locating bug

langgraph-api-1       | Retrying task Generate Data Schema after 0.23 seconds (attempt 2) after AttributeError 'dict' object has no attribute 'project_id'
langgraph-api-1       | Run Error

After - Logs are useful for locating bug

langgraph-api-1       | Retrying task Generate Data Schema after 0.23 seconds (attempt 2) due to:
AttributeError: 'dict' object has no attribute 'project_id'
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/langgraph/pregel/retry.py", line 74, in arun_with_retry
    async for _ in task.proc.astream(task.input, task.config):
  File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3287, in astream
    async for chunk in self.atransform(input_aiter(), config, **kwargs):
  File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3270, in atransform
    async for chunk in self._atransform_stream_with_config(
  File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 2161, in _atransform_stream_with_config
    chunk: Output = await asyncio.create_task(  # type: ignore[call-arg]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 181, in tap_output_aiter
    first = await py_anext(output, default=sentinel)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/langchain_core/utils/aiter.py", line 78, in anext_impl
    return await __anext__(iterator)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3240, in _atransform
    async for output in final_pipeline:
  File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1314, in atransform
    async for ichunk in input:
  File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1332, in atransform
    async for output in self.astream(final, config, **kwargs):
  File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 875, in astream
    yield await self.ainvoke(input, config, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/REDACTED.py", line 82, in ainvoke
    "project_id": self.prompt.project_id,
                          ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'project_id'

langgraph-api-1       | Run Error

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraph/pull/1363 **Author:** [@Glavin001](https://github.com/Glavin001) **Created:** 8/15/2024 **Status:** ✅ Merged **Merged:** 8/15/2024 **Merged by:** [@nfcampos](https://github.com/nfcampos) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (3) - [`d15c5a4`](https://github.com/langchain-ai/langgraph/commit/d15c5a46de3f4065741f1e654f4b61ca8290b00d) Include exception traceback in run_with_retry logging - [`78781b0`](https://github.com/langchain-ai/langgraph/commit/78781b0a9004b0ff15ac784307fdf0312dcafe47) Use exc_info - [`6a68581`](https://github.com/langchain-ai/langgraph/commit/6a68581a9fb8f579d5164cd8a07a35770e7b5563) Lint ### 📊 Changes **2 files changed** (+7 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `libs/langgraph/langgraph/pregel/retry.py` (+4 -2) 📝 `libs/langgraph/tests/test_pregel.py` (+3 -1) </details> ### 📄 Description ## About - LangGraph Studio 0.0.12 (0.0.12) - langgraph 0.2.3 ## Real Example Logs This is a real example from running my `graph` with a bug in one of the nodes. ### :x: Before - Logs are not useful for locating bug ```python langgraph-api-1 | Retrying task Generate Data Schema after 0.23 seconds (attempt 2) after AttributeError 'dict' object has no attribute 'project_id' langgraph-api-1 | Run Error ``` ### ✅ After - Logs are useful for locating bug ```python langgraph-api-1 | Retrying task Generate Data Schema after 0.23 seconds (attempt 2) due to: AttributeError: 'dict' object has no attribute 'project_id' Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/langgraph/pregel/retry.py", line 74, in arun_with_retry async for _ in task.proc.astream(task.input, task.config): File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3287, in astream async for chunk in self.atransform(input_aiter(), config, **kwargs): File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3270, in atransform async for chunk in self._atransform_stream_with_config( File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 2161, in _atransform_stream_with_config chunk: Output = await asyncio.create_task( # type: ignore[call-arg] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/langchain_core/tracers/event_stream.py", line 181, in tap_output_aiter first = await py_anext(output, default=sentinel) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/langchain_core/utils/aiter.py", line 78, in anext_impl return await __anext__(iterator) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3240, in _atransform async for output in final_pipeline: File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1314, in atransform async for ichunk in input: File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1332, in atransform async for output in self.astream(final, config, **kwargs): File "/usr/local/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 875, in astream yield await self.ainvoke(input, config, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/REDACTED.py", line 82, in ainvoke "project_id": self.prompt.project_id, ^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'project_id' langgraph-api-1 | Run Error ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-20 17:46:09 -05:00
yindo closed this issue 2026-02-20 17:46:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#2041