feat(agent): record E2B sandbox runtime usage (#42554)

This commit is contained in:
zyssyz123
2026-09-21 07:11:12 +00:00
committed by GitHub
parent 1fa3245e83
commit af4f19840c
29 changed files with 3501 additions and 5 deletions
@@ -49,6 +49,17 @@ DIFY_AGENT_E2B_TEMPLATE=difys-default-team/dify-agent-local-sandbox
DIFY_AGENT_E2B_ACTIVE_TIMEOUT_SECONDS=3600
DIFY_AGENT_E2B_SHELLCTL_PORT=5004
# Independent sandbox usage ledger. API owns fixed activation time T0; no backfill.
# Enable only with matching API metering project settings and events API access.
# Celery Beat in the API triggers a protected one-shot collection endpoint.
# No operation logging, Agent polling loop, or collector Redis leader.
# Collection requires the existing DIFY_AGENT_API_TOKEN to be configured.
DIFY_AGENT_SANDBOX_METERING_ENABLED=false
DIFY_AGENT_E2B_PROJECT_ID=
DIFY_AGENT_SANDBOX_METERING_OVERLAP_SECONDS=900
DIFY_AGENT_SANDBOX_METERING_FULL_SCAN_INTERVAL_SECONDS=3600
DIFY_AGENT_SANDBOX_METERING_MAX_PAGES=1000
# OpenShell backend (DIFY_AGENT_RUNTIME_BACKEND=openshell): sandboxes run on a
# self-hosted NVIDIA OpenShell gateway. Setup and validation:
# dify-agent/docs/dify-agent/guide/openshell.md
@@ -127,6 +127,13 @@ AGENT_BACKEND_STREAM_MAX_RECONNECTS=3
# Client timeout for Agent backend calls that may carry a Home Snapshot transfer.
# Must stay above DIFY_AGENT_ENTERPRISE_SANDBOX_SNAPSHOT_TIMEOUT on the Agent backend.
AGENT_BACKEND_HOME_SNAPSHOT_TIMEOUT_SECONDS=45
# Independent E2B accounting, collected only by API Celery Beat/workers.
# Uses the existing ops_trace queue; business binding operations never call metering.
# Enable after migrations. START_AT is an immutable, whole-second UTC T0.
AGENT_SANDBOX_METERING_ENABLED=false
AGENT_SANDBOX_METERING_PROJECT_ID=
AGENT_SANDBOX_METERING_START_AT=
AGENT_SANDBOX_METERING_INTERVAL_SECONDS=60
# Outer execution limit for Agent Apps. Agent Backend may stop the internal
# model/tool loop sooner when DIFY_AGENT_RUN_TIMEOUT_SECONDS is lower.
APP_MAX_EXECUTION_TIME=3600