_get_agent() — langchain Function Reference
Architecture documentation for the _get_agent() function in test_agent.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 14f78f65_e4e5_9e87_0c7c_292f4c2d21f0["_get_agent()"] 47a7b285_8e60_f78f_282d_429958c446fa["test_agent.py"] 14f78f65_e4e5_9e87_0c7c_292f4c2d21f0 -->|defined in| 47a7b285_8e60_f78f_282d_429958c446fa e78ae43f_ff72_c1f8_bbbb_e6e45b334c06["test_agent_bad_action()"] e78ae43f_ff72_c1f8_bbbb_e6e45b334c06 -->|calls| 14f78f65_e4e5_9e87_0c7c_292f4c2d21f0 6cbeb4f4_3c6e_44dd_4687_6a309a4c183e["test_agent_stopped_early()"] 6cbeb4f4_3c6e_44dd_4687_6a309a4c183e -->|calls| 14f78f65_e4e5_9e87_0c7c_292f4c2d21f0 style 14f78f65_e4e5_9e87_0c7c_292f4c2d21f0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/tests/unit_tests/agents/test_agent.py lines 83–111
def _get_agent(**kwargs: Any) -> AgentExecutor:
"""Get agent for testing."""
bad_action_name = "BadAction"
responses = [
f"I'm turning evil\nAction: {bad_action_name}\nAction Input: misalignment",
"Oh well\nFinal Answer: curses foiled again",
]
fake_llm = FakeListLLM(cache=False, responses=responses)
tools = [
Tool(
name="Search",
func=lambda x: x,
description="Useful for searching",
),
Tool(
name="Lookup",
func=lambda x: x,
description="Useful for looking up things in a table",
),
]
return initialize_agent(
tools,
fake_llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True,
**kwargs,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does _get_agent() do?
_get_agent() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/agents/test_agent.py.
Where is _get_agent() defined?
_get_agent() is defined in libs/langchain/tests/unit_tests/agents/test_agent.py at line 83.
What calls _get_agent()?
_get_agent() is called by 2 function(s): test_agent_bad_action, test_agent_stopped_early.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free