dify-attesta package provides an Attesta plugin for the Dify platform. It adds an Attesta Approval tool that evaluates AI agent actions for risk through the full Attesta pipeline, with provider-level credentials for configuring the risk threshold.
Package:
dify-attesta v0.0.1 | Language: Python | Type: Dify plugin | Dependencies: attesta, dify_pluginInstallation
1
Build the plugin archive
From the The plugin directory contains:
dify-attesta directory, build the .difypkg file following the Dify plugin packaging guide:2
Upload to Dify
In the Dify dashboard, navigate to Plugins and upload the
.difypkg file.3
Configure the provider
After installation, go to Tools > Attesta > Authorize and configure the optional Risk Threshold credential (see Provider Credentials below).
4
Add to a workflow
In any Dify app (chatbot or workflow), add the Attesta Approval tool from the tool picker.
Provider Credentials
The Attesta provider (AttestaProvider) defines one optional credential that applies to all Attesta tools in the workspace:
The provider’s
_validate_credentials() method validates that risk_threshold is a number between 0 and 1. Values outside this range raise a ToolProviderCredentialValidationError.
To configure:
- Go to Tools > Attesta > Authorize
- Set the Risk Threshold value (placeholder:
0.5) - Save
Tool Configuration
The Attesta Approval tool (AttestaGateTool) has three parameters, defined in tools/attesta_gate.yaml:
Parameters with form type
LLM are filled by the language model at runtime based on the conversation context. Parameters with form type Form are configured by the user in the tool settings. This means function_name and action_args are dynamically determined by the LLM, while risk_level is set once during configuration.A human-in-the-loop approval tool that evaluates AI agent actions for risk before execution. Use this tool to check whether a proposed action should be allowed.
How It Works
1
LLM Invokes the Tool
During a conversation or workflow execution, the LLM decides to call the Attesta Approval tool. It provides the
function_name and action_args parameters based on the action it wants to evaluate.2
Parse Arguments
The tool parses
action_args. If the value is a string, it attempts JSON parsing. Failed parses are wrapped as {"raw_input": <value>}. If the value is already a dict (from a workflow node), it is used directly.3
Apply Credentials
The
risk_threshold from the provider credentials is read via self.runtime.credentials.get("risk_threshold") and added to the risk hints as {"threshold": <value>}.4
Build ActionContext
The tool creates an
ActionContext with:function_name: from the LLM parameterkwargs: from the parsed action argumentshints: risk hints including the threshold from credentialsenvironment:"production"metadata:{"source": "dify"}
5
Evaluate
The
ActionContext is passed to attesta.evaluate(). The tool handles both async and sync execution contexts (see Async Execution below).6
Yield Result
The tool yields a single
ToolInvokeMessage (JSON) via self.create_json_message() with the verdict, risk score, and audit metadata.Output Format
The tool yields a JSON message with the following fields:- Approved
- Denied
message field provides a human-readable summary that the LLM can relay to the user. The denied boolean provides a simple check for downstream branching in workflows.
Usage Examples
Example: Chatbot with Gated Actions
In a Dify chatbot app, add the Attesta Approval tool so the LLM can check approval before performing actions:- Create a new Chatbot app in Dify.
- Under Tools, add the Attesta Approval tool.
- Set Risk Level to
Auto (Score-based). - In the system prompt, instruct the LLM:
- The LLM will call the tool with the function name and arguments before executing any risky action.
Example: Workflow with Conditional Branching
In a Dify workflow app, use the Attesta tool output to branch execution:- Create a Workflow app.
- Add an LLM node that determines the action to take.
- Add the Attesta Approval tool node.
- Add an IF/ELSE node that checks the
deniedfield from the Attesta output. - Route to the action node on approval, or to a denial response on denial.
Example: Multi-Tool Evaluation
The LLM can call the Attesta tool multiple times in one conversation to evaluate different actions at different risk levels:Async Execution
The Dify tool uses a synchronous_invoke() generator method (as required by the dify_plugin.Tool base class), but Attesta’s evaluate() is async. The tool handles this automatically:
- No event loop running: Uses
asyncio.run()to execute the evaluation synchronously. - Event loop already running (common in Dify’s async runtime): Creates a task on the existing loop and waits for the result via a
concurrent.futures.Futurewith a 30-second timeout.
Manifest Details
The plugin manifest (manifest.yaml) declares the plugin metadata and resource requirements:
Related Pages
n8n Integration
Workflow node for n8n data pipelines
Flowise Integration
Tool component for Flowise chatflows
Langflow Integration
Python component for Langflow pipelines
No-Code Overview
Compare all no-code platforms