Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileCallbackHandler can't resolve name in on_chain_start (same as #26588) #29941

Open
5 tasks done
mirskiy opened this issue Feb 23, 2025 · 1 comment · May be fixed by #29942
Open
5 tasks done

FileCallbackHandler can't resolve name in on_chain_start (same as #26588) #29941

mirskiy opened this issue Feb 23, 2025 · 1 comment · May be fixed by #29942
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@mirskiy
Copy link

mirskiy commented Feb 23, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

#!/usr/bin/env python3
from langchain_core.callbacks import FileCallbackHandler, StdOutCallbackHandler
from langchain.chat_models import init_chat_model
from langchain_community.utilities import SQLDatabase
from langchain_community.agent_toolkits import create_sql_agent
from sqlalchemy import create_engine

logfile = "output.log"
handlier = FileCallbackHandler(logfile)

engine = create_engine("sqlite:///titanic.db")
db = SQLDatabase(engine=engine)
llm = init_chat_model("gpt-4o-mini", model_provider="openai")
agent_executor = create_sql_agent(
        llm, db=db,
        agent_type="openai-tools",
        agent_executor_kwargs={"callbacks": [handlier]},
        verbose=True)
agent_executor.invoke({"input": "test"})

Error Message and Stack Trace (if applicable)

Error in FileCallbackHandler.on_chain_start callback: AttributeError("'NoneType' object has no attribute 'get'")

Description

Same issue as #26588
FileCallbackHandler.on_chain_start doesn't resolve name from kwargs.

System Info

System Information

OS: Linux
OS Version: #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023
Python Version: 3.13.2 (main, Feb 22 2025, 11:11:40) [GCC 7.5.0]

Package Information

langchain_core: 0.3.37
langchain: 0.3.19
langchain_community: 0.3.18
langsmith: 0.3.10
langchain_openai: 0.3.6
langchain_text_splitters: 0.3.6
langgraph_sdk: 0.1.53

Optional packages not installed

langserve

Other Dependencies

aiohttp<4.0.0,>=3.8.3: Installed. No version info available.
async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
dataclasses-json<0.7,>=0.5.7: Installed. No version info available.
httpx: 0.28.1
httpx-sse<1.0.0,>=0.4.0: Installed. No version info available.
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-anthropic;: Installed. No version info available.
langchain-aws;: Installed. No version info available.
langchain-cohere;: Installed. No version info available.
langchain-community;: Installed. No version info available.
langchain-core<1.0.0,>=0.3.34: Installed. No version info available.
langchain-core<1.0.0,>=0.3.35: Installed. No version info available.
langchain-core<1.0.0,>=0.3.37: Installed. No version info available.
langchain-deepseek;: Installed. No version info available.
langchain-fireworks;: Installed. No version info available.
langchain-google-genai;: Installed. No version info available.
langchain-google-vertexai;: Installed. No version info available.
langchain-groq;: Installed. No version info available.
langchain-huggingface;: Installed. No version info available.
langchain-mistralai;: Installed. No version info available.
langchain-ollama;: Installed. No version info available.
langchain-openai;: Installed. No version info available.
langchain-text-splitters<1.0.0,>=0.3.6: Installed. No version info available.
langchain-together;: Installed. No version info available.
langchain-xai;: Installed. No version info available.
langchain<1.0.0,>=0.3.19: Installed. No version info available.
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
langsmith<0.4,>=0.1.17: Installed. No version info available.
numpy<2,>=1.26.4;: Installed. No version info available.
numpy<3,>=1.26.2;: Installed. No version info available.
openai<2.0.0,>=1.58.1: Installed. No version info available.
orjson: 3.10.15
packaging<25,>=23.2: Installed. No version info available.
pydantic: 2.10.6
pydantic-settings<3.0.0,>=2.4.0: Installed. No version info available.
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
pytest: Installed. No version info available.
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.3
requests-toolbelt: 1.0.0
requests<3,>=2: Installed. No version info available.
rich: 13.9.4
SQLAlchemy<3,>=1.4: Installed. No version info available.
tenacity!=8.4.0,<10,>=8.1.0: Installed. No version info available.
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken<1,>=0.7: Installed. No version info available.
typing-extensions>=4.7: Installed. No version info available.
zstandard: 0.23.0

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Feb 23, 2025
@mirskiy
Copy link
Author

mirskiy commented Feb 23, 2025

Propsed fix in #29942, let me know if this is acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant