SEC filing tools for LangChain and LangGraph agents
Add 10-K and 10-Q sections, XBRL financial statements, insider trades and 8-K reports to a LangChain agent with the open source secfeed-langchain package.
A research agent that answers questions about public companies needs a reliable way to read what those companies file with the SEC. The open source secfeed-langchain package gives LangChain and LangGraph agents five tools backed by SecFeed: the right section of the latest 10-K or 10-Q, XBRL financial statements, Form 4 insider trades and recent 8-K reports.
Each tool is a standard LangChain StructuredTool that returns compact text with a link to the source filing, so the model can quote and cite it.
Install
pip install secfeed-langchain langchain langchain-openai
export SECFEED_API_KEY=sf_...
Get a key from your dashboard. The package itself only depends on langchain-core and the secfeed SDK; langchain and langchain-openai are for the agent below.
Build an agent
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from secfeed_langchain import all_tools
agent = create_agent(
ChatOpenAI(model="gpt-4o-mini", temperature=0),
all_tools(),
system_prompt="Answer only from what the SEC filing tools return and cite the filing links.",
)
reply = agent.invoke({"messages": [("user", "What are the top 3 risk factors for TSLA?")]})
print(reply["messages"][-1].content)
Any OpenAI compatible endpoint works with ChatOpenAI (set OPENAI_BASE_URL), and any other chat model that supports tool calling can take the same tools.
| Tool | Returns | API calls |
|---|---|---|
search_10k | Paragraphs of the latest 10-K that answer the question, from Business, Risk Factors, MD&A or Market Risk | 2 |
search_10q | Same for the latest 10-Q | 2 |
financial_statements | Income statement, balance sheet and cash flow from XBRL, latest periods side by side | 1 |
insider_trades | Latest Form 4 transactions with role, buy or sell, shares, price, value and the 10b5-1 flag | 1 |
recent_8k | Latest 8-K reports and the items each one covers | 2 |
Repeat questions about the same filing are cached for the life of the process, so the section is fetched once.
Call a tool yourself
Tools can be invoked directly, which is the quickest way to see what the model will read:
from secfeed_langchain import recent_8k
print(recent_8k.invoke({"ticker": "NVDA", "limit": 3}))
NVIDIA CORP (NVDA) latest 8-K reports:
- 2026-11-12: 5.02 Departure or Appointment of Directors or Officers; Compensatory Arrangements; 9.01 Financial Statements and Exhibits https://www.sec.gov/Archives/edgar/data/1045810/000104581026000082/0001045810-26-000082-index.htm
- 2026-09-03: 8.01 Other Events https://www.sec.gov/Archives/edgar/data/1045810/000104581026000078/0001045810-26-000078-index.htm
- 2026-08-26: 2.02 Results of Operations and Financial Condition; 9.01 Financial Statements and Exhibits https://www.sec.gov/Archives/edgar/data/1045810/000104581026000073/0001045810-26-000073-index.htm
The filing search tools pick the section from the question (risk questions read Item 1A, product and competition questions read Item 1, everything else reads MD&A) and keep the paragraphs that share the most words with it. You can force a section with section="risk", "business", "mdna" or "market_risk".
from secfeed_langchain import search_10k
print(search_10k.invoke({"ticker": "NVDA", "question": "What does the company say about export controls on China?"}))
NVIDIA CORP (NVDA) 10-K filed 2026-02-25, section: Business
Source: https://www.sec.gov/Archives/edgar/data/1045810/000104581026000021/0001045810-26-000021-index.htm
Over the past three years, we have been subject to a series of shifting and expanding export control restrictions, impacting our ability to serve customers outside the United States.
Why no embeddings
The usual way to let an agent read a 10-K is to download the filing, split it into chunks, embed them and retrieve the closest ones. With a filing that long, the retriever often returns pieces of the table of contents or the exhibit index. SecFeed's Section Extractor returns the exact item instead, so a simple keyword ranking inside one section is enough, and you need no vector store or embeddings key.