Langfuse AI Agent icon

Langfuse AI Agent

Run an AI Agent with Langfuse prompt management and tracing

Overview

This node integrates with Langfuse to run an AI Agent using managed prompts and tracing capabilities. It allows users to select a predefined prompt from Langfuse or specify one by ID, pass parameters to that prompt, and then execute the prompt through a connected AI language model and output parser.

Common scenarios include:

  • Automating complex AI workflows where prompts are centrally managed and versioned in Langfuse.
  • Running AI agents that require detailed tracing and monitoring of prompt usage.
  • Dynamically injecting parameters into prompts for customized AI responses.

For example, a user might select a customer support prompt stored in Langfuse, provide specific customer details as parameters, and get a tailored AI-generated response parsed into structured data.

Properties

Name Meaning
Prompt Name or ID The name or ID of the prompt to retrieve from Langfuse. Choose from a dropdown list or specify via expression.
Prompt Parameters JSON string representing parameters to pass into the prompt, allowing dynamic customization of the prompt content.

Output

The node outputs an array of items, each containing a json field with the AI agent's response after executing the prompt with the provided parameters. The structure of the JSON depends on the connected AI output parser but generally represents the processed AI output.

No binary data output is produced by this node.

Dependencies

  • Requires an API key credential for Langfuse (public and secret keys) and the Langfuse host URL.
  • Depends on external packages:
    • @langchain/core/prompts
    • @langchain/core/runnables
    • langfuse-langchain
  • Requires connections to:
    • An AI language model node providing the language model input.
    • An AI output parser node to parse the raw AI output into structured data.

Troubleshooting

  • Invalid Prompt Name or ID: If the specified prompt does not exist or cannot be retrieved, the node will fail. Ensure the prompt name/ID is correct and accessible via the Langfuse API.
  • Malformed Prompt Parameters: The "Prompt Parameters" must be valid JSON. Invalid JSON will cause parsing errors. Validate the JSON syntax before running.
  • Credential Issues: Missing or incorrect API credentials will prevent communication with Langfuse. Verify that the API keys and host URL are correctly configured.
  • Connection Errors: The node requires proper connections to an AI language model and an output parser. Missing these connections will cause execution failure.
  • Runtime Errors from External Libraries: Since the node dynamically imports Langchain and Langfuse libraries, ensure these dependencies are installed and compatible with the n8n environment.

Links and References

Discussion