Home / Function/ get_agent_trajectory() — langchain Function Reference

get_agent_trajectory() — langchain Function Reference

Architecture documentation for the get_agent_trajectory() function in trajectory_eval_chain.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  55207f35_65b3_64d0_f5f6_009c83675231["get_agent_trajectory()"]
  9066f65c_c5a3_1534_5336_72609f4ff02b["TrajectoryEvalChain"]
  55207f35_65b3_64d0_f5f6_009c83675231 -->|defined in| 9066f65c_c5a3_1534_5336_72609f4ff02b
  209b81c4_c8b0_b3f6_5d00_bbfecbd33b06["_evaluate_agent_trajectory()"]
  209b81c4_c8b0_b3f6_5d00_bbfecbd33b06 -->|calls| 55207f35_65b3_64d0_f5f6_009c83675231
  44628635_1e0c_b92e_8aa5_3a4e76f50ba0["_aevaluate_agent_trajectory()"]
  44628635_1e0c_b92e_8aa5_3a4e76f50ba0 -->|calls| 55207f35_65b3_64d0_f5f6_009c83675231
  style 55207f35_65b3_64d0_f5f6_009c83675231 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/evaluation/agents/trajectory_eval_chain.py lines 181–203

    def get_agent_trajectory(
        steps: str | Sequence[tuple[AgentAction, str]],
    ) -> str:
        """Get the agent trajectory as a formatted string.

        Args:
            steps: The agent trajectory.

        Returns:
            The formatted agent trajectory.
        """
        if isinstance(steps, str):
            return steps

        return "\n\n".join(
            [
                f"""Step {i}:
Tool used: {action.tool}
Tool input: {action.tool_input}
Tool output: {output}"""
                for i, (action, output) in enumerate(steps, 1)
            ],
        )

Domain

Subdomains

Frequently Asked Questions

What does get_agent_trajectory() do?
get_agent_trajectory() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/agents/trajectory_eval_chain.py.
Where is get_agent_trajectory() defined?
get_agent_trajectory() is defined in libs/langchain/langchain_classic/evaluation/agents/trajectory_eval_chain.py at line 181.
What calls get_agent_trajectory()?
get_agent_trajectory() is called by 2 function(s): _aevaluate_agent_trajectory, _evaluate_agent_trajectory.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free