33
44import typer
55from dotenv import load_dotenv
6+ from langchain_core .runnables .config import RunnableConfig
67
78from template_langgraph .agents .chat_with_tools_agent .agent import graph as chat_with_tools_agent_graph
89from template_langgraph .agents .image_classifier_agent .agent import graph as image_classifier_agent_graph
@@ -92,6 +93,12 @@ def run(
9293 "-q" ,
9394 help = "Question to ask the agent" ,
9495 ),
96+ recursion_limit : int = typer .Option (
97+ 10 ,
98+ "--recursion-limit" ,
99+ "-r" ,
100+ help = "Recursion limit for the agent" ,
101+ ),
95102 verbose : bool = typer .Option (
96103 False ,
97104 "--verbose" ,
@@ -116,7 +123,10 @@ def run(
116123 "content" : question ,
117124 }
118125 ],
119- }
126+ },
127+ config = RunnableConfig (
128+ recursion_limit = recursion_limit ,
129+ ),
120130 ):
121131 logger .info ("-" * 20 )
122132 logger .info (f"Event: { event } " )
@@ -142,6 +152,12 @@ def news_summarizer_agent(
142152 "-o" ,
143153 help = "Path to the output Markdown file" ,
144154 ),
155+ recursion_limit : int = typer .Option (
156+ 10 ,
157+ "--recursion-limit" ,
158+ "-r" ,
159+ help = "Recursion limit for the agent" ,
160+ ),
145161 verbose : bool = typer .Option (
146162 False ,
147163 "--verbose" ,
@@ -162,7 +178,10 @@ def news_summarizer_agent(
162178 urls = urls .split ("," ) if urls else [],
163179 ),
164180 articles = [],
165- )
181+ ),
182+ config = RunnableConfig (
183+ recursion_limit = recursion_limit ,
184+ ),
166185 ):
167186 logger .info ("-" * 20 )
168187 logger .info (f"Event: { event } " )
@@ -189,6 +208,12 @@ def image_classifier_agent(
189208 "-f" ,
190209 help = "Comma-separated list of file paths to classify" ,
191210 ),
211+ recursion_limit : int = typer .Option (
212+ 10 ,
213+ "--recursion-limit" ,
214+ "-r" ,
215+ help = "Recursion limit for the agent" ,
216+ ),
192217 verbose : bool = typer .Option (
193218 False ,
194219 "--verbose" ,
@@ -214,7 +239,10 @@ def image_classifier_agent(
214239 file_paths = file_paths .split ("," ) if file_paths else [],
215240 ),
216241 results = [],
217- )
242+ ),
243+ config = RunnableConfig (
244+ recursion_limit = recursion_limit ,
245+ ),
218246 ):
219247 logger .info ("-" * 20 )
220248 logger .info (f"Event: { event } " )
0 commit comments